glsl-specular-gaussian
Gaussian specular model for GLSL
Last updated 6 years ago by mikolalysenko .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install glsl-specular-gaussian 
SYNC missed versions from official npm registry.

glsl-specular-gaussian

Computes specular power from a Gaussian microfacet distribution

Example

#pragma glslify: gaussSpec = require(glsl-specular-gaussian)

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 = gaussSpec(lightDirection, viewDirection, normal, shininess);

  gl_FragColor = vec4(power,power,power,1.0);
}

Usage

Install with npm:

npm install glsl-specular-gaussian

Then use with glslify.

API

#pragma glslify: gaussSpec = require(glsl-specular-gaussian)
float gaussSpec(vec3 lightDir, vec3 eyeDir, vec3 normal, float shininess)

Computes the specular power in the Gaussian 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 size of the specular hight light. Smaller values give a sharper spot, while larger values give a more spread out highlight

Returns A float representing the specular power

License

(c) 2014 Mikola Lysenko. MIT License

Current Tags

  • 1.0.0                                ...           latest (6 years ago)

1 Versions

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

Copyright 2014 - 2016 © taobao.org |