ComputeScreenPos & Render queue issues

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

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

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: Unity - Manual: Providing vertex data to vertex programs

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 :slight_smile:

4 Likes

Thanks.
It work for me!!

Thanks so much!!

Four years and it’s still quirky…thanks very much!

2021 and this still is the “solution” to make the windows build.
Thank you for finding this and sharing!

2022 and this is still saving people hours of headaches! Thanks!

Thank you! This worked for me