Skip to main content
deleted 215 characters in body; edited title
Source Link

Transforming the beam3d point for depth testing

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?

Transforming the beam point for depth testing

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 camera, for the subsequent (my) depth test, how can do this? Tried to multiply by inverse(uView) but it doesn't work.

Planned to do length(o-t) for depth testing.


It's not clear why 'map to world' pos works when it's written everywhere that you need to do this: V-1 * ( V * M ) == M. (https://stackoverflow.com/a/10324884/13369695).

Transforming 3d point for depth testing

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;

ok, we have a 3d camera coordinate and a point. For Depth value, we can use length(uCamera.xyz - t), but this is not accurate. My camera is moving and rotating in 3d space.
How to accurate calculate depth value to store in texture?

added 6 characters in body
Source Link

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 camera, for the subsequent (my) depth test, how can do this? Tried to multiply by inverse(uView) but it doesn't work.

Planned to do (length(o-t)) for depth testing.


It's not clear why 'map to world' pos works when it's written everywhere that you need to do this: V-1 * ( V * M ) == M. (https://stackoverflow.com/a/10324884/13369695).

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 camera, for the subsequent (my) depth test, how can do this? Tried to multiply by inverse(uView) but it doesn't work.

Planned to do (o-t) for depth testing.


It's not clear why 'map to world' pos works when it's written everywhere that you need to do this: V-1 * ( V * M ) == M. (https://stackoverflow.com/a/10324884/13369695).

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 camera, for the subsequent (my) depth test, how can do this? Tried to multiply by inverse(uView) but it doesn't work.

Planned to do length(o-t) for depth testing.


It's not clear why 'map to world' pos works when it's written everywhere that you need to do this: V-1 * ( V * M ) == M. (https://stackoverflow.com/a/10324884/13369695).

Source Link

Transforming the beam point for depth testing

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 camera, for the subsequent (my) depth test, how can do this? Tried to multiply by inverse(uView) but it doesn't work.

Planned to do (o-t) for depth testing.


It's not clear why 'map to world' pos works when it's written everywhere that you need to do this: V-1 * ( V * M ) == M. (https://stackoverflow.com/a/10324884/13369695).