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 Shader either does nothing or covers everything up with grey, whats wrong?

Discussion in 'Shader Graph' started by Gizmo_of_Arabia, Aug 4, 2023.

  1. Gizmo_of_Arabia

    Gizmo_of_Arabia

    Joined:
    Mar 15, 2017
    Posts:
    5
    upload_2023-8-4_18-31-13.png

    Above you can see my render pipeline asset + the shader giving off the wrong effect.
    In the full screen pass I am applying the material made with the shader below (i'm just trying to see any change on the screen, like a "hello world" kind of shader).
    upload_2023-8-4_18-32-34.png

    If I change the injection point, it just covers various layers of the game with grey.
    My aim is to have the entire screen changed by the shader, like in this case study:


    Not sure what I'm doing wrong. My URP asset is set correctly in graphics settings, on the camera, it has a renderer. If URP wasn't set up correctly, I believe I wouldn't be getting the grey texture covering the screen at all.

    Would love some help/explanation as to what I'm missing.
     
  2. Gizmo_of_Arabia

    Gizmo_of_Arabia

    Joined:
    Mar 15, 2017
    Posts:
    5
    Ah, forgot to add a screenshot of what the scene looks like without the shader: upload_2023-8-4_18-40-7.png
     
  3. BenCloward

    BenCloward

    Unity Technologies

    Joined:
    Jul 15, 2021
    Posts:
    93
    If this is a URP project, make sure that you check the Opaque Texture option on the Universal Render Pipeline Asset in your project. That will allow your rendered scene to be copied to the screen texture - which is what the Scene Color node uses.
     
  4. Gizmo_of_Arabia

    Gizmo_of_Arabia

    Joined:
    Mar 15, 2017
    Posts:
    5
    TY very much for your interest, that checkbox was indeed unchecked, although it didn't solve the problem, is there something I need to do to "reload" the scene or something like that?
    For future reference, my pipeline asset below: upload_2023-8-4_19-32-9.png
     
  5. BenCloward

    BenCloward

    Unity Technologies

    Joined:
    Jul 15, 2021
    Posts:
    93
    In order to begin debugging this, I recommend that you simplify your Shader Graph shader. Try only plugging the Scene Color node into the Base Color port of the Master Stack and disconnect everything else. If that shader is working correctly, you should just get standard rendering and it should appear as though nothing has changed. Once you get to that point, then you can begin to offset the UVs to introduce the distortion.
     
  6. Gizmo_of_Arabia

    Gizmo_of_Arabia

    Joined:
    Mar 15, 2017
    Posts:
    5
    I see I made a little mistake now, your previous suggestion to check that "opaque texture" box did alter something after all -- the shader now covers everything with the camera's background color rather than simple gray: upload_2023-8-4_20-1-8.png

    Per your suggestion, I believe this shader should be sufficient to test things out, because it'll show 4 airplanes, right? (Just plugging the base color into scene color has the same effect, just checked.)
    upload_2023-8-4_20-2-42.png
     

    Attached Files:

  7. BenCloward

    BenCloward

    Unity Technologies

    Joined:
    Jul 15, 2021
    Posts:
    93
    Yes, the above shader should tile the screen 4 times. Is that what you're seeing, or are you getting something different? If you're getting the screen tiled 4 times, you've got the right result and you should be able to proceed with creating a more complex shader.
     
  8. Gizmo_of_Arabia

    Gizmo_of_Arabia

    Joined:
    Mar 15, 2017
    Posts:
    5
    Nope, I'm just getting the solid camera bg color all over the screen. I should be seeing the F-16 fighter you see in one of the screenshots above copied 4 times.

    -- I recorded a quick video of what's happening, when I set the injection point to earlier, the shader stops covering it and simply appears to do nothing at all. When the injection point is later, the shader just covers everything with green. No tiling in sight.