PDA

View Full Version : Vertice Normal

HaHa
04-16-2004, 06:42 AM
Hey,

I have the face normals for a series of triangles which compose a triangle mesh in a terrain program I have written.
Since I am passing the triangle’s face normal once for each of its three vertices the triangles stand out when light is placed upon it.

I tried this method of smoothing the lighting effect.
I found all the triangles sharing a particular vertex and calculated the average between the face normals and assigned that value to the vertex’s normal. I repeated that process for all the vertices. The result was that the lighting was too smooth and practically no detail can be seen.

I wanted to know if there is a better method of producing smoother lighting with out having individual triangles ‘standing out’ or having all details disappear.

charliejay
04-18-2004, 01:29 AM
A few suggestions...

Are you using OpenGL's lighting? - you may be able to change the type of lighting equation used, but I'm not sure on that one.

Otherwise, you'll need to use your own lighting, and control the brightness through the colour you're passing in for each vertex - this may require that you change your texturing from, for examle, DECAL to MODULATE

charliejay
04-18-2004, 01:38 AM
Or, again in the context of DIY, you could use a fragment program. if your card supports them...

V-man
04-18-2004, 10:40 AM
The lighting equation is not at issue.
He just needs to tweak the normals a bit to get something you like.

I'm assuming he is averaging face normal. Instead of simple averaging, you can use blending weights.

example :
vertex_normal = face_normal_1 *50% + face_normal_2 *25% + face_normal_3 *25%;

so 50%, 25%, 25% are the blending weights.

This is just an example when a vertex has 3 faces sharing it.

plasmonster
04-18-2004, 11:06 AM
If you can use a cube map for the diffuse light, for example, you can turn this problem on its head. Instead of varying the normals, vary the light in the cube map to achieve different effects. Think of the cube map as a function of direction, f(normal), and there are all kind of possibilities.

Michael Steinberg
05-07-2004, 10:27 AM
I found it to be quite useful to take the area of each adjacent triangle into account, and gosh, thats only 3 crossproducts and vector lenghts and divides! Then take the bigger triangle's normal more into account.