Computes the Blinn-Phong specular weight for a light source
#pragma glslify: blinnPhongSpec = require(glsl-specular-blinn-phong)
uniform vec3 eyePosition;
uniform vec3 lightPosition;
uniform float shininess;
varying vec3 surfacePosition;
varying vec3 surfaceNormal;
void main() {
vec3 eyeDirection = normalize(eyePosition - surfacePosition);
vec3 lightDirection = normalize(lightPosition - surfacePosition);
vec3 normal = normalize(surfaceNormal);
float power = blinnPhongSpec(lightDirection, eyeDirection, normal, shininess);
gl_FragColor = vec4(power,power,power,1.0);
}Install with npm:
npm install glsl-specular-blinn-phong
Then use with glslify.
#pragma glslify: blinnPhong = require(glsl-specular-blinn-phong)Computes the specular power in the Blinn-Phong lighting model.
lightDiris a unit lengthvec3pointing from the surface point toward the lighteyeDiris a unit lengthvec3pointing from the surface point toward the cameranormalis the surface normal at the sample pointshininessis the exponent in the Phong equation (default20.0)
Returns A float representing the power of the Blinn-Phong lighting equation
(c) 2014 Mikola Lysenko. MIT License