Sometimes getting complex refactive behavior through surfaces can be a tricky challenge. If you’re trying to recreate something like cracks inside of ice it can be a challenge to get this behavior as it can involve a lot of iterations in on the internal geometry and shader adjustments. Often it will also take a long while to render if you’re doing actual refractions. If you need something simpler tough there are ways to do that in the shader directly

I got the initial idea for this from Ben Cloward’s ice shader test in Unreal. It’s a very smart approach in which you get the appearance of the surface texture extending into the volume of the geometry that you are applying the shader to. Given this approach I wrote an OSL shader that does the same thing. I mainly created it for the purpose of shading ice-like internal structures but it can potentially be extended for other use cases as well.


You can supply a texture file into the filename parameter. The texture will be applied to the surface UV’s with periodic tiling. With the default values it creates a duplicate of the supplied texture “inside” the objects that the shader is applied to at the specified depth. The invert_depth parameter will drastically change the look. Depending on the source texture you are using it can give the appearance of occluded cracks vs a “see through” repetition of the surface texture. A roughness parameter is also available which you can use to simulate the texture getting more murky the deeper it goes “into” the object. This is not a physical parameter but just a simple texture blur. If you want a smoother appearance of continuous streaks as the texture goes into the surface you can increase the number of steps. This can simulate continuous from the surface down to the specified depth. Keep in mind that this is the number of texture calls, so having high values here can potentially make it quite slow.
Unfortunately this time it won’t work with Blender as I couldn’t find a proper way to get the derivatives & UV’s to work as expected :( If anyone has the time to look into it please feel free to do so!

As always having a visual demo is probably a good idea, so here it comes:

OSL Fake Parallax Shader from Julius Ihle on Vimeo.


You can download it from HERE.


If this post has helped you in any way you can express your gratefulness by using the Donate Button below to buy me a coffee! :)