Hi everyone,
I currently try to implement a post processing blooming effect. I found an approach, which I try to follow (Link). The approach uses the standard render pipeline. Because I’m working with the URP, I try to find a way how to realize the OnRenderImage function in my SciptableRenderPass.
By help of other threads I came to the mind, I could use the Blit function in the Execute function of my ScriptableRenderPass, which works perfectly fine so far. Because I want to downsample and upsample the camera image, using the interim results, I tried to use mutiple Blits. Unfortunately I had to realize that only the shader of the last Blit execution is used on the camera image. For testing I use simple tinting shaders.
Code
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
{
if (blitRenderMaterial == null)
{
Debug.LogError("Material not created");
return;
}
if (!renderingData.cameraData.postProcessEnabled) return;
CommandBuffer cmd = CommandBufferPool.Get(k_RenderTag);
Render(cmd, ref renderingData);
context.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
}
void Render(CommandBuffer cmd, ref RenderingData renderingData)
{
RenderTargetIdentifier source = currentTarget;
int shaderPass = 0;
RenderTargetHandle tempTexture = new RenderTargetHandle();
tempTexture.Init("My temporary Texture");
RenderTextureDescriptor cameraTextureDesc = renderingData.cameraData.cameraTargetDescriptor;
cameraTextureDesc.depthBufferBits = 0;
cmd.GetTemporaryRT(tempTexture.id, cameraTextureDesc, FilterMode.Bilinear);
cmd.Blit(source, tempTexture.Identifier(), blitRenderMaterial, shaderPass); // Green tinting shader
cmd.Blit(tempTexture.Identifier(), source, blitRenderMaterial2, shaderPass); // Red tinting shader
cmd.ReleaseTemporaryRT(tempTexture.id);
}
Can anyone tell me if my approach to use mutiple blits in a single RenderPass is valid? Is it even possible to execute this function more than 1 time? I also read about the DrawMesh function. Could that be a working alternative? Are there other, better ways how to get access on the interim results? I am new to unity and struggling with this topic for days. I am glad about every answer!