Normals and GL_TRIANGLE_STRIP

Started by
30 comments, last by MARS_999 20 years, 8 months ago
Ok I am trying to setup my engine to do lighting on the terrain and now have to calculate normals. I am not sure but since I am using GL_TRIANGLE_STRIP and have 4 vertexs calculating a normal using 3 points and two vectors isn''t going to work is it? I mean only half the so called quad would have light right? If this is the case do I have to do the calculations on the 4th point and third vector? Thanks for the help.
Advertisement
there are two good reasons not to.

-opengl vertex lighting doesnt look too good
-for a lot of geometry its pretty slow (for me at least, might be my mistake)
-calculating the average normal for every vertex is a pain (though you''ll do that one way or another and there a great shortcuts for grids)
-normals will take up another 3 floats per vertex (in my case not acceptable to require 80mb just for terrain geometry)

-using a normal map allows per pixel lighting
-normal map has 3byte per vertex instead of 12
-per pixel lighting looks far better
-per pixel lighting is only slightly slower than no lighting

btw. again it doesnt matter if you use strips or lists, thats just changing the order of visiting vertices and in no way what they contain.
f@dzhttp://festini.device-zero.de
Trienco I don''t have any knowledge about per pixel programming. I am assuming you''re saying using normals on every polygon in a terrain engine would be suicide for speed? What are you referring to when you say a normal map? Thanks for all your help.
a normal map would still contain all normals, with red as x, green as y and blue as z. your pixelshader/register combiner/whatever would just have to calculate the dotproduct of this normal and the light direction, multiply the result with the light color and the texture.
bonus: different levels of detail wont have different looking lighting.
f@dzhttp://festini.device-zero.de
per pixel lighting requires at least a geforce 3/radeon 8500 to run , for my , at this time it''s still an expensive card, MARS , the order of vertices drawn with tri strips goes like this :

triangle 0 : v0,v1,v2
triangle 1 : v2,v1,v3
to find the normals per face get the cross product from the difference of each 2 vectors per face, as for the normal per vertex you will need to average the normals of the faces sharing that vertex that''s simply just normalizing the sum of those normals.
feel free to mail me at bytebrain@k.ro for more feedback
Trienco: How can you have perpixel lighting ( using a normal map ) WITHOUT using vertex normals? Infact, you''d have to save at least one other vector ( tangent ) to do it, as you''d have to transform the light vector into tangent space before you perform the dot product.

Unless you''re talking about stretching a texture over the terrain, and doing a "bump" on that ( ie, so one pixel equals one vertex ), in which case it won''t look as good as standard lighting because the accuracy just isn''t as good.

Death of one is a tragedy, death of a million is just a statistic.
If at first you don't succeed, redefine success.
Trienco:

I am curious, what video card can you possibly be using which supports normal maps yet is "slow" when rendering vertices containing normals?

super genius
I have a GF2, and I use the standard OpenGL light (1 light at daytime, up to 8 at night time).
There is no difference between lighting on/off (I am talking about scenes between 1-30K traingles).

Height Map Editor | Eternal Lands | Fast User Directory
hm. that might be the reason.. im having scenes with 50k-200k

do you have a demo of that? i cant imagine 8 lights making no difference.

its a basic gf3 btw. but i thought gf2 also had register combiners. after all per pixel lighting was their great hype when they introduced it *confused*
f@dzhttp://festini.device-zero.de
I guess I need to ask this since I am becoming confused. I have my terrain engine up and running, it also has textured polygons. Now if I add in lighting which I need normals for right? Will lighting still work after I have applied textures? If so how is going to look? Does anyone have a screenshot with lighting and a textured terrain engine? What I am trying to do is, allow the user to see that their is valleys and hills without having to zoom in really close to see them. As of right now its difficult to see them without getting in real close. Thanks

This topic is closed to new replies.

Advertisement