Normal Map
Normal map is suitable for rendering scenarios with fixed light sources and diffuse reflection. The Unit-method vectors NX, NY, and NZ in their eye coordinates serve as their texture coordinates S, R, and T.
Reflection Map
Similar to sphere map, it is very suitable for Environment ing. The implementation method is to use the Unit Reflection vector as its texture coordinates S, R, and T.
The reflection vector can be obtained through the incident vector and the normal vector: r = u-2 * transpose (n) * (U dot n ). You can call the reflect function in glsl.
Vec3 reflectionmap (in vec3 ecposition3, in vec3 normal) <br/>{< br/> float ndotu, M; <br/> vec3 U; <br/> U = normalize (ecposition3); <br/> return (reflect (u, normal); <br/>}
Sphere Map
Only S and T are generated for spherical environment textures.
(1) the X and Y components of the reflection vector are projected onto the Unit Circle of the Rz = 0 plane.
Scale the X component RX and Y component ry of the reflection vector according to the specific reflection vector length m, where M = 2 * SQRT (RX * RX + Ry * ry + (RZ + 1) (RZ + 1 )). RX and ry divided by m, the two components are projected to a unit circle on the Rz = 0 plane.
(2) obtain the two texture coordinates in the range of [0, 1.
After scaling, multiply RX and ry in the unit circle by 0.5 and offset 0.5 to get the S and T coordinates in the range of [0, 1.
Vec2 spheremap (in vec3 ecposition3, in vec3 normal) <br/>{< br/> float m; <br/> vec3 R, U; <br/> U = normalize (ecposition3); // U is a unit vector (Eye coordinate) pointing from the origin point to the vertex. <br/> r = reflect (u, normal ); // R is the reflection vector (Eye coordinate) <br/> M = 2.0 * SQRT (R. x * r. X + R. y * r. Y + (R. Z + 1.0) * (R. Z + 1.0); <br/> return vec2 (R. x/m + 0.5, R. y/m + 0.5); <br/>}