The First one is my own version of
DrawRenderersCustomPass
, and the second one is the default DrawRenderersCustomPass
. I want to draw the hair with a custom shader that output depth information as color, so that I can sample this texture in other shader like face to get a high quality contact shadow. Everything works fine but the mesh in render texture is disordered. Here is my code for my own DrawRenderersCustomPass
:
protected override void Execute(CustomPassContext ctx)
{
if (!overrideMaterial)
{
Debug.LogError("You need to assign a material to render the hair buffer");
//enabled = false;
return;
}
passindex = overrideMaterial.FindPass(overrideMaterialPassName);
// Create output handle, if needed
if (outputRTHandle == null && outputRT.Length != 0)
{
RenderTexture rtToCopy = ctx.customColorBuffer.Value.rt;
outputRTHandle = RTHandles.Alloc(rtToCopy.width, rtToCopy.height, colorFormat: UnityEngine.Experimental.Rendering.GraphicsFormat.R16G16B16A16_SFloat, filterMode: FilterMode.Bilinear, wrapMode: TextureWrapMode.Clamp, name: $"{outputRT}");
}
CommandBuffer cmd = ctx.cmd;
HDUtils.BlitCameraTexture(cmd, ctx.customColorBuffer.Value, outputRTHandle); //Depth works fine if I comment this out.
base.Execute(ctx);
// Copy custom buffer to our RT
if (null != outputRTHandle)
{
//Set Global Texture using outputRT name
cmd.SetGlobalTexture(outputRT, outputRTHandle);
}
}