Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Are rendertextures double-buffered?

Discussion in 'General Graphics' started by FissicsPeep, Jul 17, 2022.

  1. FissicsPeep

    FissicsPeep

    Joined:
    Jan 14, 2014
    Posts:
    65
    Hey all,

    I'm trying to render some values into a RenderTexture... but using a mesh (with values baked into the colours) that moves around with a GameObject. The RenderTexture is not cleared each frame by the camera, so values accumulate. But what I'm seeing is that when my GameObject's mesh moves across the surface of the render texture fast, I get flickering in the rendering. My only explanation is some sort of async/race issue - or more likely, RenderTexture's are double-buffered and as my object mesh moves fast, one buffer renders it in one position, then the next frame, the next buffer renders in a slightly different position.... and then when the RT is rendered, we get flickering as it flips between these two buffers?

    Note: This is a normal RenderT exture asset. Not a Custom Render Texture (CRT). I have tried with a CRT with double-buffer unticked - still flickering.

    Thanks in advance for any info or help.

    Using URP. Unity 2021.2.7f1
     
  2. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Render textures are not double buffered. They are simply single buffers themselves. Custom Render Textures are just a wrapper that provides that kind of functionality.
     
  3. FissicsPeep

    FissicsPeep

    Joined:
    Jan 14, 2014
    Posts:
    65
    Good to know, I will rule that out then. It's very bizarre, perhaps a precision issue... or maybe it's because the rendertexture is subsequently used by the compute shader - maybe the system doesn't take into the account that they're a shared resource and the render must happen before the compute shader.
     
    Last edited: Jul 18, 2022
  4. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Would be best to make a new post about the flickering problem and supply code. Some heads won't usually respond without more info.
     
  5. Pitarcus_mp

    Pitarcus_mp

    Joined:
    Feb 4, 2021
    Posts:
    1
    Hey there, did you fix the flicking? Perhaps the flicking is actually caused because the render texture is not double-buffered indeed. I am looking into it although it's not a crucial matter to me right now!
     
  6. FissicsPeep

    FissicsPeep

    Joined:
    Jan 14, 2014
    Posts:
    65
    I did fix it actually, but now I'm struggling to recall what it was exactly. I know that it wasn't related to the rendertexture being double-buffered or not. If I recall it was something to do with whether the main camera was outputting an opaque texture or not - possibly because of the way the shader was referencing the texture.