How to have lighting computed for every pixel??
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
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
--Buzzy
Not without an extension (say, pixel shaders).
OpenGL 1.2 doesn''t support Phong shading.
You will have to subdivide your plane.
OpenGL 1.2 doesn''t support Phong shading.
You will have to subdivide your plane.
...bit surprised (because it wouldn''t be such a big thing to support this, isn''t it?).
Thanks anyway for your help
Marc
Thanks anyway for your help
Marc
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.
Death of one is a tragedy, death of a million is just a statistic.
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
perpixellighting is a hot topic and fully in evolution since about 1 year
for infos about it:
developer.nvidia.com
www.ati.com
>>..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
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
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement