Jump to content

Primitive Normals again


gaurav

Recommended Posts

Hello Folks,

I did a search and found answers to some of my questions about them.

However 2 of them remain unanswered rather unclear.

1. How primitive normals are really derived / calculated. ?

2. Do they qualify to be called as primitive attribute ?

If prim() returns an attribute which exists on a primitive.

We can surely access them using prim("../path",$PR,"N",index). Does this make them an attribute?

If yes then why can't they be renamed using "attribute" node to something else.

Whats going on under the hood ?

Just curious.

Thanks,

Edit - What are some of the various advantages of having them this way ? Noob !!

Edited by vectorblur
Link to comment
Share on other sites

Actually, I think it's vice versa - the vertex normals are calculated from the primitive normals.

I'm sure the primitive normals are calculated from the polygon's vertex positions.

I don't know how exactly, one way would be to take a vector from vertex 0 to vertex 1 and another from vertex 0 to the last vertex, and do a cross product.

(This is the way LW calculates it)

You can also see why the winding of the vertex order decides which way the normal points.

Link to comment
Share on other sites

Hi guys,

Thanks for the replies.

Actually, I think it's vice versa - the vertex normals are calculated from the primitive normals.

hey eetu, Can we visualize vertex normals to check it ?

I find the idea of vertex normals little strange in sops, never seen them in action.

I'm sure the primitive normals are calculated from the polygon's vertex positions.

I don't know how exactly, one way would be to take a vector from vertex 0 to vertex 1 and another from vertex 0 to the last vertex, and do a cross product.

(This is the way LW calculates it)

You can also see why the winding of the vertex order decides which way the normal points.

You nailed this one. I tried reversing the polygon only to find vertex 1 and 3 are swapped. So vertex position makes sense more than normal.

Thanks,

Link to comment
Share on other sites

hey eetu, Can we visualize vertex normals to check it ?

I find the idea of vertex normals little strange in sops, never seen them in action.

Ohh, sorry, I meant to say point normals are calculated from primitive normals.

I, too, think there are no vertex normals in SOPland.

  • Like 1
Link to comment
Share on other sites

And I by vertex normals meant point normals :) For me it seems very backward to calc point normals from primitive normals tho. Wouldnt the point normals just always point in the same direction? The points will just be in a flat plane so i dont see how they would contain enough info to create correct point normals.

Link to comment
Share on other sites

In fact there are vertex normals in Houdini and one of my favourite things is that you can adjust the cusping (with the vertex SOP), kinda like the facet SOP, but without splitting the polygons.

But vertex normals are not calculated by default, I don't think. Another guess is that it's there more for compatibility with other packages since mantra doesn't seem to need it.

Edited by rafaelfs
Link to comment
Share on other sites

Hmm, confusing thread. :)

1. How primitive normals are really derived / calculated. ?

If we're talking about polygons, from their vertex positions. I think it's something like the averaged normal computed from the cross product of each successive 2 edges. (Don't quote me on that :) ).

2. Do they qualify to be called as primitive attribute ?

When you turn on primitive normal display in the viewport, I think those are computed from the the polygon vertex positions. This happens even if you actually created a vector primitive attribute named "N". So no, not really an "attribute" in the same sense as a point/vertex attribute.

If prim() returns an attribute which exists on a primitive.

We can surely access them using prim("../path",$PR,"N",index). Does this make them an attribute?

No, because the prim() expression has special code which recognizes the name "N". In this case, if you happen to have created a primitive attribute named "N", then it will return those values (unlike the viewport primitive normal display option). However, if it can't find the attribute named "N", then it will compute one for you.

Of course, this is wildly inconsistent but convenient. It avoids having a separate expression "primnormal()" function.

  • Like 1
Link to comment
Share on other sites

And I by vertex normals meant point normals :) For me it seems very backward to calc point normals from primitive normals tho. Wouldnt the point normals just always point in the same direction? The points will just be in a flat plane so i dont see how they would contain enough info to create correct point normals.

Vertex normals are useful if you have something like a cube and you want flat shading. Put down a Box SOP, render it. Now append a Vertex SOP and set it to "Cursp Normal". Render again and compare.

Computed point normals (eg. by the Facet SOP) also known as "smooth" normals. This means that the point normal is an average of its adjacent polygon normals.

Link to comment
Share on other sites

Vertex normals are useful if you have something like a cube and you want flat shading. Put down a Box SOP, render it. Now append a Vertex SOP and set it to "Cursp Normal". Render again and compare.

Computed point normals (eg. by the Facet SOP) also known as "smooth" normals. This means that the point normal is an average of its adjacent polygon normals.

Yeah I know why Vertex Normals are necessary. Think my actual question got lost in translation somewhere.

Link to comment
Share on other sites

If we're talking about polygons, from their vertex positions. I think it's something like the averaged normal computed from the cross product of each successive 2 edges. (Don't quote me on that :) ).

This will not work for non-convex polygons. Normals computed at convex vertices and those at concave vertices will point in the opposite directions, so the resulting normal can point in either direction, regardless of how vertices are ordered.

I'm pretty sure Houdini uses Newell's method to compute polygon normals:

http://tog.acm.org/resources/GraphicsGems/gemsiii/newell.c

(also see here).

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...