Ok I think that's quite enough theory for the moment. Time to do something! Here was our last render:
Oh please...stop inspiring me you wondrous looking object.....*COUGH*. Let's go for something a bit more interesting! First up, let's change the colour from pasty-tan-brown to red!:
And rendering the scene gives us?
Well, pasty-red. We'll fix the pastiness in a second. You might be wondering why I chose to change the 'Front SSS Color' rather than the 'Diffuse Color'? It's because I really just want to concentrate on the SSS effect rather than the boring old lambert shading of the outer surface.
Now we get:
Which is much redder. Oh, I'm not going for something realistic here by the way, just something to show off the dramatic effects you can get. What if we now want some back scattering effects in a different color? Let's try that.
No effect!? Maybe it needs more weighting?
It must be a conspiracy against the colour blue! No, not really. In order to get any back scattering effects, you need a light shining on the back of the object! Makes sense right?
That's better! Now we've got back scattering in the mix too. If you're back scattering is way too strong, you could either move your new light further away, or turn down the 'Back SSS Weight' a bit. I also unlinked the light (just using Maya's 'Lighting/Shading > Break Light Links') from the floor to remedy a hotspot that appeared. The SSS is starting to get a little grainy though don't you think?
At this point, I think it's about time I finished up this tutorial and left you to your own devices! Playing with values and putting maps in different places is as good a way to experiment and learn as any from here on. There are just a few more things I'll mention first though. Here's an example of rendering this object with Final Gathing, and having the 'Include Indirect Lighting' option off/on on the Misss_fast_lmap_maya node:
As you can see it makes a fairly big difference! I won't go into the Final Gather settings because those with Maya 6.5 can download the scene now (sorry 6.0 people but I don't have 6 anymore and it won't translate backwards properly). Another thing I said I'd talk more about is reasons to save out the lightmap to the harddrive. This again is related to indirect lighting. It's not hugely important, but if you save the map to your hard drive and then render again with the 'Writable' option on the mentalrayTexture node turned off (so that it just reads straight from the saved file without writing it again) you'll get much stronger indirect lighting effects on the surrounding objects:
It seems to be due to the order in which things are calculated at rendertime. The Final Gather prepass comes before the SSS effect is calculated, so most of the SSS colours are left out of the indirect lighting on other objects. If you have saved the lightmap though (by rendering it with 'Writable' turned on and a filename supplied) and then render with 'Writable' turned off, Final Gather can already see the object in it's finished SSSy state, as if it were just a textured object.
Hmm what else is there...oh! What about if you wanted to create the effect of something being 'inside' the SSS object, like bones inside a gelatin hand? All you need to do is create the objects that go inside, and apply the same SSS material to them. It treats them as 'blocking' objects that block the light:
In that render you can see that there is a sphere contained in the left cube, and a cone (though harder to see) in the right cube. All four objects share the same shader and are almost entirely weighted towards the back scatter colour.
Some extra info -
Hopefully I've convinced you that this is quite a versatile and useful shader. Are there any limitations though? Well, there's at least one. This shader is calculated in a way that makes it view dependant. Normally that shouldn't be a problem, however look what happens if I add a mirror behind my crazy test object:
Well amazingly it held up quite well, but as you can see in my poorly illustrated example, some areas displayed in the reflection didn't need to have the SSS calculated for them in order to get a nice result from the camera view. So they look wrong when seen from the back in the mirror. Another downside to view dependence is that you can't bake the shader into a texture map without these artifacts appearing either.
I'm sure some of you might be thinking, "isn't the fact that it takes 20 million steps to setup one shader a downside!?". Well, it does become second nature to setup all the lightmappy business after a few goes, but luckily there's an even better solution! Now that I've shown you how to do it yourself manually, I can point you to this script:
createAndAssignShader.zip
If you put that in your user scripts folder, it'll take priority over the default way that Maya assigns this shader. So when you assign it via the right-click menu in the viewport this script will cause all the lightmap nodes and connections to be made automatically!
And, well, that's about it guys! If you'd like to ask questions about this shader, you can post a in the forum below. So have fun! Bye!!
Oh please...stop inspiring me you wondrous looking object.....*COUGH*. Let's go for something a bit more interesting! First up, let's change the colour from pasty-tan-brown to red!:
- Change the 'Front SSS Color' to red!
And rendering the scene gives us?
Well, pasty-red. We'll fix the pastiness in a second. You might be wondering why I chose to change the 'Front SSS Color' rather than the 'Diffuse Color'? It's because I really just want to concentrate on the SSS effect rather than the boring old lambert shading of the outer surface.
- To fix the pastiness, we can turn up the 'Front SSS Weight' to something like 1.
Now we get:
Which is much redder. Oh, I'm not going for something realistic here by the way, just something to show off the dramatic effects you can get. What if we now want some back scattering effects in a different color? Let's try that.
- Change the 'Back SSS Color' to blue.
No effect!? Maybe it needs more weighting?
- Change the 'Back SSS Weight' to 3.
It must be a conspiracy against the colour blue! No, not really. In order to get any back scattering effects, you need a light shining on the back of the object! Makes sense right?
- Stick a point light in behind one side of your object.
That's better! Now we've got back scattering in the mix too. If you're back scattering is way too strong, you could either move your new light further away, or turn down the 'Back SSS Weight' a bit. I also unlinked the light (just using Maya's 'Lighting/Shading > Break Light Links') from the floor to remedy a hotspot that appeared. The SSS is starting to get a little grainy though don't you think?
- Turn up the 'Sampling' to 256. That should be plenty.
At this point, I think it's about time I finished up this tutorial and left you to your own devices! Playing with values and putting maps in different places is as good a way to experiment and learn as any from here on. There are just a few more things I'll mention first though. Here's an example of rendering this object with Final Gathing, and having the 'Include Indirect Lighting' option off/on on the Misss_fast_lmap_maya node:
As you can see it makes a fairly big difference! I won't go into the Final Gather settings because those with Maya 6.5 can download the scene now (sorry 6.0 people but I don't have 6 anymore and it won't translate backwards properly). Another thing I said I'd talk more about is reasons to save out the lightmap to the harddrive. This again is related to indirect lighting. It's not hugely important, but if you save the map to your hard drive and then render again with the 'Writable' option on the mentalrayTexture node turned off (so that it just reads straight from the saved file without writing it again) you'll get much stronger indirect lighting effects on the surrounding objects:
It seems to be due to the order in which things are calculated at rendertime. The Final Gather prepass comes before the SSS effect is calculated, so most of the SSS colours are left out of the indirect lighting on other objects. If you have saved the lightmap though (by rendering it with 'Writable' turned on and a filename supplied) and then render with 'Writable' turned off, Final Gather can already see the object in it's finished SSSy state, as if it were just a textured object.
Hmm what else is there...oh! What about if you wanted to create the effect of something being 'inside' the SSS object, like bones inside a gelatin hand? All you need to do is create the objects that go inside, and apply the same SSS material to them. It treats them as 'blocking' objects that block the light:
In that render you can see that there is a sphere contained in the left cube, and a cone (though harder to see) in the right cube. All four objects share the same shader and are almost entirely weighted towards the back scatter colour.
Some extra info -
Hopefully I've convinced you that this is quite a versatile and useful shader. Are there any limitations though? Well, there's at least one. This shader is calculated in a way that makes it view dependant. Normally that shouldn't be a problem, however look what happens if I add a mirror behind my crazy test object:
Well amazingly it held up quite well, but as you can see in my poorly illustrated example, some areas displayed in the reflection didn't need to have the SSS calculated for them in order to get a nice result from the camera view. So they look wrong when seen from the back in the mirror. Another downside to view dependence is that you can't bake the shader into a texture map without these artifacts appearing either.
I'm sure some of you might be thinking, "isn't the fact that it takes 20 million steps to setup one shader a downside!?". Well, it does become second nature to setup all the lightmappy business after a few goes, but luckily there's an even better solution! Now that I've shown you how to do it yourself manually, I can point you to this script:
createAndAssignShader.zip
If you put that in your user scripts folder, it'll take priority over the default way that Maya assigns this shader. So when you assign it via the right-click menu in the viewport this script will cause all the lightmap nodes and connections to be made automatically!
And, well, that's about it guys! If you'd like to ask questions about this shader, you can post a in the forum below. So have fun! Bye!!
Author: Jozvex
Submitted: 2005-08-26 00:56:43 UTC
Tags:
Software: Maya
Views: 296,988
Related Items
-
Dome of the Rock 3D Model
$25.00 (USD) -
The Elder Wand 3D Model
$25.00 (USD) -
The Resurrection Stone 3D Model
$20.00 (USD) -
The Metaphone Model 3D Model
$29.00 (USD) -
Gary the snail 3D Model
$50.00 (USD) -
Swiper the Fox 3D Model
$70.00 (USD) -
New Swiper the Fox 3D Model
$80.00 (USD) -
The FleX Rig for Maya 2.1.0
$20.00 (USD) -
The Shanghai Tower Day Time 3D Model
$79.00 (USD)