Splitting polygons, problem with normals

Started by
4 comments, last by sepul 19 years, 2 months ago
Hi I'm building BSP tree out of level geometry which requires splitting polygons. the split poly algorithm works, but with incorrect normals when new vertices are created, I used couple of methods to calculate the new vertex normal : - n = (v1.n + v2.n)/2 -> bad lighting - n = faceNormal -> bad lighting - n = interpolation of two normals -> better lighting, but still have problems anyone knows the correct way of splitting a polygon that I can have correct normals ? thanks

dark-hammer engine - http://www.hmrengine.com

Advertisement
My guess is this:

Change

Quote:n = (v1.n + v2.n)/2 -> bad lighting


to

n = v1.n * (1-f) + v2.n * f

where f is the fraction where the split occurs between v1 and v2
______________________________________________________The problem with designing something completely foolproof is tounderestimate the ingenuity of a complete fool. - Douglas AdamsEmail: thefatgecko@yahoo.co.ukhttp://www.geocities.com/thefatgecko
Taking it one step further, interpolation should work, as long as you normalize the result so the normal is of unit size again.

Something like this should do the trick:

n = v1.n + ( T * ( v2.n - v1.n ) );
n.Normalize();

where:
if T = 0, split is at v1
if T = 1, split is at v2
if ( T > 0 ) & ( T < 1 ) split is inbetween v1 and v2.
Steve Broumley
Wouldn't you just calculate the vertex normal from the adjacent faces like you'd normally would do? (i.e. the average of the face normals of all faces adjacent to the new vertex).
thanks
but I've just tried all of these three methods that as you guys mentioned. but none of them get me satisfactory results. while recalculating normals out of adjucent faces, makes better results.
I have addressed the linkt to my test application that draws a bsp scene with normals and three lights, as you can see there are problems with lighting with each method.

there are 3 BSP files that is built with each method, before running the demo, rename each BSP file into World3.bsp to test it.

here is the link : http://www.geocities.com/seppehrt/bsploader.zip

dark-hammer engine - http://www.hmrengine.com

I fixed the problem, thanks to you guys for your help, the third method works perfectly. but at first I implemented it a little wrong.

in splitting polys, each time a plane hits an edge I added a vertex, so multiple vertices with the same positions were born on adjucent faces, and that raised problems with calculating normals.

so with the new fixes, it now adds fewer vertices, but takes some more time, and the normals are correct.
download the link : http://www.geocities.com/seppehrt/world3_correct.zip , and rename the bsp file to "world3.bsp" as you can see the lighting is correct.

and forget about inerpolation or average technics between two normals, they won't work.
thanks

dark-hammer engine - http://www.hmrengine.com

This topic is closed to new replies.

Advertisement