Results 1 to 5 of 5

Thread: flat/gourad shading question

  1. #1
    Member Newbie
    Join Date
    Jan 2013
    Posts
    46

    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 Lord
    Join Date
    Mar 2015
    Posts
    6,672
    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
    Member Newbie
    Join Date
    Jan 2013
    Posts
    46
    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
    Senior Member Regular Contributor
    Join Date
    Apr 2012
    Location
    Los Angeles
    Posts
    394
    Have you tried fooling around with glShadeModel ?

  5. #5
    Member Newbie
    Join Date
    Jan 2013
    Posts
    46
    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

Similar Threads

  1. help with flat shading
    By ale211734 in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 06-25-2015, 12:10 PM
  2. Implementing Flat Shading
    By Mr_Bean in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-27-2014, 02:29 PM
  3. VBO with flat shading
    By tchau83 in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 09-27-2010, 08:24 AM
  4. flat shading with VBO
    By thinks in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 07-23-2009, 05:10 AM
  5. flat shading
    By heppe in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 12-04-2003, 05:43 AM

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