http://www.lighthouse3d.com/opengl/glsl/index.php?ogldir2は、次のことを示しています。
H=目-L
ハーフベクトルを計算するために、WebGL頂点シェーダーで次のことを行いました。
vec4 ecPosition = u_mvMatrix * vec4(a_position.xyz, 1.0); // Get the eye coordinate position
vec3 eyeDirection = normalize(-ecPosition.xyz); // Get the eye direction
v_halfVector = normalize(eyeDirection + lightDirection); // Compute and normalize the half-vector
しかし、上記のコードスニペットが正しいかどうかはわかりません。
任意のポインタ/ヘルプをいただければ幸いです。よろしくお願いします。
編集:正しいコードは
vec4 ecPosition = u_mvMatrix * vec4(a_position.xyz, 1.0); // Position in the eye coordinate position
vec3 ecLightPosition = (u_mvMatrix * lightPosition).xyz; // Light position in the eye coordinate
vec3 lightDirection = ecLightPosition - ecPosition.xyz // Light direction
vec3 eyeDirection = (-ecPosition.xyz); // Eye direction
v_halfVector = normalize(eyeDirection + lightDirection); // Compute and normalize the half-vector