in 2019.3 you can now add custom post-processing shaders. I’m trying to render to two outputs in the shader.
However, unlike what I’ve read in various posts, I can’t change the return type of the CustomPostProcess(Varyings input) function to be a struct instead of a float4.
It fails to compile with:
cannot convert from ‘struct Targets’ to ‘float4’ at line 164 (on metal)
The Targets struct looks like this:
struct Targets
{
float4 target0 : SV_Target0;
float4 target1 : SV_Target1;
};
My postprocessor class looks like this:
public override void Setup()
{
if (Shader.Find(“Hidden/Shader/Test”) != null)
material = new Material(Shader.Find(“Hidden/Shader/Test”));
textures = new RTHandle[ ] { RTHandles.Alloc(new Vector2(1, 1), 1, DepthBits.Depth8), RTHandles.Alloc(new Vector2(1, 1), 1, DepthBits.Depth8) };
textureIds = new RenderTargetIdentifier[ ] { textures[0].nameID, textures[1].nameID };
}
public override void Render(CommandBuffer cmd, HDCamera camera, RTHandle source, RTHandle destination)
{
if (material == null)
return;
// setting the uniforms here
material.SetTexture(“_InputTexture”, source);
HDUtils.DrawFullScreen(cmd, material, textureIds, textures[0]);
}