oit-unity icon indicating copy to clipboard operation
oit-unity copied to clipboard

Doesn't work on URP

Open Ritbulau opened this issue 7 months ago • 8 comments

I tried use this with URP, and it simply does not work...

public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
        {
            CommandBuffer cmd = CommandBufferPool.Get("Order Independent Transparency");
            var mat = orderIndependentTransparency.Render(cmd, renderingData.cameraData.renderer.cameraColorTargetHandle,
                renderingData.cameraData.renderer.cameraColorTargetHandle);
            if (mat != null)
            {
                Blitter.BlitCameraTexture(cmd, renderingData.cameraData.renderer.cameraColorTargetHandle,
                    renderingData.cameraData.renderer.cameraColorTargetHandle, mat, 0);
            }
            context.ExecuteCommandBuffer(cmd);
            cmd.Clear();
            CommandBufferPool.Release(cmd);
        }

This piece of code creating errors, all they say, that "ScriptableRenderer" does not contain the definition of "cameraColorTargetHandle", and an available extension method "cameraColorTargetHandle" could not be found that accepts the type "ScriptableRenderer" as the first argument (perhaps the using directive or assembly reference was omitted).

I tried everything, even recoding this part myself, but it didn't work out. (Yeah, I know, that I am really bad at coding these things):

        public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
        {

            CommandBuffer cmd = CommandBufferPool.Get("Order Independent Transparency");
            var mat = orderIndependentTransparency.Render(cmd, renderingData.cameraData.renderer.cameraColorTarget,
                renderingData.cameraData.renderer.cameraColorTarget);


            cmd.Blit(renderingData.cameraData.renderer.cameraColorTarget, renderingData.cameraData.renderer.cameraColorTarget, mat, 0);
            
            context.ExecuteCommandBuffer(cmd);
            cmd.Clear();
            CommandBufferPool.Release(cmd);
        }

All my attempts were in vain, and despite strictly following the instructions, I tried to change all possible settings, connect libraries, and so on. Most likely I'm too stupid and I don't see some obvious mistake of mine, but I'll be glad of any help and I'll be happy to provide any additional details, I've spent more than 2 weeks on this!

And sorry for my english, If I wrote something illiterate.

Ritbulau avatar Jun 30 '24 15:06 Ritbulau