- Home /
Shader Replacement for DepthNormals with custom HLSL Clipping
I'm trying to use the Standarad Assets Edge Detection filter on a scene which includes objects that have custom clipping planes (via the HLSL clip() instruction in a surface shader.)
When rendering in deferred mode, this works fine, as the edge detection works against the gbuffer laid down by my generated surface shader, or some variant of it, and as a result the edges are only detected against the parts of the object that are visible.
When in forward rendering mode, it looks like the depth/normals are being laid down by a shader that does not include my clip() instructions, presumably because shader replacement is finding an internal depth/normals shader (presumably there in the builtin shaders download), and rendering using that.
Is there a way that I can provide my own clipping shader, and set up the tags (in a different pass of the shader?) so that forward pass depth-normals shader replacement will find my clipped shader?
If you're using a surface shader, from memory adding "addshadow" to the surface declaration fixed this problem, as it regenerates the shadow/depth pass based on the surface shader. They might have changed this though.
Hmm, I thought that worked, but it looks like I hadn't switched my camera rendering mode back to forward.
Answer by ferretnt · Apr 19, 2017 at 12:35 AM
Namey5's version works for rendering depth only. For Depth+Normals, you can write your own version of depthnormals shader that handles your clipping and assigning it in GraphicsSettings.
Your answer
Follow this Question
Related Questions
iOS shader scale issue 2 Answers
Creating a Masking Object with Variable Pass Through 0 Answers
Cutting hole in water plane using stencil buffer.Help making it visible from both sides. 0 Answers
Why CYAN is default object color (with default materials & shaders) 0 Answers
How to not have custom node variables be global across all material instances 0 Answers