glsl-specular-blinn-phong
Blinn-Phong specular effect
Last updated 3 years ago by hughsk .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install glsl-specular-blinn-phong 
SYNC missed versions from official npm registry.

glsl-specular-blinn-phong

Computes the Blinn-Phong specular weight for a light source

Example

#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);
}

Usage

Install with npm:

npm install glsl-specular-blinn-phong

Then use with glslify.

API

#pragma glslify: blinnPhong = require(glsl-specular-blinn-phong)
float blinnPhong(vec3 lightDir, vec3 eyeDir, vec3 normal, float shininess)

Computes the specular power in the Blinn-Phong lighting model.

  • lightDir is a unit length vec3 pointing from the surface point toward the light
  • eyeDir is a unit length vec3 pointing from the surface point toward the camera
  • normal is the surface normal at the sample point
  • shininess is the exponent in the Phong equation (default 20.0)

Returns A float representing the power of the Blinn-Phong lighting equation

License

(c) 2014 Mikola Lysenko. MIT License

Current Tags

  • 1.0.2                                ...           latest (3 years ago)

3 Versions

  • 1.0.2                                ...           3 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           6 years ago
Downloads
Today 0
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 2
Dependencies (0)
None
Dev Dependencies (3)
Dependents (2)

Copyright 2014 - 2017 © taobao.org |