Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: NURBS + Normals = Suicide

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2003
    Location
    Syracuse, NY, USA
    Posts
    3

    NURBS + Normals = Suicide

    Hi all,

    I'm trying to write a program that models an outdoor scene and part of the scene involves an amphitheater that I've rendered using NURBS. Now, I'm trying to use texturing and lighting on the object, but am having trouble calculating the normals for the object. There are several parts to the actual theater, so I'll include just one of the sets of control points here. I'm using a 4th order NURB to get this done.

    My question is, how do I calculate the Normals? Is it just like calculating normals for Linear objects? Any help you can give is appreciated:

    Code :
    float restnear[4][4][3] = { 8.0, -10.0, 0.0,
    							8.0, -5.0, 0.0,
    							8.0, 5.0, -4.0,
    							8.0, 10.0, -6.0,
    							6.0, -10.0, 0.0,
    							6.0, -5.0, 0.0,
    							6.0, 5.0, -4.0,
    							6.0, 10.0, -6.0,
    							2.0, -10.0, 0.0,
    							2.0, -5.0, 0.0,
    							2.0, 5.0, -4.0,
    							2.0, 10.0, -6.0,
    							0.0, -10.0, 0.0,
    							0.0, -5.0, 0.0,
    							0.0, 5.0, -4.0,
    							0.0, 10.0, -6.0 };
     
    float restnearnorm[4][4][3] = { 0.0, 0.0, -1.0,
    								0.0, 0.0, -1.0,
    								0.0, -1.0, -1.0,
    								0.0, -1.0, -1.0,
    								0.0, 0.0, -1.0,
    								0.0, 0.0, -1.0,
    								0.0, -1.0, -1.0,
    								0.0, -1.0, -1.0,
    								0.0, 0.0, -1.0,
    								0.0, 0.0, -1.0,
    								0.0, -1.0, -1.0,
    								0.0, -1.0, -1.0,
    								0.0, 0.0, -1.0,
    								0.0, 0.0, -1.0,
    								0.0, -1.0, -1.0,
    								0.0, -1.0, -1.0 };
     
    gluNurbsSurface(theNurb, 
                       8, knots, 8, knots, 
                       4 * 3, 3, &restnear[0][0][0], 
                       4, 4, GL_MAP2_NORMAL);
    	gluNurbsSurface(theNurb, 
                       8, knots, 8, knots, 
                       4 * 3, 3, &restnear[0][0][0], 
                       4, 4, GL_MAP2_VERTEX_3);
    	gluNurbsSurface(theNurb, 
                       8, knots, 8, knots, 
                       4 * 3, 3, &restnear[0][0][0], 
                       4, 4, GL_MAP2_TEXTURE_COORD_2);
     
    	gluEndSurface(theNurb);

  2. #2
    Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Spain
    Posts
    269

    Re: NURBS + Normals = Suicide

    Try glEnable(GL_AUTO_NORMAL);
    "I don't know... with a casual fly"

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2003
    Location
    Syracuse, NY, USA
    Posts
    3

    Re: NURBS + Normals = Suicide

    I had that enabled already. I just turned up the ambient and diffuse lighting for now. Is that a proper way to do it? Increase the light settings to compensate?

  4. #4
    Junior Member Newbie
    Join Date
    Dec 2003
    Location
    Melbourne,VIC,Australia
    Posts
    23

    Re: NURBS + Normals = Suicide

    I tried to make an algorythm to get automate calculation of GL_MAP2_NORMAL control points for fun, but it made my brain hurt too much, I think you need higher level normal nurbs than the surface in question, but my calculations hypothesis might have been flawed. I didn't use knots because that would have been way tricky. I was able to calculate normals for MAP1 curves, but that was sort of pointless. But.... maybe specifying GL_MAP2_NORMAL's renders quicker than GL_AUTO_NORMAL or at least in the future. I may go back to it and work it out properly one day, it is more fun than chess.

  5. #5
    Intern Newbie
    Join Date
    Oct 2003
    Location
    Oakland, CA, USA
    Posts
    31

    Re: NURBS + Normals = Suicide

    lighting that appears either too light or too dark is often the sign of normals that need normaizing. Try glEnable( GL_NORMALIZE) as a workaround.

  6. #6
    Junior Member Newbie
    Join Date
    Dec 2003
    Location
    Syracuse, NY, USA
    Posts
    3

    Re: NURBS + Normals = Suicide

    Thanks for the reply guys,

    I had normalize enabled already. I just turned the ambient lighting all the way up and it started to blend a little better. That was my biggest issue. The NURBS was part of an object that included flat surfaces as well, so they didn't blend especially well.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •