[Mesa-dev] [PATCH] torus.c: Lighting effect is distorted when object is scaled up/down

Dongwon Kim dongwon.kim at intel.com
Tue Feb 3 14:48:50 PST 2015

When torus object is scaled up/down via glScalef call the lighting
effect is incorrectly expressed on render target because normals'
length is also changed when vertices are scaled up/down.

This patch enables "automatic normalization" of normals, which
is one of well-known ways to avoid this kind of distortion.



 If scale factors other than 1 are applied to the modelview matrix
 and lighting is enabled, lighting often appears wrong.
 In that case, enable automatic normalization of normals by
 calling glEnable with the argument GL_NORMALIZE.

Signed-off-by: Dongwon Kim <dongwon.kim at intel.com>
 src/egl/opengles1/torus.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/egl/opengles1/torus.c b/src/egl/opengles1/torus.c
index 8f262b5..bb20670 100644
--- a/src/egl/opengles1/torus.c
+++ b/src/egl/opengles1/torus.c
@@ -358,6 +358,10 @@ init(void)
+   /* Enabling automatic normalizing to prevent wrong expression of lighting
+      when torus is scaled down via glScalef */
+   glEnable(GL_NORMALIZE);

More information about the mesa-dev mailing list