Jump to content
  • Advertisement
Sign in to follow this  
YengaMatiC

Per-pixel diffuse lighting (dot3)

This topic is 4842 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

Hi, i'm trying my material system for fixed function pipeline. I want per-pixel diffuse lighting. I have constant light vectors per vertex, passed as texture coordinates to a normalisation cubemap. So I get per-pixel light vectors. Then i pass per vertex normals as primary color, so they get interpolated across the surface to give per-pixel normals. Finally i set up glTexEnv to do DOT3 between primary color (normals) and texture (normalised light vectors). This are the results. It doesn't seem to be per pixel lighting. I know the mesh is not very tesselated, but it should work ok. I rendered primary color to see per pixel normals (from a diferent point of view) and they seem to be ok. I avoided to rotate light vectors to tangent spaces because i don't need a normal map to perturb normals. If i transform light vectors then i'll have a constant normal, so it's a waste of CPU doing the transform. I also tried to pack normals to [0,1] range before passing them as primary color, getting the same result. Do you know what's happening?? EDIT: i made a test with a more tesselated torus and i still get that per-vertex look. [Edited by - YengaMatiC on August 14, 2005 4:53:00 PM]

Share this post


Link to post
Share on other sites
Advertisement
I bet you are normalizing the light positions per vertex. If so, don't do this. Light positions are positions, not normalized vectors.

Let the cubemap do the normalization implicitly for you.

At each vertex, just subtract the light position, and pass that to the cubemap.

Share this post


Link to post
Share on other sites
I don't normalize the light positions per-vertex. They are constant vectors that indicate light direction from a directional light.
I tried to pass normals to normalisation cubemap, but i get weird results (in theory i should get the same result).
I'm also computing tangent space matrices following Eric Lengyel's method (in opengl forums), but there's something bad with my tangents, so i cannot use them yet. What texcoords do i have to use to compute tangents?

Share this post


Link to post
Share on other sites
I think i found the problem. My PackTo01 function wasn't working as it should.

Now i modified it and i pass normals packed to [0,1] as vertex colors and light vectors also packed to [0,1] as texture coords. This is the result i get with a dodecahedron.
Theres also a torus and the same torus with normals and faces shown.
I still have problems with tangent computation, so i cannot test with tangent space transformation of light vectors.

What do you think?

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!