Replaced Shaders during the "PrePassBase" phase.

Hey everyone,

OK so a new thread for my PrePassDecal issues…

Is it possible to create a replaced shader that will execute during the “PrePassBase” phase of the rendering queue?? The reason I ask is for my decals normal maps to look correct I need the surface normals of the underlying geometry. Otherwise, when my decal is applied to the surface, its normals are simply calculated as if they were on the flat surface of the decals bounding cube. This causes results as shown below.


This is what the decal looks like on curved surfaces as it is essentially getting only one underlying surface normal from when the decal is oriented from its placement. So lighting is still being calculated as if on a plane.


It of course looks correct when on a flat surface though.

So what I want to accomplish is to use replacement shaders to render out an image of the scenes surface normals and pass that in to my PrePassDecal shader and use those normals to blend in with the decals normals and so this all has to be done in the the “PrePassBase” phase. It would be awesome if I could use _CameraDepthNormals but of course sadly this is not accessible at this point in the rendering phase.

Any words of wisdom? :slight_smile:

Perhaps this vid will help you

I dont think its exactly the type of blending you are after but it might help you choose a method.
I haven’t looked into what space unity stores its deferred normal buffer info but at a guess you could try ignoring the Z equivalent and doing a similar blend.

OK so I managed to get this issue resolved. I guess this was sort of a preemptive post because with a little bit of experimenting and playing around I managed to initialize a second camera and work it in to the rest of the decal framework to render the scenes surface normals prior to the Decal pre pass.

There is however a small issue I am still trying to deal with with this replaced shader, but I am going to discuss that in a new thread. In short, the replaced shader is not rendering the scenes objects in the correct order, as if it is ignoring the ZWrite test entirely.

The new thread is here:
http://forum.unity3d.com/threads/119953-Replaced-Shader-not-Rendering-Objects-in-Correct-Depth-Order?p=804449#post804449