view vector ortho projection fix
This commit is contained in:
@@ -543,8 +543,12 @@ float4 main(PixelInput input, in bool is_frontface : SV_IsFrontFace) : SV_Target
|
||||
#endif // OBJECTSHADER_USE_AO
|
||||
|
||||
#ifdef OBJECTSHADER_USE_POSITION3D
|
||||
float2 clipspace = uv_to_clipspace(ScreenCoord);
|
||||
float4 unprojectedNEAR = mul(GetCamera().inverse_view_projection, float4(clipspace, 1, 1));
|
||||
unprojectedNEAR.xyz /= unprojectedNEAR.w;
|
||||
|
||||
surface.P = input.pos3D;
|
||||
surface.V = GetCamera().position - surface.P;
|
||||
surface.V = unprojectedNEAR.xyz - surface.P; // instead of camera.position - surface.P, unprojectedNEAR is used because it will also work correctly for orthographic projection!
|
||||
float dist = length(surface.V);
|
||||
surface.V /= dist;
|
||||
#endif // OBJECTSHADER_USE_POSITION3D
|
||||
|
||||
Reference in New Issue
Block a user