Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in traceScreenSpaceRay, i think dQ.z = 0, iterator Q.z += dQ.z is meaningless at all #8436

Open
yejun81 opened this issue Feb 11, 2025 · 0 comments

Comments

@yejun81
Copy link

yejun81 commented Feb 11, 2025

in shaders/src/surface_light_reflection.fs, line 60, function traceScreenSpaceRay

// Project into screen space
highp vec4 H0 = mulMat4x4Float3(uvFromViewMatrix, vsOrigin);
highp vec4 H1 = mulMat4x4Float3(uvFromViewMatrix, vsEndPoint);

// There are a lot of divisions by w that can be turned into multiplications at some minor
// precision loss...and we need to interpolate these 1/w values anyway.
//
// Because the caller was required to clip to the near plane, this homogeneous division
// (projecting from 4D to 2D) is guaranteed to succeed.
highp float k0 = 1.0 / H0.w;
highp float k1 = 1.0 / H1.w;

// Switch the original points to values that interpolate linearly in 2D
highp vec3 Q0 = vsOrigin * k0;
highp vec3 Q1 = vsEndPoint * k1;

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

here, k0 = -1/vsOrigin.z, and Q0.z = -1, and Q1.z = -1 too.

// Track the derivatives of Q and k
highp vec3 dQ = (Q1 - Q0) * invdx;
highp float dk = (k1 - k0) * invdx;

so dQ.z = 0 too.

so line 150, in for loop iterator, what does Q.z += dQ.z do?

btw, github.com's reference in a new issues can't work now...

@yejun81 yejun81 changed the title i think dQ.z = 0, iterator Q.z += dQ.z is meaningless at all in traceScreenSpaceRay, i think dQ.z = 0, iterator Q.z += dQ.z is meaningless at all Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant