Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19

Thread: per vertex lighting vs per pixel lighting

  1. #11
    Senior Member OpenGL Pro
    Join Date
    Jul 2001
    Location
    France
    Posts
    1,663

    Re: per vertex lighting vs per pixel lighting

    Zulfiqar you wrote: "You are in no particular space in fragment shaders!"
    You're right, but what I was trying to mean is that all the information calculated by GL for the fragment shader (like half-vector) is done in eye-view space.

    Trahern, could you develop why specular lighting could be a problem on vertex-lighting ? At this point, I don't see why.

    To both of you, I now understand more all the process, so I'll surely (soon or later) also implement a vertex-lighting version to try out efficiency and difference between the two rendering results.

    Thank you for having taking time for my problems

  2. #12
    Intern Contributor
    Join Date
    Apr 2005
    Location
    Prague, Czech Republic
    Posts
    87

    Re: per vertex lighting vs per pixel lighting

    The problem with the specular lighting in per-vertex lighting is that it usualy looks really ugly on low-poly models. I'll show you what I mean ( just a little example with a point light+low poly sphere )

    Per-Vertex Lighting:


    Per-Fragment Lighting:



    Wireframe:


  3. #13
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Naarn, Austria
    Posts
    1,102

    Re: per vertex lighting vs per pixel lighting

    Usually it's much worse than these screenshots. The highlight exactly at a vertex is the best possible case. When the highlight is inside a polygon it will disappear completely with vertex lighting.

    Things get even worse when the objects and lights move...

  4. #14
    Senior Member OpenGL Pro
    Join Date
    Jul 2001
    Location
    France
    Posts
    1,663

    Re: per vertex lighting vs per pixel lighting

    Can it be due to bad interpolation ? I guess so.

  5. #15
    Intern Contributor
    Join Date
    Apr 2005
    Location
    Prague, Czech Republic
    Posts
    87

    Re: per vertex lighting vs per pixel lighting

    Well, yes..the specular color is computed on each vertex and then its interpolated between them. But you simply can't obtain better result with per-vertex lighting unless you make the model more hi-poly. And as Overmind stated this is the best possible case. When the highlight is between vertices then it will look like this:

    Per-Vertex:


    Per-Fragment:



    believe it or not the screenshots are taken from the exact same location/light direction.
    On per-vertex lighted image you cant see any highlight becouse the highlight should be between vertices but it is calculated only for each vertex and then interpolated but in this case no vertex has any highlight on it so there is nothing to interpolate.

  6. #16
    Senior Member OpenGL Pro
    Join Date
    Jul 2001
    Location
    France
    Posts
    1,663

    Re: per vertex lighting vs per pixel lighting

    I believe you Trahern. But that's start up my torment again Should I do per-vertex lighting or not ? Anyway, this is a question I'm the only one who can answer to, but at this moment, I'd choose keeping per-fragment lighting. And I also need to see that story about normal maps, I'll try to find out some info about that, always hoping they would help in interpolating.

  7. #17
    Junior Member Regular Contributor Zulfiqar Malik's Avatar
    Join Date
    Jun 2004
    Location
    London, UK
    Posts
    248

    Re: per vertex lighting vs per pixel lighting

    Originally posted by jide

    I believe you Trahern. But that's start up my torment again Should I do per-vertex lighting or not ? Anyway, this is a question I'm the only one who can answer to, but at this moment, I'd choose keeping per-fragment lighting. And I also need to see that story about normal maps, I'll try to find out some info about that, always hoping they would help in interpolating.
    Yes jide, you are the best person to make a decision. Trahern is right. Per-vertex lighting usually gives bad results in comparison to per-fragment lighting. I was trying to clear up a few things regarding the use of interpolators . It is useful to know the details about them since you will definitely find out one day that your lighting shader is giving really poor performance , and then you will try to optimize it, and then will be the time when you will need to shift some calculations to vertex shader and that's when you need to know how you can use interpolators to minimize per-fragment calculations with little or no visual difference.
    Zulfiqar Inayat Malik.
    Senior Developer, The Foundry.

  8. #18
    Junior Member Regular Contributor Zulfiqar Malik's Avatar
    Join Date
    Jun 2004
    Location
    London, UK
    Posts
    248

    Re: per vertex lighting vs per pixel lighting

    Originally posted by jide

    I believe you Trahern. But that's start up my torment again Should I do per-vertex lighting or not ? Anyway, this is a question I'm the only one who can answer to, but at this moment, I'd choose keeping per-fragment lighting. And I also need to see that story about normal maps, I'll try to find out some info about that, always hoping they would help in interpolating.
    Yes jide, you are the best person to make a decision. Trahern is right. Per-vertex lighting usually gives bad results in comparison to per-fragment lighting. I was trying to clear up a few things regarding the use of interpolators . It is useful to know the details about them since you will definitely find out one day that your lighting shader is giving really poor performance , and then you will try to optimize it, and then will be the time when you will need to shift some calculations to vertex shader and that's when you need to know how you can use interpolators to minimize per-fragment calculations with little or no visual difference.
    Secondly, Trahern's pictures are relevant to area lights like point and spot lights. But in case of directional lights, there will be no difference in diffuse component using per-vertex normals, whether the component is calculated per-vertex or per-fragment.
    Zulfiqar Inayat Malik.
    Senior Developer, The Foundry.

  9. #19
    Junior Member Regular Contributor Zulfiqar Malik's Avatar
    Join Date
    Jun 2004
    Location
    London, UK
    Posts
    248

    Re: per vertex lighting vs per pixel lighting

    Extremely sorry for mistakenly posting the first incomplete post.
    Zulfiqar Inayat Malik.
    Senior Developer, The Foundry.

Posting Permissions

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