Shader Builder - How to Decouple Ambient from Diffuse

DAZ_bfurnerDAZ_bfurner Posts: 62
edited December 1969 in Daz Studio Discussion

A special thanks to ReDave and many others who contributed to this information. The original and full forum post can be viewed here: Shader Builder - How to Decouple Ambient from Diffuse

Here's a mini tutorial on how to decouple ambient from diffuse. You will loose tiling, AFAICT, and the shader doesn't seem to load in Shader Mixer for further shader play, so all of that will have to be redone in Shader Builder. :?
Shader Builder can be overwhelming with lots of windows with plenty of confusing stuff, but the procedure to decouple ambient is not painful at all.
The first pic shows the familiar state of affairs, of ambient slaved to diffuse.
Bring up Shader Builder (View->Tabs->Shader Builder). The active tab should say Catalog, below it is a panel labeled Shader Categories, and several shader categories are listed below it. Click on the one named Surface, if it isn't the default. In the panel on the right you'll see four icons, one of which is named DzPower. Right-click on it and select Duplicate Shader, and give it a name. I named it DzPower Ambient. Double click (or right click and select Edit Shader) on the newly created DzPower Ambient shader. A new window will appear with a number of squiggly lines going to and fro. Roughly in the middle of those lines will be a largish block named Plastic. Again either double click anywhere inside the block, or right click on it and select Edit Macro Instance. This will pop up yet another window. In the bottom part of this window are three tabs, named Global Code, Initialization Code and Evaluation Code. Click on the latter: you'll see a short line that probably says (probably, because I edited it :lol: ):
(§2§*(§6§+%+§5§+%)+%+§4§)
Cut the §6§+% part and paste it outside of the parentheses that are multiplied by §2§, such that it looks for example like this:
(§2§*(§5§+%)+§6§+%+%+§4§)
Ok, we're done, click Accept. I clicked on Save Network just under the Atmosphere Code tab on the window with all the squiggly lines, then closed that window. Now we're back at the Shader Builder main window, right click on your new shader and click on Apply to selected surface(s).
Final picture shows the result.

image

image

image

image

image

