Shader mixer, applied crash course pt.1

AoA Subsurface is a popular shader for DS+3Delight. It has a problem, though: it’s a shader mixer network, and shader mixer is hardwired to output completely unwanted visibility attributes when there is an “image” brick attached to surface opacity anywhere up the line, even when there is no image there, only colour.

Those attributes tell 3Delight to run the whole shader when calculating raytraced shadows and diffuse light transport like ambient occlusion or indirect lighting – yes, even when your object is completely solid!!

This can slow your renders down. Exact amount varies, but still, why put up with those extra calculations?

We can fix it by tinkering with the spaghetti in the shader mixer.

IMPORTANT: unfortunately this is not a one-off fix that will automatically carry over to all the AoA presets you have – because every shader mixer preset actually has the whole network saved in it and not just parameter values. So you will need to remember to fix every preset you may use. Fortunately, it’s fairly easy once you get the gist of it.

Here is how to do it.

1. In the DS “Window – Panes (tabs)” menu turn Shader Mixer on and go to its tab.  To make sure you’ll see the whole shader mixer interface without parts being hidden, make shader mixer pane undockable and expand it:

1_undockable

Go to the shader mixer “Edit-Preferences” menu and in the pop-up dialog, make sure you have the same settings as I do in the screenshot below, so that you could follow my directions.

1a_prefs

Switch back to the main DS window.

2. In the viewport, apply the AoA preset you want to fix to a primitive. Select the surface in the surfaces tab.

3. In the shader mixer window, import the selected material from scene:

2_import
4. You’ll see the spaghetti soup, from a low Earth orbit apparently. Hold down CTRL and use the mouse wheel to zoom in. Still holding CTRL, use the left mouse button to drag the spaghetti view around until you see the “surface” brick in the left top corner, as here:

3_surface

5. But in your shader mixer, there is a line connecting the opacity colour input (the C letter). It’s a bad thing. You should right-click that C letter and select “DISCONNECT”.

6. If you don’t want to make any further modifications, then we can start saving this new preset. Go to the “Edit – Shader name” menu and in the pop-up window, type something like “AoA_Subsurface_FixA” (to be able to tell right away if it’s the original AoA SSS or your modified one) and accept the renaming. Then press the green “Apply” button on the bottom right (if you haven’t done the first part of step 1, you may have trouble locating it…).

When you switch back to the main DS window, you should see the surface tab updated with the new shader name.

7. With the surface still selected, make sure you have the primitive selected in the scene tab as well. Go to the “File – Save as” menu and save out a new shader preset.

8. Now you can either close shader mixer and proceed to whatever you wanted to do, or you can go on and add refraction to the shader so as to get more cool effects from it.

9. Let’s add the “reflect and refract” brick first: in the brickyard, find it (see screenshot) and double-click it. It will appear in the spaghetti on the right.

9_refref

Move the brick around to where you will see it well.

10. Now, the “Binary operation” math brick for adding the refraction in:

10_add

Double-click it to have it appear in the editor. In its “type” dropdown, select “colour”. The “operation” should remain “add” for now. Move it into a handy place.

11. Right-click the C input letter of the “colour” channel in the “surface” brick and disconnect it. With the left mouse button, draw a line from that C input to the C output of the Binary math brick. Similarly connect the Binary’s first “value” input to the “IfElse(60)” output, and the “value 2” input to the “refraction colour” output of the “reflect and refract” brick. You should get something like this:

11_Final.png

12. Now repeat step 6 renaming the shader to something like “AoA_Subsurface_FixB”, and step 7 making a new preset.

What you can do now that you have a “reflect and refract” section in the surface tab:

  • an example SSS preset for something like translucent plastic – you don’t need to copy all the scatter/absorb values manually! They will get filled automagically once you select “Marble” in the dropdown!

fix_sss

  • combined with this refraction preset for hollow tinted surfaces –

reflectrefract

  • will give you a slightly translucent cone like this:

sss_refra

Or, with a few changes, the following render – it is subtle in this particular example, but the refraction is now blurred:

sss_frostedrefract.png

The changes are only setting Subsurface Strength to 50%, refraction strength to 1 (100%) and refraction sample cone to 0.01.

Sample cone controls the “frosted glass” effect. To decrease noise when increasing sample cone, you should increase samples.

…actually you could also replace the “oldschool” specular with a physically based specular model (with Fresnel attenuation), but let’s save it for later =)

Advertisements

10 thoughts on “Shader mixer, applied crash course pt.1

      1. It was definitely just the grass being affected; the rock looked fine. I loaded up the rock and rendered it; the displacement isn’t as strong as the example you posted in the link at my blog. Displacement was more standard: 100% strength, 2.0 and -2.0 for the values.

        But it could be as you said, that two displacements next to each other caused the problem.

          1. Yes. I used Souless Empathy’s older Versatile Terrain set, which I’ve done in the past with the AoA grass shader and had no trouble. It’s bumpy, so the terrain looks a little more interesting. :)

            I have added subd to that prop in the past — there was an issue at one point with AO lights causing weird little black triangles on the surface when rendered, which was fixed by applying subd — but I didn’t do so for the princess vs the dragon render.

            I have to set this aside for tonight, though. I have to make cookies for the husband’s birthday, as he’s coming back from a fishing trip tomorrow morning, and I also have to make a batch of bread and butter pickles. We’re at that stage of gardening where it’s “aaahhh! what do I do with all this stuff?!”

            1. So most likely it happened because of the two displacement bounds weirdly interacting. I just don’t see anything else that could go wrong =)

              Ooh, pickle making, awesome! I’m trying to grow basic potted flowers, but they don’t like me =) Maybe they arrive already sick. They come from countries like Holland, packaged in that weird soil, and they tend to either dry out or rot, even though I’m technically doing everything right. I think I should stop buying plants and start growing them from seeds. So as to be in control over what soil there is in the pot.
              The kohlerias I grow from stems that fall off my grandmother’s plants, they are doing much better than the ones bought in the store. So this is why I suspect the soil.

              1. Yup, I’ll just have to remember this the next time I use the AoA grass shader.

                We’ve had pretty good luck growing flowers as well as vegetables and fruits from seeds, though we do buy seedlings from a local nursery for some plants. Sometimes they are sickly and don’t grow well. We had problems with tomatoes this year. We also tried a new soil and that also made a difference — the vegetables and bee-friendly flowers didn’t do nearly as well this year as they did last year. The sunflowers in particular were stunted.

                Go on and try growing from seeds. It takes longer, but it should be worth it in the long run.

                  1. We bought them as seedlings and they never did well. All four failed to thrive, though one plant did pretty well. They produced tomatoes, but nothing like we’ve had in the past. The husband thinks we just got some sickly plants.

                    The cherry tomato however is a beast. The only real problem with that one is that if there is too much rain, the little tomatoes split and you have to get rid of them due to bugs, bacteria, etc. Very annoying, as we had nearly a solid week of rain recently. Lots got pitched — if the bunnies and turkeys strolling through our yard like tomatoes, they’ll have a feast. :)

                    1. Oh, how unfortunate =((

                      So they split when there’s too much water, interesting… I sometimes see split cherry tomatoes among those sold in stores, but they never look bruised so I was wondering why it happens. Now that you’ve told me about it, it makes sense.
                      Turkeys, like wild turkeys or your own?

Comment here

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s