Fake Sub-Surface Scattering

From ThirdPartyWiki
Jump to: navigation, search

Contents

Introduction

Sss fake sss cells01.jpg

So you'd like to know how to create a good and relatively quick Sub-Surface Scattering shader in C4D... but and this is important, without having to use the godawful AR SSS by CEBAS or the somewhat limited Chanlum shader. Can't be done? Absolutely it can, with only the most basic tools!

And here's how (note all images have been rendered using Linear Workflow here with DeGamma, to match you will either need to use a linear workflow or at the very least use the Color Correction post effect to set your Gamma to around 2.2).

Background

A little background information : SSS is when it comes down to it a form of global illumination within a volume. A very basic way to produce global illumination is called the "Monte Carlo" method, where we just shoot lots and lots of rays out in lots of directions, the QMC (Quasi Monte Carlo) method is just this with a little bit of intelligence about where the rays go, each ray is used to calculate an intersection point on the surrounding geometry and then sample the color of that surface, you then integrate (add up all the samples together and divide by the total to get the average color) the result and thus you get the amount of global illumination for the current point.

With SSS the rays get scattered a bit more and their strength is under the influence of Beers Law, which means that within a medium that scatters light the amount of light to actually come through drops off by an order of magnitude over distance from the light source, i.e. it gets darker the thicker the object.

There's also some other stuff about the light being bounced around in all directions and even coming back towards the surface that it originated from, known as back-scattering but we don't need to think about that yet, it's the previous two nuggets that make for the core of this little hack and by which we can create a passable forward scattering only SSS effect fairly cheaply.

How

Sss stage 0.jpg

The Premise

So the premise is actually remarkable simple. Based on these bits of information, we know something inside of C4D that does those two things already... the transparency channel!

After all we already know that we can fake GI itself by using the reflection channel, so lets see where this takes us.

They key transparency settings

The transparency channel has the first in the form of the "Blurriness" options, which cast rays into the interior and then average the result, and the second in the form of Absorption, which gives us Beers law. All we have to do is set the blurriness itself to 100% and then the absorption color to black and a distance over which it will become totally dark.

Sss stage 1.jpg


Inside scattering out, not outside scattering in

So we're just missing one component, the fact that we want to sample the light or surface color rather than what's outside of the volume, after all just turning on those two options just makes a transparent blurry object, not SSS at all, because the rays go to the opposite sides of the object and then carry on through out beyond. So how do we solve this with the inbuilt tools? We basically need to reverse the faces to make it so that the transparency channel is sampling what's on the outside... impossible... or maybe not...

Stop Rays from Exiting

Normal Direction shader

Fortunately there are in fact shaders inbuilt to Cinema 4D that we can use to solve this twofold problem, first to stop the rays from exiting the volume we can use the Normal Direction shader in the Transparency Channel, this will color the inside black and the outside white, where transparency is black it's no longer transparent, where it's white it's fully transparent, so now the rays cannot exit the volume, but we just turned everything transparent black!

Sss stage 2.jpg


Bring Light in

Next for the effect of bringing the light in.

The use of the Backlight Shader

There are two depending on what modules you have. The first is in the Sketch & Toon module and is called the Cel shader. The second is inbuilt and is called the Backlight Shader, as this one is available to more people this is the one we'll use for our experiments.

To make it work we just place it into the slot in the Luminance channel of a basic Cinema 4D material, and then to make sure it transmits all of the light through just edit the values so that “Illumination” is 100% and obviously we want shadows to be cast correctly so we set that Shadow Intensity value up to 100% too. Now the light that gets cast onto the front of the material also shows up on the back, which is exactly what we want so all those rays cast in the transparency channel can sample the luminosity of the surface.

Sss stage 3.jpg


Surface

Additive Transparency Option

We now have a sort of SSS effect in place but there's a problem, we *only* have the SSS effect in place. To solve this we need to visit the Transparency channel, un there you will find a control called "Additive" when this is enabled it stops the Transparency from overwriting the other material channels, it allows the Color channel to start working again, which is what we need if we want the BRDF part (the immediate reflection of diffused light) to work, otherwise it's going to always have a semi-transparent rather than translucent material. So simply check the Additive box and the surface should re-appear.

