Per pixel point light: interpolating vertex world pos

Started by
11 comments, last by angelmu88 12 years, 3 months ago
per vertex lighting:

NdotL0 = dot(N0, L)
NdotL1 = dot(N1, L)
V = NdotL0 + t (NdotL1 - NdotL0)


per pixel lighting:

N = normalize( N0 + t( N1 - N0 ) );
V = dot( N, L );
Advertisement
So it's the renormalization that introduces the "non-linearity" I guess. Because otherwise you could just distribute the dot product into that expression for 'N' and get the same result as in the per-vertex case.

Here are some screen shots from RenderMoneky showing per-vertex nDotL along with per-pixel with and without the renormalization

Per Vertex:

rmpervertex.th.png.


Per Pixel w/out normalize

rmperpixelnonormalize.th.png

Per Pixel w/normalize

rmperpixel.th.png
Ok, you are right, in very strange situations you can see some differences:
Per-Vertex

cubevertex.jpg

Uploaded with ImageShack.us

Per-Pixel

cubepixel.jpg

Uploaded with ImageShack.us

Anyway I think if I only use diffuse component, per-pixel isn't worth it, because I'm not going to use a mesh like the one above (a cube deformed with only two triangles per face).
Thanks everybody!
My 3D graphic engine: http://graphicprogramming.wordpress.com/rebirthengine/
My blog: http://graphicprogramming.wordpress.com/

This topic is closed to new replies.

Advertisement