Search Unity

Blur Shader mesh not showing up in game view when camera is set to perspective

Discussion in 'Shaders' started by poopwizard, Jul 31, 2020.

  1. poopwizard

    poopwizard

    Joined:
    Sep 6, 2019
    Posts:
    3
    I've been having trouble the past few days getting my shader mesh to display properly in the game view. For whatever reason, it only shows up in the 2D scene view, or if I switch the camera to orthographic projection. However, I have a lot of background assets that I need to show depth on so a perspective camera is essential. One last detail is that tint effect of the shader can be seen regardless of the camera projection type which.

    I included some screen grabs of the effect cranked all the way to max settings to help illustrate the situations it is, and isn't working in. If anyone knows how to get the effect to display properly please let me know. I've tried everything from adjusting Z values to playing with the render queue and all of the forums I've looked at didn't seem to have the solution I need.

    My knowledge of shaders is still very limited so I grabbed this one off the unity forums.
    Link to the post: https://forum.unity.com/threads/simple-optimized-blur-shader.185327/
     

    Attached Files:

  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    My guess is the blur shader, and by extension the grab pass, is running at the wrong time.

    Try uses the Frame Debugger and checking when the geometry with the blur shader is running. It's probably before the background. Perspective cameras default to using the spherical bounds distance from camera, where as orthographic sprites use pivot depth. You can override how depth is calculated to some extent, but you're probably better off using material queues to force the "background" elements to get rendered before the blur pass rather than hoping the draw order works out in your favor. Also to make sure the blur pass doesn't sometimes render after foreground elements.
     
    poopwizard likes this.
  3. poopwizard

    poopwizard

    Joined:
    Sep 6, 2019
    Posts:
    3
    So I'm using the frame debugger (which thank you for telling me about, its really useful) but the thing thats got me confused is that it looks like everything is being drawn in the correct order, the blur just isnt taking effect when it appears in the list. I've got some more screen grabs, in the second photo the mesh has gone through its three draws but doesn't effect the wall drawn before it. I tried messing with the material queue but that didn't seem to change it, although its entirely possible I didn't do it correctly.
     

    Attached Files:

  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    If try one more thing. Try having the blur shader output a solid color, like red, and see if you can even see it.
     
  5. poopwizard

    poopwizard

    Joined:
    Sep 6, 2019
    Posts:
    3
    I changed it to output white and for whatever reason it shows up just fine.
     

    Attached Files:

  6. Huxii

    Huxii

    Joined:
    Sep 15, 2018
    Posts:
    37
    I have the same problem. May I ask where exactly you changed the output?
     
  7. RemDust

    RemDust

    Joined:
    Aug 28, 2015
    Posts:
    432
    Sorry for digging this old topic but I have the exact same problem, anyone has resolved it ? :D