hello everyone, i want to write a simple scriptabale render pipeline ; and i want to do some post processing before render the final image , so what i did is write this code to render first into a rendertexture and then blit the texture to screen ; this is my code
protected override void Render(ScriptableRenderContext _ctx, Camera[ ] _cams)
{
foreach (var c in _cams)
{
FunTest(_ctx, c);
}
_ctx.Submit();
}
void FunTest(ScriptableRenderContext _ctx, Camera _c)
{
var cmd = new CommandBuffer();
rt = new RenderTexture(_c.pixelWidth, _c.pixelHeight, 0, RenderTextureFormat.Default);
rt.Create();
cmd.SetRenderTarget(rt);
cmd.ClearRenderTarget(true, true, Color.red);
DrawRenderers(_ctx, _c);
_ctx.ExecuteCommandBuffer(cmd);
cmd.Release();
cmd = new CommandBuffer();
cmd.Blit(rt, BuiltinRenderTextureType.CameraTarget);
_ctx.ExecuteCommandBuffer(cmd);
cmd.Release();
rt.Release();
}
void DrawRenderers(ScriptableRenderContext _ctx, Camera _c)
{
_c.TryGetCullingParameters(out var _cluPar);
var culRes = _ctx.Cull(ref _cluPar);
_ctx.SetupCameraProperties(_c);
var sh = new ShaderTagId(“MyTag”);
var renderSet = new DrawingSettings(sh, new SortingSettings(c));
var filter = new FilteringSettings(RenderQueueRange.opaque) { layerMask = c.cullingMask };
_ctx.DrawRenderers(culRes, ref renderSet, ref filter);
}
when i render directly to screen code work perfect , the problem happen when i want use an render texture
it seems to me that the texture have the red color only and not my renderers
what is the problem ?