Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / What is object normals?

Author
Message
mnemonic
19
Years of Service
User Offline
Joined: 14th Jan 2007
Location: Sweden
Posted: 13th Feb 2013 20:42
What is Object normals? And how can you make use of these?

Best!

www.memblockgames.com
Nytus Sermus
13
Years of Service
User Offline
Joined: 17th Jan 2013
Location:
Posted: 13th Feb 2013 20:47
Normals are a vector of length 1, that point away from the triangle/ face on a model. They are used to reference the normal of a surface, or the orientation of it. You could use this data to maybe place a bloodstain on a wall, you would use the normal to align the image to wall, among other things, its often used to orient things to other things.

You could be done already.....stop trying to re-invent the wheel.
mnemonic
19
Years of Service
User Offline
Joined: 14th Jan 2007
Location: Sweden
Posted: 13th Feb 2013 20:52
Thank you!

www.memblockgames.com
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 13th Feb 2013 22:24
It's a perpendicular vector from a plane's surface.

If A,B,C represent the 3 points of a triangle, you can find the normal by forming two vectors and calculating their cross product:

normal = (B-A) X (C-A)

But don't forget to normalize that result.

"You're all wrong. You're all idiots." ~Fluffy Rabbit
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 13th Feb 2013 22:28 Edited at: 13th Feb 2013 22:33
http://en.wikipedia.org/wiki/Normal_%28geometry%29

This kind of stuff is why programming is so good for learning: you can't stick your hands in and move things about, you have to control them with maths, and then you see the utility and power of mathematics.

^ That's what she said.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 14th Feb 2013 00:40
But wait, object normals aren't always perpendicular to the face. Is there any use for that?

TheComet

http://blankflankstudios.tumblr.com/
"ZIP files are such a retarded format!" - Phaelax
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 14th Feb 2013 00:55
Quote: "Is there any use for that?"

for smoothing

mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 16th Feb 2013 18:32
Quote: "It's a perpendicular vector from a plane's surface."

Face has no normals, the vertex does. There is no face. There is only vertex.

*** Merry Chuckmas! ***
Dar13
18
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 16th Feb 2013 21:31
Quote: "Face has no normals, the vertex does. There is no face. There is only vertex."

There's two types of normals, vertex and polygon. Vertex normals are defined per-vertex and aren't generally used all that much as far as I can tell. Polygon normals are defined as Phaelax showed a couple posts above. Most normals you see referred to in game development are polygon normals as they are more useful than plain vertex normals.

mnemonic
19
Years of Service
User Offline
Joined: 14th Jan 2007
Location: Sweden
Posted: 17th Feb 2013 11:06
okay,,, I know what a vector normal is from math. But since i've seen so many things that ends in normal, such as object, surface, vertex, polygon normals etc I started to wonder: Do you use the same mathematical method for calculating these? Are they theoratically the same thing, just that they referr to different things?

But I think I have a better understanding know, thank to you guys. Thanks!

www.memblockgames.com
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 17th Feb 2013 13:34 Edited at: 17th Feb 2013 13:36
Quote: "There's two types of normals, vertex and polygon. Vertex normals are defined per-vertex and aren't generally used all that much as far as I can tell. Polygon normals are defined as Phaelax showed a couple posts above. Most normals you see referred to in game development are polygon normals as they are more useful than plain vertex normals."


How do you access polygon normals? Can they be accessed in fragment shaders? And how do polygon normals relate to vertex normals? Are polygon normals an average of the three surrounding vertex normals or something, or are they just perpendicular to the polygon?

TheComet

http://blankflankstudios.tumblr.com/
"You're all wrong. You're all idiots." - Fluffy Rabbit
"Bottom line, people are retarded." - Fluffy Rabbit
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 17th Feb 2013 13:54
Quote: "How do you access polygon normals?"

you don't, there's no such thing as polygon normal. DirextX and OpenGL have only vertex normals.

Normals depend on shading type. There's flat shading and smooth shading.

In flat shading normal is calculated as a vector which is perpendicular to a polygon surface. That normal is then stored in every vertex of a polygon.

In smooth shading normal is also calculated as a vector perpendicular to a polygon vertex but vertex normal is calculated as an average of all polygon normals that vertex belongs to

Dar13
18
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 17th Feb 2013 15:45
Quote: "How do you access polygon normals? Can they be accessed in fragment shaders? And how do polygon normals relate to vertex normals? Are polygon normals an average of the three surrounding vertex normals or something, or are they just perpendicular to the polygon?"

I don't know if you can access them from a fragment shader(haven't done enough shader programming), can access them from object data in DBP via "get vertexdata normals" or generate them like how Phaelax did above:
Quote: "It's a perpendicular vector from a plane's surface.

If A,B,C represent the 3 points of a triangle, you can find the normal by forming two vectors and calculating their cross product:

normal = (B-A) X (C-A)

But don't forget to normalize that result."


Quote: "you don't, there's no such thing as polygon normal."

So Sparky's Collision isn't accessing a stored normal for polygon collision? I'd always assumed that normals were stored when models and such were loaded into memory. The DirectX file format allows for normals to be stored per-polygon IIRC.

Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 17th Feb 2013 17:46
Quote: "So Sparky's Collision isn't accessing a stored normal for polygon collision?"

no, they are calculated when the collision occurs

Quote: "I'd always assumed that normals were stored when models and such were loaded into memory."

they are but not on the polygon level, only vertices have normals

Quote: "The DirectX file format allows for normals to be stored per-polygon IIRC."

i don't know about .x format but in memory there's no polygon normals just vertex normals. There's no data structure for polygons, only vertices have data structure and polygons are 3 vertices in a row

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 17th Feb 2013 21:34
Quote: "only vertices have data structure and polygons are 3 vertices in a row"


Are polygons sequential; or is there no way to assume that a polygon shares two vertices with the next polygon?

Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 17th Feb 2013 21:57 Edited at: 17th Feb 2013 22:02
Quote: "or is there no way to assume that a polygon shares two vertices with the next polygon?"

There is

objects can be assembled in 2 ways:
1. only using vertex buffers where 3 sequential vertices form a polygon/triangle
2. using vertex and index buffer where 3 sequantial indices in index buffer point to a 3 vertices that form a polygon/triangle - that index format is called triangle list and is the most common. There's also triangle fan and triangle strip

So, in 2nd case you can have a index buffer like this (in a case of triangle list):
0
1
2
3
0
1

That would be a plain which consists of 4 vertices and 2 triangles(which share 2 vertices)

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 18th Feb 2013 00:16
Thanks, that will be a handy lesson.

Login to post a reply

Server time is: 2026-07-08 05:38:06
Your offset time is: 2026-07-08 05:38:06