Comments

  • GhostofMacbethGhostofMacbeth Posts: 1,524
    edited December 1969

    Been wanting to do this for years. It will be handy when I can actually see the images.

  • ReDaveReDave Posts: 815
    edited October 2012

    Glad to be of help GhostofMacbeth!
    However the formulas haven't been copied correctly. :-S They should be respectively:
    (§2§*(§6§+% 14%+§5§+% 15%)+% 16%+§4§) (Note that there are no spaces between % and each number following it, but the forum code breaks ands shows just % if I leave them as they are).
    and:
    (§2§*((§5§+% 15%))+§6§+% 14%+% 16%+§4§)
    The link to the old thread is http://forumarchive.daz3d.com/viewtopic.php?t=126939
    I'll try to make a tutorial with pictures from the most informative posts.

    The links to the original screenshots are also broken in the OP, they are:
    http://forumarchive.daz3d.com/postimages/origimage_1_2081503.jpg
    http://forumarchive.daz3d.com/postimages/origimage_2_2081503.jpg
    http://forumarchive.daz3d.com/postimages/origimage_3_2081503.jpg
    http://forumarchive.daz3d.com/postimages/origimage_4_2081503.jpg
    http://forumarchive.daz3d.com/postimages/origimage_5_2081503.jpg
    I'm attaching the significant pictures. The ordering should be: picture ending with 2_2081503.jpg should come first, then 3_2081503.jpg then 4_2081503.jpg.

    Modified_Block.png
    640 x 640 - 27K
    origimage_4_2081503[1].jpg
    583 x 614 - 97K
    origimage_3_2081503[1].jpg
    308 x 436 - 42K
    origimage_2_2081503[1].jpg
    803 x 440 - 56K
    Post edited by ReDave on
  • wancowwancow Posts: 2,708
    edited December 1969

    Stupid Question: Why?

    Why would I want to decouple Ambient from Diffuse?

  • Richard HaseltineRichard Haseltine Posts: 95,997
    edited December 1969

    So that you can do glow effects - for example, magma channels or glowing runes in dark rock. While the two are coupled the dark diffuse colour will limit the glow, which isn't always desirable - and since Poser doesn't multiply diffuse and ambient quite a few products use the ambient for glow technique.

  • wancowwancow Posts: 2,708
    edited December 1969

    OH! Kewlness, think that would work for things like lazers, gun flashes or other auras?

  • mjc1016mjc1016 Posts: 15,001
    edited January 2013

    Well, it's a fun thing to play with that, does have a very practical use...and from the looks of a couple of recent threads, maybe needed.

    Post edited by mjc1016 on
  • blondie9999blondie9999 Posts: 771
    edited December 1969

    wancow said:
    OH! Kewlness, think that would work for things like lazers, gun flashes or other auras?

    Yes, it would. That's how I did "glowing" effects in Poser for years (where the ambient is a separate channel) and why I've been screaming for years for DAZ to "unslave" the ambient channel from the diffuse channel in DS.
  • wancowwancow Posts: 2,708
    edited December 1969

    wancow said:
    OH! Kewlness, think that would work for things like lazers, gun flashes or other auras?

    Yes, it would. That's how I did "glowing" effects in Poser for years (where the ambient is a separate channel) and why I've been screaming for years for DAZ to "unslave" the ambient channel from the diffuse channel in DS.

    Is that DAZ or 3Delight?

  • GhostofMacbethGhostofMacbeth Posts: 1,524
    edited December 1969

    It is DAZ, I think. An old version had them split so you could do what we are talking about.

  • mjc1016mjc1016 Posts: 15,001
    edited December 1969

    wancow said:
    wancow said:
    OH! Kewlness, think that would work for things like lazers, gun flashes or other auras?

    Yes, it would. That's how I did "glowing" effects in Poser for years (where the ambient is a separate channel) and why I've been screaming for years for DAZ to "unslave" the ambient channel from the diffuse channel in DS.

    Is that DAZ or 3Delight?

    Well, sort of both...but it isn't 'slaved' in 3Delight, so much as that's how many of the surface shaders are written. It used to be pretty much the common way of doing it. When the basic DS stuff was written that's the way it was done and that's the way it's stayed. So without editing the shader or using a different one entirely, it's 'slaved' in DS, especially since most DS users aren't going to get 'under the hood' to actually change it, the change would have to come from DAZ itself.

    I'd like to see a basic DS surface shader that has a 'twin' with the Ambient decoupled already...

  • Richard HaseltineRichard Haseltine Posts: 95,997
    edited December 1969

    Ideally a "Multiply Ambient through Diffuse" setting, like the oen we already have for specularity and opacity.

  • ReDaveReDave Posts: 815
    edited January 2013

    wancow said:
    Stupid Question: Why?

    Why would I want to decouple Ambient from Diffuse?

    When you make a render you have to add colours in some fashion. A visually oriented explanation would be something like this:
    Put 255 red in your diffuse channel, and 255 green in Ambient.
    Make sure both are at 100% strength.
    Screenshot with yellow green sphere shows the OpenGL preview.
    Screenshot with red sphere shows the 3Delight render of the same scene.


    I thought you could force the DAZ default shader to give the same results if you left both Diffuse and Ambient Colour to white and applied a 1 pixel *1 pixel red texture to Diffuse and likewise 1 pixel * 1 pixel green texture in Ambient. But actually that doesn't work and I don't know why. Basically if you do that the OpenGL preview gives a perfectly red sphere (no diffuse to speak of), but the 3Delight render shows a red ball with very definite darkening towards the edges (i.e. a diffuse look). Still, it's vastly less different than doing it the other way, and doesn't require messing with shaders.

    NoShaderBuilder_3Delight_RedDiffuse_GreenAmbient.png
    974 x 765 - 191K
    NoShaderBuilder_OpenGL_RedDiffuse_GreenAmbient.png
    974 x 765 - 113K
    Post edited by ReDave on
  • JonnyRayJonnyRay Posts: 1,744
    edited December 1969

    I realize this thread is over a year old now; so I apologize in advance for the necromancy, however since I’ve been reading / studying shader design lately, I wanted to comment on why one might want to leave the ambient channel just the way it is.

    First, the Renderman engine (and the 3Delight implementation of such) intended the ambient channel to be used as “fill” light when a surface isn’t being lit by light shaders. Before global illumination, the ambient channel was a way to say “Even if nothing shines here, there is still light bouncing around the scene; so it needs something”.

    Because it was intended to be background light, it was designed in most shaders (DAZ’s default shader included) to be overwhelmed by direct light within the scene. Decoupling ambient from diffuse will mean you need to pay close attention to the ambient surface settings or else risk overexposing your surfaces.

    Second, keep in mind that if the content creator has created DAZ Studio specific settings, they have likely tested those settings with the shader in its default configuration. So while decoupling them may help with Poser materials and a more consistent translation of those settings to DS, you may do so at the risk of your DS materials. And since DS is smarter now about seeing DS specific settings even if the files are located in the Poser portion of the content library, you may not be aware of which settings you’re using.

    I think at this point, if I wanted to achieve the special effects like the Poser folks do using the ambient channel, I’d remove all the ambient settings from my existing shader, and use Shader Mixer to blend the ambient information with the standard surface.

  • mjc1016mjc1016 Posts: 15,001
    edited December 1969

    JonnyRay said:
    I think at this point, if I wanted to achieve the special effects like the Poser folks do using the ambient channel, I’d remove all the ambient settings from my existing shader, and use Shader Mixer to blend the ambient information with the standard surface.

    That's why I wanted a 'standard' without the Ambient...heck it could just be a brick in the brickyard. Much more useful for 'rolling your own', if you don't have to 'deconstruct' first.

Sign In or Register to comment.