kode80 / kode80SSR

An open source screen space reflections implementation for Unity3D 5.
BSD 2-Clause "Simplified" License
382 stars 92 forks source link

Clip to Screen space #16

Open ManishJu opened 7 years ago

ManishJu commented 7 years ago

Hello! I had some doubt about your conversion from clip space to screen space in the code present in the shader file: kode80SSR/Assets/Resources/Shaders/SSR.shader. From line 136 - 146:

 // Project into homogeneous clip space
                float4 H0 = mul( _CameraProjectionMatrix, float4( rayOrigin, 1.0));
                float4 H1 = mul( _CameraProjectionMatrix, float4( rayEnd, 1.0));

                float k0 = 1.0 / H0.w, k1 = 1.0 / H1.w;

                // The interpolated homogeneous version of the camera-space points  
                float3 Q0 = rayOrigin * k0, Q1 = rayEnd * k1;

                // Screen-space endpoints
                float2 P0 = H0.xy * k0, P1 = H1.xy * k1;

The final result that has been commented as screen space end points. Isn't that Normalized Device Coordinates or NDC ?