Hi there
Context:
for testing to render 3D elements into a 2D environment I have 2 cameras placed in the exact same position.
One is rendering into a RenderTexture and the other will display a Quad reading from it.
To make it fit the same position I use the ScreenPosition as my uv for my texture.
Issue:
Everything works fine Except for Shadows.
I tried it in shadergraph and using shader hlsl but with no clue on what is going on in the shadow caster pass.
Test and repro steps:
I did a checker texture with every tile marked to be “human readable” and see how much the uvs are incorrect in the shadows.
The uber simple shader graph:
The check Texture with marked tiles:
Scrambled shadow uvs with shadergraph:
changing position to see that the screenspace uvs are correct for other passes:
Other test using hlsl
For my hlsl version I tried in the fragment shader a simple
inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS);
but it leads to even more scrambled results (in fact uv even changes if I hover the hierarchy randomly)
Uvs with HLSL are also scrambled:
The unlit pass is however correct with the same computation:
Any help on what could be going on would be much appreciated.