Results 1 to 5 of 5

Thread: Having some problem with negative scale values and normals

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2002
    Posts
    13

    Having some problem with negative scale values and normals

    For example. I have an object that is scaled {-1,0,0}. Mirrored on the x axis, basically.

    The gl code would kinda look like:

    glScale(-1,0,0)
    glNormal3fv(x,y,z)
    draw_face()
    glNormal3fv(x,y,z)
    draw_face()
    ...

    (x,y,z) is the computed normal of the untranslated face.

    Of course, this doesn't work because all the normals are still reversed. Does the gl system not apply the current matrix to the glNormal call? Or maybe I just don't know what I'm doing (more likely).

    I'm going to need to handle gluTessNormal stuff too, I'm wondering if it does or does not translate the normals by the current matrix.

    I guess my question boils down to: Should I be calculating the normal based on the translated or untranslated version of the face?

    Thanks for any info!

  2. #2
    Junior Member Newbie
    Join Date
    Jan 2002
    Posts
    13

    Re: Having some problem with negative scale values and normals

    I should add...

    If I reverse the order in which I draw each face. It almost works. I can see the faces normally, but the lighting is reversed. It's dark on the side I'm looking at (which is normally light) and light on the backside.

    Ohwell, off to pound my head some more...

  3. #3
    Senior Member Regular Contributor
    Join Date
    Oct 2001
    Location
    Holland
    Posts
    179

    Re: Having some problem with negative scale values and normals

    Originally posted by Super-K:

    glScale(-1,0,0)
    This should be glScale (-1, 1, 1) !!!!

    HTH

    Jean-Marc

  4. #4
    Member Contributor
    Join Date
    Jul 2001
    Location
    NY
    Posts
    85

    Re: Having some problem with negative scale values and normals

    Here is a quote which might help you some:

    "Any modelview scaling that occurs is likely to mess up OpenGL's lighting equations. Remember, the lighting equations assume that normals have a length of 1.0. The symptom of incorrectly scaled normals is that the lit surfaces appear too dim or too bright depending on whether the normals enlarged or shrunk.

    The simplest way to avoid this pitfall is by calling:

    glEnable(GL_NORMALIZE);"

    I took that from http://www.opengl.org/developers/cod...glpitfall.html

    Hope it helps.
    -lost hope

  5. #5
    Junior Member Newbie
    Join Date
    Jan 2002
    Posts
    13

    Re: Having some problem with negative scale values and normals

    Thanks! That helped.

    I had to go through everything by hand and make sure it was 100% correct. I was reversing the draw order (to invert the normals) but when I was calculating the draw normal I was inverting it again. It would then get inverted by the model matrix (negative scale) before being drawn. Ugh, or something like that, the lighting calculations had backwards normals.

Similar Threads

  1. Texture negative values
    By Azar92 in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 01-27-2014, 06:10 PM
  2. how to scale am matrix non-uniformly/with negative values?
    By Vexator in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 07-25-2006, 02:29 AM
  3. Negative Scale - Maya Export
    By stuartbryson in forum COLLADA
    Replies: 1
    Last Post: 02-07-2005, 08:47 PM
  4. negative Z values
    By Paulo Costa in forum OpenGL: General
    Replies: 1
    Last Post: 08-29-2004, 11:35 PM
  5. Negative values for materials and color...
    By Iceman in forum OpenGL: Advanced Coding
    Replies: 7
    Last Post: 08-13-2002, 06:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean