#### Archived

This topic is now archived and is closed to further replies.

# Metaballs - Normals

This topic is 5758 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Before I forget my thanks also go out to you goltrpoat!

But goltrpoat, this may look like a stupid question, but because of my bad English - can you explain what you mean in more simple words?

##### Share on other sites
This is starting to look like a tutorial on "how to calc your normals on smooth surfaces".

Implementation of above angle calculation solution is completed but - normals are still wrong!!!
Here''s the next and hopefully last question on perfect normal calculation:

The size of each poly does also matter!
Hope to explain more with the following pictures:
"2D images of an metaballs animation"

the animation starts with a uge red polygon (line in this case)

during animation, the red poly shrinks to almost none existing

Watch the green normals: if the polygon gets smaller -> the normals come closer together and in the end are the same!!!

So, the question is (forget about the angle calculation explained above):
Is there a formula to calculate the correct normal of a vertex using it''s attached polygon normals, while polygons differ in size?

Am I right?
Can you just calc the polygon normal (as always) and divide it by the average size of the polygons edges. Then add up all the normals that are attached to a vertex, and normalize?

##### Share on other sites
Let's use a generalized function for averaging the normals at the vertices

NV = w1*N1 + w2*N2 + w3*N3 + ...

Here NV is the vertex normal. N1, N2, and N3 is the normalized triangle normals. w1, w2, and w3 is the weights that are used to average the normals together.

1. If you ignore the size of the triangle and the angle it makes at the vertex, all weights are 1.

2. You can use the angles as weights. This ensure that the vertex normal stays the same if one of the triangles are divided in two at the vertex. Yet it ignore the size of the triangle which is also good if you for example tesselate your triangles so that a triangle is divided into four parts.

3. If you use the size of the triangle as weight, you'll of course get that larger triangles have more influence on the vertex normal. This is not too good if any triangle is divided into parts as the size will then change and the vertex normal will move away from the triangles normal. But then again this may be what you want.

4. Then there is the possibility to use the reciprocity of the triangles area as weight. Then the smaller the triangle is the more influence it will have. This has similar effects as the above.

For your problem I would say that number 4 is what you want. Here you can compute the weight like this:

E1 = V1-V0
E2 = V2-V0
Normal = CrossProduct(E1,E2);
w = Normal.x*Normal.x + Normal.y*Normal.y + Normal.z*Normal.z;

VertexNormal += Normal/w;

You'll of course have to be careful so you don't get divide by zero due to the low precision of floats or doubles.

Give this a try and see if it works better

(Hmm, I think I'll have to make my own little demo with Metaballs )

- WitchLord

Edited by - WitchLord on May 22, 2000 6:40:26 PM

##### Share on other sites
WitchLord, good to hear from you again! Who else could respond so such a topic (maybe goltrpoat?).

I first said:
> Can you just calc the polygon normal (as always) and divide it by the average size of the polygons edges. Then add up all the normals that are attached to a vertex, and normalize?

Your version: (see if I''m getting this right)
> Calc the polygon (un-normalized-)normal and divide it by it''s own (un-normalized-)normal length^2. Then add up all the normals that are attached to a vertex, and normalize!

This way small polys weigh more. If a polygon size is nearing zero the weight is nearing infinity...
If the above doesn''t turn out to be the solution, should we be thinking in a sort of interpolation technique between polygons?

Looks like you know what I meant, and it seems right!
Also, your formula is a nice and fast implementation, thanks. In a few minutes/hours I''ll be needing some sleep, but I''ll test it tomorrow.

> (Hmm, I think I''ll have to make my own little demo with Metaballs )

If you ask me: metaballs is a different topic. Maybe the solution to this normal problem lies elsewhere, but then again - maybe not!
Hey, why don''t you write a GameDev tutorial on "Smooth surface normal calculation"? Seems like you know your stuff!
It''s hightech to me.
You have my permission to use the superb images on this page!

Anyway, hope to hear from you again...I''ll be back with more...

##### Share on other sites
After you stopped laughing from the previous joke (I know: wasn''t that good),

Is there a Smooth-Surface-Normal-Calculation-Guru around?

(Maybe nobody is smarter than WitchLord?)

##### Share on other sites
There are plenty of guys smarter than me. They are just too smart to hang around here when they could be working on their own game.

Maybe I will write a tutorial on smooth surface normal computations, but I think there are more important ones to be written first. Read my thread "A Direct3D tutorial by WitchLord" and give your suggestions for future tutorials.

- WitchLord

##### Share on other sites
I''m sorry but I''ve only done OpenGL and currently my own software rendering. But it looks great - good use of colours - nice links to ms!

If you write your future tutorials in a more independant style, you''ve got a 100% of my attention!

By the road, checked out my tutorials? (getting a little old though)
- Backface culling & optimization
- General 3D optimization techniques
- 3D Matrix calculations
- Fullscreen Windows application (Win32 or DirectDraw)

##### Share on other sites
Screenshot, probably a good idea. I will add this in the future. As these are my first tutorials there are room for alot of improvement and I''m grateful for any tip I can get.

What do you mean with independant style?

PS. I like you homepage, very pleasant design. The tutorials look good as well, even though there wasn''t anything I didn''t already know.

- WitchLord

##### Share on other sites
Thanks, and you''re right: it needs some new stuff.
I see we have the same idea''s, when it''s about tutorials.

> "independant style"

I can see this could see said more clearly. How can I say this...I mean platform independant, OpenGL/Direct3D independant. Everybody has it''s own interrest and opinion, but if it''s "independant" everybody will have something from it!
Do I make any sense? Sometimes my English leaves me!

I also saw your new thread "A Direct3D Tutorial from WitchLord" and will be posting tutorial stuff to this thread from now on.

Has anyone seen the tutorial Metaball stuff on Gamasutra?
Maybe I''ll do some more research before restarting metaballs...but will be back...

##### Share on other sites
My tutorials will be as independant as they can be without talking about anything else than Direct3D. I don''t know enough about OpenGL to really say anything about it. But the 3D theory that I''m planning on writing about for my coming tutorials can be applied to both OpenGL and Direct3D. As I speak about the theory I will show how it is done in Direct3D, but if the reader knows OpenGL he/she should be able to implement it from the theory.

And yes I saw the article on Gamasutra. I haven''t had time to read it though. At a quick glance it looked as if he used ''marching tetraeders'' instead of cubes, which I think is a stupid choice. But it is perhaps easier write about them.

- WitchLord

• 12
• 33
• 15
• 15
• 15