Which is better for lighting quality?

Started by
15 comments, last by MARS_999 17 years, 11 months ago
I just got the Gems6 book this week... I read the chapter on Vertex texturing with PS3.0 for terrain rendering. The author states that lighting quality is better if you calculate a normal map and use that in the FS vs. calculating the normals in the VS and then sending them to the FS? Right now I calculate my normals and send them to OpenGL and in the vertex shader I

normal = normalize(gl_NormalMatrix * gl_Normal);

and send that normal to the FS. Is this true? Thanks
Advertisement
The way you do it, you have one normal per vertex.
Those are interpolated across each fragment.. it looks good for spheres and, such things, but you get no details.
A normal-map can make it appear like you have loads more vertices than you actually have, just look at Doom3. :D

Another problem you have is you normalize your normals in the vertex program.
When these are later interpolated and sent to the fragment program, some of these will NOT be normalized anymore, and the lightning quality will be bad...
Normalize in your fragment program, or use a normal-texture for kick-ass lighting. :D
Ok, so this will still be the case even if I renormalize the normal in the FS, that the normalmap will be better quality still. Thanks for the info.
Quote:Original post by gulgi
Normalize in your fragment program, or use a normal-texture for kick-ass lighting. :D


and you should prefer to use normilisation in the FS over a texture for newer hardware (9700 and up and GF6 and up) as using a texture wastes bandwidth and cache.
Quote:Original post by phantom
Quote:Original post by gulgi
Normalize in your fragment program, or use a normal-texture for kick-ass lighting. :D


and you should prefer to use normilisation in the FS over a texture for newer hardware (9700 and up and GF6 and up) as using a texture wastes bandwidth and cache.
..if we were talking about a normalization cubemap that is. :D
I just meant use a normalmap OR interpolated renormalized vertexnormals. And yes, on newer gfx cards, normalize with math, and on something old as my GeForce5800, a a cubemap is way faster.. :)
Ok, I am trying to implement a normalmap for my PPL lighting. I am having a issue with my lighting moving around on me when I move my camera and must have to do something with the way I am calculating my lightDir? I am using a directional light.

//vs lightDir = normalize(vec3(gl_LightSource[0].position));//fsvec3 n = texture2D(normalmap, gl_TexCoord[0].xy);   n = vec3(2.0) * (n - vec3(.5));   vec4 lightColor = ambient;   float NdotL = max(dot(n, lightDir), 0.0);


thanks for any help...
Quote:Original post by MARS_999
Ok, I am trying to implement a normalmap for my PPL lighting. I am having a issue with my lighting moving around on me when I move my camera and must have to do something with the way I am calculating my lightDir? I am using a directional light.

*** Source Snippet Removed ***

thanks for any help...


Right now it seems that you're calculating lightDir as the vector from the eye point to the light source. (Assuming gl_LightSource[0].position is specified in view-space, I always forget).

Anyway, you need to calculate the vector from the vertex to the light source.
Quote:Original post by mhamlin
Quote:Original post by MARS_999
Ok, I am trying to implement a normalmap for my PPL lighting. I am having a issue with my lighting moving around on me when I move my camera and must have to do something with the way I am calculating my lightDir? I am using a directional light.

*** Source Snippet Removed ***

thanks for any help...


Right now it seems that you're calculating lightDir as the vector from the eye point to the light source. (Assuming gl_LightSource[0].position is specified in view-space, I always forget).

Anyway, you need to calculate the vector from the vertex to the light source.


So this then? If so that isn't working either... :(
lightDir = normalize(vec3(gl_LightSource[0].position) - vec3(gl_Vertex));


Well I think I got it working but I am doing bumpmapping with tangent space and as of now I am thinking the Lighting looks a lot better than the VS/FS lighting... I thought doing the lighting in the FS was supposed to be PPL... But it doesn't look this good... Anyone care to comment on this, to help me understand why. Thanks
It is difficult to give you a definitive answer whithout the complete VS / FS.

Therefore, I will just suggest to have a look at Lighthouse3D GLSL tutorial which explains how to perform PPL for directional / spot / omni lights and compare PPL to vertex lighting.

This topic is closed to new replies.

Advertisement