Is there a way to make the effect of camera clear flags on render texture in URP Unity

I’m making a fog of war effect and I want to use the camera no clear flags method that used to be available to paint the trail of vision for many units. The ability to do the clear flags method seems to have faded and there seems to be little documentation on other options.

What can I do to recreate this method of painting textures in Unity now? The no clear flags option seemed like it was almost for free, as it just didn’t clear the previous frame before rendering a new one. Now it seems I would have to make a system of painting pixels, which would be quite taxing for multiple objects each frame.

Alternatively I’ve looked at doing vertex painting systems, but again, for hundreds of objects at once, that would be terribly inefficient.

I have the feeling that I could do some magic with making some render features in URP to do it, I would have to learn that side of Unity some more. I also have the feeling that a shader could manage it too. But I’m not sure if I should somehow multiply the latest frame with the first frame perpetually? I don’t know how I would access the latest frame from a render texture, while keeping an original to multiply it with.

I’ve tried Uninitialized background type on my render texture camera, but it renders a white background. I’ve tested rendering other objects and it doesn’t seem to do what the no clear flags method did anyway.

  • 1

    Pretty sure the don't clear flag is still a thing, tho I’m not sure how helpful that would be to a fog of war system. Personally I’d use a stencil shader on an invisible vision range sphere that surrounds your units and only shows enemy materials if they are underneath.

    – 

  • The don’t clear flag is not in URP cameras anymore, they say you can use the Uninitialized background option instead, but it doesn’t work. It still clears the colour buffer. I’ve already got a stencil shader working for unit vision, but I also want another fog layer that hides undiscovered areas in black. I’ve got that working just like the stencil shader, but I can’t find a way to keep the areas which have been discovered in the texture.

    – 

Leave a Comment