Skip to content

Commit

Permalink
Add two-sided rendering to the fragment shader.
Browse files Browse the repository at this point in the history
  • Loading branch information
learnopengles committed May 10, 2012
1 parent 53bad4b commit 50ca1a9
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ void main()

// Calculate the dot product of the light vector and vertex normal. If the normal and light vector are
// pointing in the same direction then it will get max illumination.
float diffuse = max(dot(v_Normal, lightVector), 0.0);
float diffuse;

if (gl_FrontFacing) {
diffuse = max(dot(v_Normal, lightVector), 0.0);
} else {
diffuse = max(dot(-v_Normal, lightVector), 0.0);
}

// Add attenuation.
diffuse = diffuse * (1.0 / (1.0 + (0.10 * distance)));
Expand Down

0 comments on commit 50ca1a9

Please sign in to comment.