[Mesa-dev] [PATCH] torus.c: Lighting effect is distorted when object is scaled up/down
Brian Paul
brianp at vmware.com
Tue Feb 3 15:00:02 PST 2015
On 02/03/2015 03:48 PM, Dongwon Kim wrote:
> 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 <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)
>
> make_texture();
> glEnable(GL_TEXTURE_2D);
> +
> + /* Enabling automatic normalizing to prevent wrong expression of lighting
> + when torus is scaled down via glScalef */
> + glEnable(GL_NORMALIZE);
> }
Reviewed-by: Brian Paul <brianp at vmware.com>
I'll commit this for you.
-Brian
More information about the mesa-dev
mailing list