Created
November 26, 2014 02:11
-
-
Save lazd/24511f0abace1a0630c1 to your computer and use it in GitHub Desktop.
shader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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