Created
December 26, 2020 16:11
-
-
Save jadepark-dev/c5dfab1017dcbbb31d7a22e7ccd6bd92 to your computer and use it in GitHub Desktop.
This file contains 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
varying vec3 vPositionW; | |
varying vec3 vNormalW; | |
uniform float u_intensity; | |
void main() { | |
vec3 color = vec3(.58, .74, 1.); | |
float fresnelTerm = dot(vPositionW, vNormalW) * (1. - u_intensity/2.); | |
fresnelTerm = clamp(1.0 - fresnelTerm, 0., 1.); | |
gl_FragColor = vec4( color * fresnelTerm, 1.) * u_intensity; | |
} |
This file contains 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
varying vec3 vPositionW; | |
varying vec3 vNormalW; | |
void main() { | |
mat4 LM = modelMatrix; | |
LM[2][3] = 0.0; | |
LM[3][0] = 0.0; | |
LM[3][1] = 0.0; | |
LM[3][2] = 0.0; | |
vec3 objectNormal = vec3( normal ); | |
vec4 GN = LM * vec4(objectNormal.xyz, 1.0); | |
vPositionW = normalize( cameraPosition - GN.xyz ); | |
vNormalW = normalize( GN.xyz ); | |
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment