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: Vertice Normal

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2004
    Posts
    2

    Vertice Normal

    Hey,

    I have the face normals for a series of triangles which compose a triangle mesh in a terrain program I have written.
    Since I am passing the triangle’s face normal once for each of its three vertices the triangles stand out when light is placed upon it.

    I tried this method of smoothing the lighting effect.
    I found all the triangles sharing a particular vertex and calculated the average between the face normals and assigned that value to the vertex’s normal. I repeated that process for all the vertices. The result was that the lighting was too smooth and practically no detail can be seen.

    I wanted to know if there is a better method of producing smoother lighting with out having individual triangles ‘standing out’ or having all details disappear.

  2. #2
    Junior Member Regular Contributor
    Join Date
    Sep 2003
    Location
    Ireland
    Posts
    137

    Re: Vertice Normal

    A few suggestions...

    Are you using OpenGL's lighting? - you may be able to change the type of lighting equation used, but I'm not sure on that one.

    Otherwise, you'll need to use your own lighting, and control the brightness through the colour you're passing in for each vertex - this may require that you change your texturing from, for examle, DECAL to MODULATE

  3. #3
    Junior Member Regular Contributor
    Join Date
    Sep 2003
    Location
    Ireland
    Posts
    137

    Re: Vertice Normal

    Or, again in the context of DIY, you could use a fragment program. if your card supports them...

  4. #4
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,264

    Re: Vertice Normal

    The lighting equation is not at issue.
    He just needs to tweak the normals a bit to get something you like.

    I'm assuming he is averaging face normal. Instead of simple averaging, you can use blending weights.

    example :
    vertex_normal = face_normal_1 *50% + face_normal_2 *25% + face_normal_3 *25%;

    so 50%, 25%, 25% are the blending weights.

    This is just an example when a vertex has 3 faces sharing it.
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  5. #5
    Advanced Member Frequent Contributor plasmonster's Avatar
    Join Date
    Mar 2004
    Posts
    739

    Re: Vertice Normal

    If you can use a cube map for the diffuse light, for example, you can turn this problem on its head. Instead of varying the normals, vary the light in the cube map to achieve different effects. Think of the cube map as a function of direction, f(normal), and there are all kind of possibilities.

  6. #6
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Hannover, Germany
    Posts
    1,074

    Re: Vertice Normal

    I found it to be quite useful to take the area of each adjacent triangle into account, and gosh, thats only 3 crossproducts and vector lenghts and divides! Then take the bigger triangle's normal more into account.
    - Michael Steinberg

Posting Permissions

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