- Home /
What's the best way to read a texture in camera space in a vertex shader?
Hi, I'm currently trying to write a shader which will distort the scene in front of it using a vertex function and an image. (With the default particle texture for example this shader might cause vertices in the middle of the camera to buldge). I'm struggling to get the texture to be a constant size on the screen even with (as far as I can tell) correct transformations for screenposition. Could someone give me a second pair of eyes on this?
//screenspace effect
float4 clipSpace = UnityObjectToClipPos(v.vertex);
float4 screenSpace = ComputeScreenPos(clipSpace);
float4 deformTex = tex2Dlod(_ScreenspaceDeformTex, float4((((screenSpace.xy) / screenSpace.z) / _ScreenParams.yx), 0, 0)).r;
I've written fragment shader functions using VPOS which are very accurate but haven't found an analog in the vertex shader world to help solve this problem.
Comment