A while ago I decided to try modeling some Translucency Shaders in Unity.

Translucency in general is fairly complicated to simulate real-time. When you are dealing with objects that are not entirely opaque you’re presented with:

* Refraction
* Chromatic Aberration due to refraction.
* Transparency blur due to light scattering
* Beer’s Law
* Direct Light vs IBL/Probes.
* View-based lighting.

When you’re modelling a simple but realistic system that scatters the light, a lot of properties come as just properties from the brute-force you’re applying. Since we’re dealing with real-time shaders, things get a lot more complicated as we need to either address these properties independently (but find a way to link them in order to preserve energy conservation) or figure out an algorithm that deals with them.

When dealing with translucency, most articles I find seem to either be focused on liquids or skin, with not a lot of in-between. Skin is very complex in itself and an optimized skin shader can probably be hacked into other objects, but there’s not much middle ground. How to deal with jelly and food, for example?

I think at the end of the day there’s not a lot of practical use for these objects that cannot be realistically simplified in some way like light wrapping and what not, but I still find interesting to ponder about more complex systems.

The first problem I’ve seen is that transparent objects that show some degree of light scattering will not show the background perfectly. Even water will not do that. It’s not hard to solve that problem – we can use Command Buffers to blur the background. However that only solves the problem for a specific distance – while we can Lerp the results as the depth-difference approaches zero (so that objects near the surface look clearer), very distant objects still should get scattered to oblivion and we can’t do infinite blur passes – maybe there’s a way to play with MIP Maps the same way we do with PBR probes?

Second, and this is something I genuinely don’t know – At which point for some objects should we just apply Beer’s Law to deal with the color and not bother with a diffuse map?

Beers-Law_Geleia

This seems to be an issue with jellies as they have a lot of color variation. Since the surface color is an accumulation of rays coming from multiple layers, it seems unrealistic to use albedo maps for objects that show any significant degree of translucency at all.

Third – How do you fit direct lighting into all of this? We’re balancing depth, energy conservation, object density, and light scattering into account. There doesn’t seem to be a magic trick to solve it and it’s all highly dependent on what you’re doing with direct lighting in the first place, especially if you’re including view-dependent effects. In which case keeping everything energy-conserving is a whole new can of worms.

Playing with Translucency – Part I

Leave a Reply

Your email address will not be published. Required fields are marked *