This is a `playground`

to test code. It runs a full `Node.js`

environment and already has all of `npm`

’s 400,000 packages pre-installed, including `glsl-specular-blinn-phong`

with all `npm`

packages installed. **Try it out**:

**glsl-specular-blinn-phong** lists no main file and has no index.js, so it can't be directly required. If this is a mistake, please let us know. It may however contain internal files that you can require manually:

// require("glsl-specular-blinn-phong/[??]")

- all documents on RunKit are public
`require()`

any package directly from npm- use arrow functions, classes, template strings, and most of ES6
`await`

any promise instead of using callbacks (example)- create your own embedded
**node.js**snippets

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

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)
```

`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

(c) 2014 Mikola Lysenko. MIT License

- package on npmhttps://npmjs.com/package/glsl-specular-blinn-phong
- homepagehttps://github.com/stackgl/glsl-specular-blinn-phong
- licenseMIT

RunKit is a free, in-browser JavaScript dev environment for prototyping **Node.js** code, with every **npm** package installed. Sign up to share your code.

Sign Up for Free