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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

ComputeScreenPos & Render queue issues

Discussion in 'Shaders' started by benjam901, Feb 3, 2017.

  1. benjam901

    benjam901

    Joined:
    Dec 29, 2016
    Posts:
    4
    Hello all,

    I am finishing up my water shader and am trying to get shadows on top of it. I found out if the render queue is set to transparent then it will not recieve shadows, so I set it to:
    Tags { "RenderType" = "Transparent" "Queue" = "Geometry+1"}

    Problem is the shader throws an error about ComputeScreenPos:
    Out.scrPos = ComputeScreenPos(Out.position);
    invalid subscript 'pos' 'ComputeScreenPos': no matching 1 parameter function at line 224

    Line 224 holds the Transfer shadow function:
    TRANSFER_VERTEX_TO_FRAGMENT(Out);

    When the Queue is set to transparent it all seems to work (without shadows of course) Am I missing something with the render queue and compute screen pos?

    If you need more information like code snippets please do not hesitate to ask

    - Ben
     
  2. benjam901

    benjam901

    Joined:
    Dec 29, 2016
    Posts:
    4
    Oh I am also using grab pass to gain refraction under the surface of the shader, will the change of queue from "Transparent" to "Geometry+1" be the reason affecting this?

    - Ben
     
  3. benjam901

    benjam901

    Joined:
    Dec 29, 2016
    Posts:
    4
    Ok so I found out why my code was throwing errors.

    It turns out when you use TRANSFER_VERTEX_TO_FRAGMENT to create shadows if you have a custom struct and your semantics are not named exactly as they are here: https://docs.unity3d.com/Manual/SL-VertexProgramInputs.html

    i.e. vertex instead of position and your outputting vertex position must be named pos the function throws an error. Seems a bit odd but Unity is full of quirky things :)
     
    Lynxed and Zyblade like this.
  4. info10133

    info10133

    Joined:
    Oct 26, 2014
    Posts:
    1
    Thanks.
    It work for me!!
     
  5. AtsukiIkeda

    AtsukiIkeda

    Joined:
    Apr 17, 2020
    Posts:
    1
    Thanks so much!!
     
  6. chenwanwan13

    chenwanwan13

    Joined:
    Apr 28, 2019
    Posts:
    2
    Four years and it's still quirky...thanks very much!
     
  7. Lynxed

    Lynxed

    Joined:
    Dec 9, 2012
    Posts:
    121
    2021 and this still is the "solution" to make the windows build.
    Thank you for finding this and sharing!
     
  8. JosBGN

    JosBGN

    Joined:
    Dec 3, 2020
    Posts:
    4
    2022 and this is still saving people hours of headaches! Thanks!
     
  9. TLien

    TLien

    Joined:
    Mar 21, 2019
    Posts:
    1
    Thank you! This worked for me