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 5 of 5

Thread: flat/gourad shading question

Hybrid View

  1. #1
    Intern Newbie
    Join Date
    Jan 2013
    Posts
    42

    flat/gourad shading question

    Hi there,

    For a project I have a terrain (height map), for which I preferably would only like to use 1 vertex per height point, but the problem is that I would like to have hard edges. If I use flat shading it looks good without any lights, but if I add lights it will light up the terrain on triangle basis, instead of per vertex, and this doesn't look good. If I use gourad shading however, I can't seem to get around making 3 vertices for each triangle, so that I can point the normals for each triangle outwards so I can the hard edges. But it seems a waste of vertices. Is there another way that i can achieve a lighting similar to gourad, have hard edges, and only use 1 vertex per height-point in my map?

    Thanks a lot for any information!!

  2. #2
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    It's not clear what it is you mean by "have hard edges". Edges only matter in terms of lighting. Where do you want hard edges? And if you want hard edges across every edge, then this means you must use flat shading.

  3. #3
    Intern Newbie
    Join Date
    Jan 2013
    Posts
    42
    yes I mean they have to be flat looking... I'm going for terrain-look like simcity 2000, but then in 3d..


    But I CAN get flat looking faces use gouraud shading, as long as I point all the normals of a face in the same outward direction. For example a standard cube has that. If I turn on gouraud shading it does better lighting because it interpolates colors/lighting between triangles, and flat shading doesn't seem to do that. you can clearly see that each triangle has 1 color, which is not the case with gouraud. So basically I do want gouraud shading, but I want to try to share vertices between triangles....

  4. #4
    Junior Member Regular Contributor
    Join Date
    Apr 2012
    Location
    Los Angeles
    Posts
    173
    Have you tried fooling around with glShadeModel ?

  5. #5
    Intern Newbie
    Join Date
    Jan 2013
    Posts
    42
    Thanks for pointing that out! I was looking at it and found the following discussion, which seems to answer my question. Seems it is possible to calculate the face normals in a a fragment shader so you can ignore vertex normal (and thus save a lot of vertices) and do a custom flat shading

    http://www.opengl.org/discussion_boa...at-shading-now

Posting Permissions

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