Jump to content
  • Advertisement
Sign in to follow this  
50_Cal

I'm new in GLSL, whats the difference between per-vertex lighting & per-pixel lighting?

This topic is 2299 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

As the title, im wondering whats the difference between them.
Cuz vertex shader deals with every vertex the program transfers, and how can it deal with the pixels ?

Share this post


Link to post
Share on other sites
Advertisement
in per-vertex lighting, lighting computation is done at each of the vertices of a model in the glsl vertex shader and the resulting pixel color is an interpolation of the color values of vertices on a face passed from the vertex shader. In per pixel lighting, all lighting computation is done pixel wise in the fragment shader. If the faces on a model are too big, per vertex lighting produces incorrect and undesirable and will require tessellation or subdivision of the faces.
Per vertex is faster since less computation is involved. Per pixel lighting gives correct result but requires pixel wise computation.

Share this post


Link to post
Share on other sites
1) Per vertex lighting is computed in vertex (or geometry or tessel) shader, with setting apropriate interpolation that OpenGL will use to get lighting per pixel.
2) Per pixel lighting is computed in part on vertex (geo or tess) shader for normal vectors, with setting apropriate interpolation that OpenGL will use to get normals per pixel. But actual lightning is computed in fragment shader based on that interpolated normal, with manual control over how relusting color must be incorporated into framebuffer.

There are few consequences:
Per vertex lighting put computation in vertex (geo or tess) shader stages so it is less computational intensive.
Per pixel lighting allow for more accurate color for every pixel.
Per vertex lighting interpolate color but only inside of primitive so it there is other primitive near by it can have different color which reasult in more artificial look.
Per pixel lighting interpolate normals but only inside of primitive *but* for near by primitives normals will vary only slightly, so relusting color should be not so different, giving impresion of "smoothnes".

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!