Skip to content

Instantly share code, notes, and snippets.

@jadepark-dev
Created December 26, 2020 16:11
Show Gist options
  • Save jadepark-dev/c5dfab1017dcbbb31d7a22e7ccd6bd92 to your computer and use it in GitHub Desktop.
Save jadepark-dev/c5dfab1017dcbbb31d7a22e7ccd6bd92 to your computer and use it in GitHub Desktop.
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;
}
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