SCIInstitute / map3d

Other
3 stars 3 forks source link

Strange rendering following triangle flipping #11

Open bryanworthen opened 9 years ago

bryanworthen commented 9 years ago

This one is a little subtle. I was exploring the triangle flipping and it was working fine for the first 4-5 triangles I flipped, but then when flipping just one additional triangle, I got a strange rendering that became visible inside the "hole" created by the flipping.

The two attached images show the effect. Conditions of the image were

map3d -nw -f daltorso.fac -f daltors.fac

so rendering the same surface in two separate windows.

I had the lighting turned on (the third attached image shows what happened when the lighting model was off

I also had a clipping plane turned on show that the back surface of the torso should have been invisible (see 4th image)

map3d1

map3d2

map3d3

map3d4

map3d5

map3dscreensnapz003

map3dscreensnapz004

map3dscreensnapz005

map3dscreensnapz006

bryanworthen commented 9 years ago

I think this is what you're referring to, if not let me know.

When drawing the triangles, each node has it's own normal vector that is the average of all normal vectors of all triangles around it. Start with map3d1.jpg, no triangles flipped. At this point all the normals are pointing to the back.

We flip a strip of them, and they appear dark (map3d2.jpg). Most of the triangles around the flipped triangle are still pointing to the back. The flipped triangles' normals are pointing to the front. However, for each node, the average of the surrounding triangles' normals still points a bit away, hence why they appear dark.

We flip one more next to the strip, and they brighten up (map3d3.jpg). Same reason - where it's brighter, there are more adjacent triangles pointing the same direction.

Flip the "hole" in the middle of them, and they go dark again (map3d4.jpg), and flip a whole bunch, and they go bright (map3d5.jpg).

If this is what you're referring to, we can't do much about it, unless you'd rather the triangles be rendered in "flat" shading - which may be a good idea in triangle flipping mode. I agree that it can be tedious to have all the triangles changing color while you're flipping, but it is kind of nice because it does a good job of showing when you have it wrong.

Actually, if you turn on flat shading (surface data->render style->flat) and elts/conn (mesh->render as->elements and connectivity), it makes a pretty good triangle flipping mode... However, with flat and elements (w/o connectivity), you can't really tell, so you have to be careful how you're viewing the data.