[ad_1]
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;
okay, we’ve a 3d digicam coordinate and some extent. For Depth worth, we are able to use size(uCamera.xyz - t), however this isn’t correct. My digicam is shifting and rotating in 3d house.
How to correct calculate depth worth to retailer in texture?
[ad_2]