Search Unity

How to correct blurry UI? Or duplicate the camera? also clean render texture.

Discussion in 'Image Effects' started by resetme, Mar 1, 2017.

  1. resetme

    resetme

    Joined:
    Jun 27, 2012
    Posts:
    204
    Hello unity masters,

    I'm working on an UI project and I want to copy my ui, blurry it and put it behind the same Ui.
    I setup a camera that only render the canvas Ui, screen space camera if I'm not wrong.

    Right now is working but I'm pretty sure I'm doing it wrong.
    In my code I create a render texture, then in my Update code I save the camera render in targettexture in low resolution (fake blurry), after that I null the target texture, if I don't do this part my ui don't render at all.

    After I got my render texture in low res I just put it inside a raw texture in my canvas with an add shader and upscale.

    It's feel really wrong to do this on update... there is no other way to render the camera inside a texture and keep the camera rendering on screen? I saw something about temporarytexture but I didn't find any code example.

    Also, my render texture never clear, so every time I press play my texture rewrite the older one giving some ghost effect, liking adding images together.

    I'm very lost, Appreciate any help!
     
  2. resetme

    resetme

    Joined:
    Jun 27, 2012
    Posts:
    204
    So i did it.

    This was the technique;
    1 Camera to the BG - render in texture
    1 Camera to the UI - render in texture
    1 Camera that do blit, taking the texture from BG and UI and render to screen.

    In the shader i take the BG and attach the UI (blurried) to it, using lerp.
    from the (BG+ UI blurry ) lerp i do another lerp with the UI not blurry.

    After that i add the Post proccess stack.
    It works well and the colors are mostly the same.

    I still want to find a way to Layer those texture in the shader, going to make another post for that. The lerp solution works but is not perfect. maybe using a second pass?