Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>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.</p> <p>I think what you want to do is set the <code>GL_LIGHT_MODEL_TWO_SIDE</code> option of <a href="http://www.opengl.org/sdk/docs/man/xhtml/glLightModel.xml" rel="noreferrer">glLightModel</a>. </p> <blockquote> <p>GL_LIGHT_MODEL_TWO_SIDE</p> <p>params is a single integer or floating-point value that specifies whether one- or two-sided lighting calculations are done for polygons. It has no effect on the lighting calculations for points, lines, or bitmaps. If params is 0 (or 0.0), one-sided lighting is specified, and only the front material parameters are used in the lighting equation. Otherwise, two-sided lighting is specified. In this case, vertices of back-facing polygons are lighted using the back material parameters <strong>and have their normals reversed before the lighting equation is evaluated</strong>. Vertices of front-facing polygons are always lighted using the front material parameters, with no change to their normals. The initial value is 0.</p> </blockquote> <p>Note that this only applies to the fixed pipeline. </p> <p>===EDIT===</p> <p>Using custom shaders (GLES2.0 or OpenGL3+), then in the fragment shader you have access to the special boolean <code>gl_FrontFacing</code>. To emulate two sided lighting in a shader just test for <code>gl_FrontFacing</code> and multiply normal by negative one if <code>false</code>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload