in traceScreenSpaceRay, i think dQ.z = 0, iterator Q.z += dQ.z is meaningless at all
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...
Why are you saying that k0 = 1/vsOrigin.z? k0 uses H0.w which comes from uvFromViewMatrix * vec4(vsOrigin, 1.0). The value of H0.w depends on what's in uvFromViewMatrix.
Why are you saying that
k0 = 1/vsOrigin.z?k0usesH0.wwhich comes fromuvFromViewMatrix * vec4(vsOrigin, 1.0). The value ofH0.wdepends on what's inuvFromViewMatrix.
yes, uvFromViewMatrix is just a projection composed with uv transform. as we know, after projection, H0.w = -vsOrigin.z