Hi, I’m building a post process that takes in an input image and another texture that I need to sample. Now the input image sampling is alright (1 to 1 with the grayscale post-process example in HDRP scripting docs), but I can’t figure out how am I supposed to sample a normal texture.
This is what I’ve got so far:
Shader:
TEXTURE2D_X(_InputTexture);
TEXTURE2D_X(_WorldMask);
......
float4 maskTexture = SAMPLE_TEXTURE2D_X(_WorldMask, s_linear_clamp_sampler, uv);
Post Process:
public BoolParameter UseDebug = new BoolParameter(false);
public TextureParameter DebugTexture = new TextureParameter(null);
public override void Render(CommandBuffer cmd, HDCamera hdCamera, RTHandle source, RTHandle destination)
{
var cam = hdCamera.camera;
var material = GetMaterial();
material.SetTexture(_MaskProperty, GetMask());
material.SetTexture(_InputTextureProperty, source);
HDUtils.DrawFullScreen(cmd, material, destination);
}
private Texture GetMask()
{
#if UNITY_EDITOR
return UseDebug.value ? DebugTexture.value : WorldMask;
#else
return WorldMask;
#endif
}
When I render the image it is just gray-ish, regardless of what texture I put in. Does it have something to do with that RTHandle type?
There aren’t many resources on HDRP shader scripting I could find.