Is there a special way to get “world space” in a customized version of the URP/2D/Sprite-Lit-Default shader?
I’m converting a shader I made that wasn’t lit (just a basic vert/frag shader) over to a “lit” version by starting with the URP/2D/Sprite-Lit-Default shader and just adding/changing things as needed. Everything seems to be working fine except that my world-space position doesn’t seem correct.
This is how I got world space in my original shader (in the vertex function):
OUT.worldPos = mul(unity_ObjectToWorld, IN.vertex);
And this is what I have in the new customized 2D/sprite-lit-default one:
o.worldPos = mul(unity_ObjectToWorld, v.positionOS);
The result with the new shader is almost as though the world position is ‘moving along with the camera’. Recorded a video explaining whats going on. The issue is at the 1:00 mark.
89xtop
My fragment code is exactly the same for both. I’m 99.9% the issue I’m seeing is due to this world position calculation. Maybe something is different with the 2D Renderer ? Or “v.positionOS” isn’t the same thing as what would be “IN.vertex” (from vertex functions that take appdata_t)?
@castor76 I saw you mention in another thread that you are also doing reflections, did you happen to run into this same issue?
Thanks for any help!!