I’ve a ray and its path is (o
,d
). Multiply it by the mannequin matrix to rotate the mannequin.
o = uCamera.xyz, d = GenRay();
o = vec3(uModel * vec4(o,1));
d = vec3(uModel * vec4(d,0));
Then beam, RayMarchLeaf(o, d, t, coloration, regular);
the place get the place vec3 t
of the collision of the beam. (in mannequin coordinates).
Then traslate t
to world coordinates :
t = vec3(inverse(uModel) * vec4(t,1)); // map to world pos;
Subsequent want calc t relative to the digital camera, for the following (my) depth take a look at, how can do that?
Tried to multiply by inverse(uView)
but it surely would not work.
Deliberate to do (o-t
) for depth testing.
It is not clear why ‘map to world’ pos works when it is written in every single place that you might want to do that: V-1 * ( V * M ) == M. (https://stackoverflow.com/a/10324884/13369695).