Archived

This topic is now archived and is closed to further replies.

MrFreeze

How to have lighting computed for every pixel??

Recommended Posts

Hi, I was wondering if it is possible to tell openGL to compute the correct lighting for every pixel of a triangle, instead of having openGL interpolating it between the three vertices? The problem I have is as follow: I have a big plane which is composed of two triangles. If I put some lighting onto it, the effect is not real and you can''t see the cone of the light on the plane. What I used to do is simply subdivide the plane into sub-planes until the cone becomes visible and quite smooth. But this can take lot of time (instead of rendering 2 triangles, I have to render 10000+ triangles depending on how close my camera is of the plane). Then I thought there must be some option to tell openGL to compute the lighting between the vertices of a triangle instead of interpolating it. Am I wrong? Thanks

Share this post


Link to post
Share on other sites
Um, yes you are wrong (afaik). There is no way to computer the light inside a triangle. However, there may be extensions which allow for something similar. I''ve never actually gone and looked at what those new fangled pixel shaders and vertex shaders are capable of, so I don''t know for sure. Also, there is always to option of using lightmaps.

--Buzzy

Share this post


Link to post
Share on other sites
Not without an extension (say, pixel shaders).
OpenGL 1.2 doesn''t support Phong shading.

You will have to subdivide your plane.

Share this post


Link to post
Share on other sites
AFAIK you can do per-pixel lighting using register combiners... Although I haven''t tried it myself...

Death of one is a tragedy, death of a million is just a statistic.

Share this post


Link to post
Share on other sites
depending on what you wanna do exactly you can do it on every gpu, or on gpu''s that support the GL_EXT_texture_env_dot3 extension, or registercombiners, or fragmentshaders, or textureshaders..

perpixellighting is a hot topic and fully in evolution since about 1 year

for infos about it:
developer.nvidia.com
www.ati.com

Share this post


Link to post
Share on other sites
>>..bit surprised (because it wouldn''t be such a big thing to support this, isn''t it?).<<

theres a lot more calculations to calculate lighting per pixel than just 3x (once for each corner of the triangle) + lerp between them.
a lot of hardware eg voodoo5, tnt2 dont support this

http://uk.geocities.com/sloppyturds/gotterdammerung.html

Share this post


Link to post
Share on other sites
Well, you can approximate the dot product using unextended opengl, but this requires many passes, see Cass Everitt''s OIM paper.
http://www.opengl.org/developers/code/features/oimfinal/perpixel.html

With OpenGL 1.3 and the texture_env_dot3 and texture_env_combine being the part of the spec one surely can do per pixel lighting.

You get more flexibility with register combiners/texture shaders(NVIDIA) or fragment shaders(ATI).

The bad thign about it is that there is no glEnable(GL_EYE_CANDY_PER_PIXEL_BUMPMAPPING), you have to do everything yourself and it can be tricky. If youwant to understand what you#re doing you''ll need some math (argh... the &%$§ing tangent space generation .

On NVIDIA''s site you''ll find lots of information about per pixel lighting, as someone already mentionen, I esp. recommend Mark Kilgard''s paper "A Practical and Robust Bump-mapping Technique for
Today’s GPUs" it explains the theory behind per pixel lighting.

-Lev

Share this post


Link to post
Share on other sites