Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

How to efficiently blur a planar reflection sampler2d texture in shader?

Discussion in 'Shaders' started by protopop, May 17, 2020.

  1. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,351
    i am learning how to write shaders and am not too experienced.

    I use real-time reflection probes for my water and it gives shimmer free reflections that blur nicely when I lower the reflection probe resolution.

    But real-time reflection probes are expensive and don’t reflect everything. So I am testing a planar reflection water shader. The Planar reflections use less cpu and reflect everything.

    the planar reflection is injected into my shader as a sampler2d texture. But no matter what resolution I capture the reflection in, I get a shimmering, point filtered look to the reflection that I don’t see with the reflection probes. The reflection probe cube map almost seems to come with some sort of temporal anti aliasing built in or something that makes for a nice blurred and stable reflection.

    I would like to know how I can resize the planar reflection in my shader? I am thinking it would be an efficient way to blur the reflection if I shrink it in the shader code. (I can resize the size of the planar reflection texture before I inject it into the shader, but it doesn’t blur and keeps the point filtered shadow maker look. ) Or can I somehow apply bilinear filtering to the reflection texture sampler2d in the shader?

    Here is an example of the problem. I am switching between the real-time reflection probe water and the planar reflection water. You can see specially in the distance how the planar reflection texture is too sharp, point filtered and noisy.

    Can anyone help me?

     
    IrrSoft likes this.
  2. IrrSoft

    IrrSoft

    Joined:
    Jul 6, 2012
    Posts:
    1,132
    Hi there,

    We are working on a smaller update that will add more settings to the way the reflections are generated internally (allowing you to set up bilinear filtering, mip maps generation and other options to the internal reflection texture) but you can also assign a manually created RenderTexture asset to the reflection renderer component and set up these parameters in your manually created RenderTexture. Hopefully this would stop the shimmering :)

    The update will be available next week (around Friday) but in the meantime we believe using an external RenderTexture asset may help.

    Another update (which has become quite necessary) to allow for high quality blurring of the reflection on any shader through the Planar Reflections Caster component is also on the way, but it may still take a little longer to be ready for public use (we are currently testing it internally on URP and HDRP) and we do not think it will be available before mid June.

    We wish we had seen your post sooner instead of almost a week later when browsing the forums, but we hope that this still provides some help. Have a great day!
     
    protopop likes this.
  3. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,351
    Please take ke your time:) as you know, and for anyone reading this, I love your PIDI planar shader. It's better to do it right than to rush things. As it is now the water looks wonderful- the blurring would be an extra bonus option for an artistic look.
     
    IrrSoft likes this.
unityunity