{"id":18536,"date":"2022-03-19T03:36:15","date_gmt":"2022-03-19T03:36:15","guid":{"rendered":"https:\/\/jurn.link\/dazposer\/?p=18536"},"modified":"2022-04-17T00:40:58","modified_gmt":"2022-04-17T00:40:58","slug":"script-apply-a-single-shader-to-multiple-surfaces-in-daz","status":"publish","type":"post","link":"https:\/\/jurn.link\/dazposer\/index.php\/2022\/03\/19\/script-apply-a-single-shader-to-multiple-surfaces-in-daz\/","title":{"rendered":"Script: apply a single shader to multiple surfaces in DAZ"},"content":{"rendered":"<p>I\u2019ve finally found and hacked a working way to have a script apply a single shader across multiple surfaces in DAZ. Many hours of searching and testing finally surfaced Mcasual\u2019s free <em><a href=\"https:\/\/sites.google.com\/site\/mcasualsdazscripts5\/mcjselectthesemats\">mcjSelectTheseMats<\/a><\/em>. This will do the job in DAZ 4.12.x, with a few custom adjustments. I\u2019m amazed no-one has made such a script for this basic task, until now. Here is my working tweak to extend the \u2018mcjSelectTheseMats\u2019 script.<\/p>\n<p><a href=\"https:\/\/jurn.link\/dazposer\/wp-content\/uploads\/2022\/04\/SelectTheseMats_ApplyShader.txt\">SelectTheseMats_ApplyShader.txt<\/a> (download, rename to be a .DSA script)<\/p>\n<p>This selects the named base figure in the scene, then makes sure he is really selected, then selects and highlights all the non-eye surfaces of the \u2018Genesis 2 Male\u2019. Adjust as desired for your likely target figure (e.g \u2018Genesis 8 Female\u2019. There is also a naming convention which handles having two or more Genesis figures of the same base type in a scene).<\/p>\n<p>The resulting script auto-selects all the required surfaces. This part works even if something else entirely is selected in the scene, when the script is run, e.g. a light. It also doesn\u2019t matter if the target figure is named \u2018Fluffy Bunny\u2019 etc in your runtime, the DAZ scene only sees and knows him as a \u2018Genesis 2 Male\u2019.<\/p>\n<p>Then at the end of the script, I added two lines to apply the chosen shader to the selected surfaces. Obviously you will need to adjust the path to your desired shader and file and then save the script.<\/p>\n<p>With this script in hand you can then theoretically build it into a larger multi-pass \u2018render, load and repeat\u2019 script. By having the script make an automatic render after each new shader is applied. It would be \u2018shader-based\u2019 multi-pass, rather than \u2018render-engine based\u2019 multi-pass.<\/p>\n<p>Obviously the script as it stands is not the \u2018apply to all surfaces in a scene, except those identified as eyes\u2019 I initially wanted, but it works and goes a long way toward it.<\/p>\n<hr>\n<p>Also, this was the short non-working version that I wrestled with for a long time. Theoretically it should work, but it doesn\u2019t select the surfaces, only applies the shader to any <em>already-selected<\/em> surfaces\u2026<\/p>\n<p><em><br \/>\nvar figure = Scene.findNodeByLabel( &#8220;Genesis 2 Male&#8221; );<br \/>\nfigure.select( true );<br \/>\nvar sPathToFile = &#8220;C:\/\/my_folder\/my_shader.duf&#8221;;<br \/>\nApp.getContentMgr().openFile( sPathToFile, true );<br \/>\n<\/em><\/p>\n<p>It may save someone else the trouble in the future.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I\u2019ve finally found and hacked a working way to have a script apply a single shader across multiple surfaces in DAZ. Many hours of searching and testing finally surfaced Mcasual\u2019s free mcjSelectTheseMats. This will do the job in DAZ 4.12.x, with a few custom adjustments. I\u2019m amazed no-one has made such a script for this [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,9,12],"tags":[],"class_list":["post-18536","post","type-post","status-publish","format-standard","hentry","category-daz-studio","category-freebies","category-tutorials"],"_links":{"self":[{"href":"https:\/\/jurn.link\/dazposer\/index.php\/wp-json\/wp\/v2\/posts\/18536","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jurn.link\/dazposer\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jurn.link\/dazposer\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jurn.link\/dazposer\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jurn.link\/dazposer\/index.php\/wp-json\/wp\/v2\/comments?post=18536"}],"version-history":[{"count":2,"href":"https:\/\/jurn.link\/dazposer\/index.php\/wp-json\/wp\/v2\/posts\/18536\/revisions"}],"predecessor-version":[{"id":18539,"href":"https:\/\/jurn.link\/dazposer\/index.php\/wp-json\/wp\/v2\/posts\/18536\/revisions\/18539"}],"wp:attachment":[{"href":"https:\/\/jurn.link\/dazposer\/index.php\/wp-json\/wp\/v2\/media?parent=18536"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jurn.link\/dazposer\/index.php\/wp-json\/wp\/v2\/categories?post=18536"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jurn.link\/dazposer\/index.php\/wp-json\/wp\/v2\/tags?post=18536"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}