Skip to content

Instantly share code, notes, and snippets.

@lazd
Created November 26, 2014 02:11
Show Gist options
  • Select an option

  • Save lazd/24511f0abace1a0630c1 to your computer and use it in GitHub Desktop.

Select an option

Save lazd/24511f0abace1a0630c1 to your computer and use it in GitHub Desktop.
shader
uniform vec3 glowColor;
uniform float coeficient;
uniform float cutoff;
uniform float power;
varying vec3 vVertexNormal;
varying vec3 vVertexWorldPosition;
void main(){
vec3 worldCameraToVertex = vVertexWorldPosition - cameraPosition;
vec3 viewCameraToVertex = (viewMatrix * vec4(worldCameraToVertex, 0.0)).xyz;
viewCameraToVertex = normalize(viewCameraToVertex);
float cosTheta = dot(vVertexNormal, viewCameraToVertex);
float intensity = pow(coeficient + cosTheta, power);
// Attempt to stop drawing of the shader when looking up
if (cosTheta > cutoff) {
intensity = 0.0;
}
gl_FragColor= vec4(glowColor, intensity);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment