I have a ray and its direction is (o,d). Multiply it by the model matrix to rotate the model.
o = uCamera.xyz, d = GenRay();
o = vec3(uModel * vec4(o,1));
d = vec3(uModel * vec4(d,0));
Then beam, RayMarchLeaf(o, d, t, color, normal); where get the position vec3 t of the collision of the beam. (in model coordinates).
Then traslate t to world coordinates :
t = vec3(inverse(uModel) * vec4(t,1)); // map to world pos;
Next need calc t relative to the cameraok, for the subsequent (my) depth testwe have a 3d camera coordinate and a point. For Depth value, howwe can do this?
Tried to multiply by inverse(uView) but it doesn't work.
Planned to douse length(ouCamera.xyz - t) for depth testing.
It's not clear why 'map to world' pos works when it's written everywhere that you need to do, but this: V-1 * ( V * M ) == M is not accurate. (https://stackoverflow.com/a/10324884/13369695)My camera is moving and rotating in 3d space.
How to accurate calculate depth value to store in texture?