I’m working on a Depth Peeling system that tries to not use Replacement shaders. So I setup multiple render targets but because the diffuse is going to be blended I’m trying to write out the depth in the first pass but output it to a specific target and then in the second pass output to the other target. The problem is that when I look at my second render target( destination for diffuse ) it seems to have blended with the depth texture. Is it possible to setup MRT and have one pass output to one target and the second pass output to a second target??
Tried this:
…
half4Depth_Frag( _v2fi ) : COLOR0 {
#ifDEPTH_PEEL_ENABLED
floatprevDepth = DecodeFloatRGBA(tex2Dproj(_DepthTex, UNITY_PROJ_COORD(i.screenPos)));
//needslightbias
if( i.depth <= (prevDepth + 0.000001) ) {
discard;
}
#endif
returnEncodeFloatRGBA( i.depth );
}
…
Then in the second pass( which has alpha blending setup )
…
half4Color_Frag( _v2fi ) : COLOR1 {
#ifDEPTH_PEEL_ENABLED
floatprevDepth = DecodeFloatRGBA(tex2Dproj(_DepthTex, UNITY_PROJ_COORD(i.screenPos)));
//needslightbias
if( i.depth <= (prevDepth + 0.000001) ) {
discard;
}
#endif
half4texColor = tex2D( _MainTex, i.uv.xy );
returnhalf4( texColor.rgb, _Color.a );
}
…
The first pass seems to work but when I look at the output of the second pass it seems to have blended with the depth. As if I was outputting to the same render target for both passes.
In my original implementation I had it all in one pass but it occurred to me that I would be blending the depth also which is why I am trying to use two passes.
Just curious if anyone can show what I am doing wrong.
Any help would be great. Thank you
1768866–112128–Bumped-Glossy-ZTestGreater.shader (2.74 KB)
1768866–112130–DepthPeelStateManager.cs (4.3 KB)
1768866–112131–DepthPeelObjectShaderManager.cs (1.21 KB)