Cut Mesh Shader

General / 29 April 2019

At my work I saw that we have events where a character walks into objects which blocks the camera. Our level designers were just modeling out blockouts with only one side modeled to see inside these areas. I had previously seen many tutorials on how to do cut shaders so you can cut into one mesh with a plane or object.

Many of these tutorials involves multiple passes on the shader (one for standard lighting outside and one for unlit inside). I wanted to keep the first pass of this shader simple so I found some info that allowed me to do just that by utilizing the VFACE float that is built into the Struct input of  Unity's shader code. This gives a 1 for faces looking towards the camera and -1 for ones looking away (kind of like a built in dot product for facing polygons). If you halve the info it gives you, you can use it for a linear-interpolation where 1 is your standard albedo, emission and 0 is your emission / albedo color.


The next step in this shader is to experiment with a past experiment of making a realtime render texture and then using that to power the emission areas of a particle system so I can "burn" into an object.