Module: Demos Branch: master Commit: a56afc865e95bfc5e9748d015f344ad58aafdc22 URL: http://cgit.freedesktop.org/mesa/demos/commit/?id=a56afc865e95bfc5e9748d015f344ad58aafdc22
Author: Dongwon Kim <[email protected]> Date: Tue Feb 3 15:48:00 2015 -0700 torus.c: Lighting effect is distorted when object is scaled up/down 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. Reference: www.opengl.org/sdk/docs/man2/xhtml/glScale.xml Notes 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 <[email protected]> Reviewed-by: Brian Paul <[email protected]> --- src/egl/opengles1/torus.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/egl/opengles1/torus.c b/src/egl/opengles1/torus.c index 8f262b5..ccf53d1 100644 --- a/src/egl/opengles1/torus.c +++ b/src/egl/opengles1/torus.c @@ -358,6 +358,11 @@ init(void) make_texture(); glEnable(GL_TEXTURE_2D); + + /* Enable automatic normalizing to get proper lighting when torus is + * scaled down via glScalef + */ + glEnable(GL_NORMALIZE); } _______________________________________________ mesa-commit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/mesa-commit
