September 2018
Intermediate to advanced
472 pages
15h 36m
English
To implement a shader pair that uses the Phong reflection model with two-sided lighting, take the following steps:
// Uniforms and attributes...out vec3 FrontColor;out vec3 BackColor;vec3 phongModel( vec3 position, vec3 n ) {
// The Phong model calculations go here...
}
void main() { vec3 tnorm = normalize( NormalMatrix * VertexNormal); vec3 camCoords = (ModelViewMatrix * vec4(VertexPosition,1.0)).xyz; FrontColor = phongModel( camCoords, tnorm ...Read now
Unlock full access