Looking to Create a Flashlight "Masking" Effect

Hey guys,

I’m looking to create an effect whereby the player’s flashlight reveals texture elements on surfaces:

^^ Where Mr. Wake reveals the orange phosphorescent paint on the rocks.

I figure this is something that can be made with a cleverly coded shader that’s able to recognize a certain type of light, but I don’t speak shader syntax (yet), I do have an understanding of 3D graphics technology and programming however. Wondering if anyone can point me to a Shader that does this already or some pseudo-code/starting points.

Thanks!

Edit: Thinking a bit more, I suppose if it’s a texture that’s visible when there’s light on it, and invisible when it’s black, I could use layers to achieve the effect. Any shaders that do this?

I’ve sent you a PM.
This can be implemented with a spotlight. Basically you’ll need a shader with 2 passes - one for general lighting (i.e. directional light) and an extra pass for the spotlight that will expose the texture.

Your best bet would be to use a spotlight and have a two-pass shader - one pass for general lighting and an extra pass for the masked texture.
Don’t forget to use “#pragma multi_compile_fwdbase” to make sure that your shader will compile for different light types.

For the second pass it would be something like this (pseudocode):

v2f {

_LightCoord : TEXCOORD{whatever is available};
}

frag (v2f i) : COLOR {
fixed3 outputColor;
#ifdef SPOT //Handle the case when the wall is lit by a spot light i.e. show our mask
fixed attenuation = UnitySpotAttenuate(i._LightCoord);
outputColor = attenuation * tex2D(_MaskTexture, _MaintexUV);
#endif

return outputColor
}

That isn’t the complete code, but you should get the idea.