Sss stage 4.jpg


Back Tracking a little

Add the Layer and Normal Direction shader

If we now render we should be beginning to get a result that's promising, but it's not there yet, there's two vital but small things to fix yet. The first is that the Backlight Shader is working on the outside of the material too, so we're getting brighter edges and so on for the outside of the object, this is no good to us, the solution is once again the Normals Direction shader. To use it all we need to do is in the luminance channel add a “Layers” shader, the Backlight shader will be automatically dropped into it, then if we go into the Layer Shader and add in a Normal Direction shader above the Backlight Shader.

Invert the Normal Channel (and set it's blending mode to "Mutliply"

Next to make it so that it only blocks off or masks the Backlight Shader rather than replaces it we can just set it's blending mode to Multiply. Unfortunately though it's masking the wrong side, to solve this either Right Mouse Button Click on the Normal Shader and choose “Invert Image” from the pop-up menu, or edit the colors in the Normal Shader so that they're the other way around (Color 1 becomes black and Color 2 becomes white), now it's only stopping the Backlight shader from working on the outside of our mesh and the result should be much more pleasant.

Sss stage 5.jpg


Shadows

The Shadow Settings you must use for this material

The next problem is that we're still getting internal bounced light from our Lights on the opposite side of the mesh, the reason is actually very simple. It's that the lights shadows (if you have any) are probably set to use transparency! This means that as the material is (currently) 100% transparent but with a falloff the light gets to go right through the object, it's not casting any shadows on itself! The solution is to go into the lights shadow tab and disable the “Transparent” setting for the shadow.

Sss stage 6.jpg


Fine Tuning

Now you're ready to go and the light distribution effect should be looking fairly good.

Color

Setting Mix Mode to Multiply

To allow a good degree of control over the effect you should set the blending for the texture slots in the transparency and luminance channels to multiply. Now you can once again use the Color controls to adjust the overall effect.

Sss fake coloured.jpg


Textures

Most materials thought that you'll deal with wont in fact be flat colors though, so we should now examine how to apply textures and what the effect should be as a result.

A texture in the Color Channel

Lets start out with a basic texture, immediately two problems show up, firstly the texture doesn't even show up on the sides where the light itself doesn't directly fall (or there's no GI to show it up) and secondly the SSS remains unaffected by the texture at all, it's just still plain old white all the way through.

Sss stage 7 surfacing textureproblem.jpg


Solving these two problems is in fact quite simple to do.

Shadow Texture Visibility
Texture in the Transparency Channel

Firstly to fix the issue of the texture not being visible on the back face all we need to do is apply it to the transparency. To do this we add a Layer Shader to the Transparency channel Texture Slot, this moves the Normal Direction shader that's already there directly into the Layer Shader, and then in the Layer Shader we "Paste" the Texture we have in the Color Channel directly into the Layer Shader and set it's mode to "Multiply" so that it will overlay the Texture on the SSS effect coming from the Transparency Channel.

Sss stage 7 surfacing transonly.jpg


Texture effect on SSS
Texture in the Luminance Channel

Secondly to solve the issue of the lack of any effect from the Texture on the SSS itself we need to do the same in the Luminance Channel, that is in the Layer Shader that's already in there we paste in the texture from the Color Channels texture slot and set it's mode to Multiply. Now the Transparency/SSS Will be sampling the surface colored by this texture which will result in a much more believable effect.

Sss stage 7 surfacing luminanceonly.jpg

When we do both these things the final result is much better looking, far closer to what we would have been expecting all along from an SSS Shader.

Sss stage 7 surfacing combined.jpg

Conclusion

This method can be quite effective, especially when used in conjunction with AR Global Illumination, which can help improve and create some of the effect of localized "back" scattering when set at higher depths.

As you can see here, this scene is lit only by the GI from this block

Sss woody about to melt.jpg

Here is a version for you to examine and test for C4D R11.

File:Textured Fake SSS.zip

Enjoy and have fun with this hack.

Personal tools