http://www.lighthouse3d.com/opengl/glsl/index.php?ogldir2 показывает следующее:
H = Eye - L
Я сделал следующее на своем вершинном шейдере WebGL для вычисления половиныvector:
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