I am drawing only back faces of a geometry by invoking gl.cullFace(gl.FRONT). I noticed that the shade of light on these surfaces is opposite to what I expect. For correct rendering, do I have to explicitly reverse the direction of surface normals on back faces, or does the OpenGL subsystem automatically do that?
EDIT: Coming to think of it, if I reverse their normals manually they will become front faces and will be culled.
OpenGL front/back detection is based on winding, not the normal. The normal vector does not have any effect on whether the polygon is considered front or back facing.
I think what you want to do is set the
GL_LIGHT_MODEL_TWO_SIDEoption of glLightModel.Note that this only applies to the fixed pipeline.
===EDIT===
Using custom shaders (GLES2.0 or OpenGL3+), then in the fragment shader you have access to the special boolean
gl_FrontFacing. To emulate two sided lighting in a shader just test forgl_FrontFacingand multiply normal by negative one iffalse.