Notifications
Clear all

[Closed] Get (explicit) normal at arbitrary mesh location?

Any suggestions how to efficiently get the surface normal at an arbitrary point on a mesh?

More precisely: Given a mesh, a face index and a barycentric coordinate, I would like to get the surface normal at that point, taking explicit normals into account.

So far, I have been using the Edit_Normals modifier and it’s GetNormal() / ConvertVertexSelection() methods to get normals for triangle vertices, and then to interpolate according to the barycentric coordinates, but Edit_Normals needs the Modify Tab to be active, and the ConvertVertexSelection() method is VERY slow…

Any thoughts?

Thanks!
– MartinB

8 Replies
2 Replies
(@denist)
Joined: 11 months ago

Posts: 0

it would be better to give more details about your pipeline. to bake normals to a uv channel sounds reasonable for me

(@martinb)
Joined: 11 months ago

Posts: 0

I want to get surface normals at specific points from a high resolution mesh. Baking a normal map would require calculating UVs, then baking at fairly high resolution, just to query some points for their normals.

I was hoping for something like

getNormal theMesh 123 [0.1, 0.8, 0.1]

(where 123 would be the face index and [0.1, 0.8, 0.1] the barycentrics); unfortunately, the standard getNormal function does not take explicit normals into account.

– MartinB

If your sampling a lot of points it might become quicker to bake a normal map and sample using bary
-to-UV coords.

Good point, thanks! But I’d rather avoid the baking step.

Any others?
– MartinB

the vertex colour interpolater gives thebest results copy the normals to a map channel the retrieve the barycentric result from the map channel

1 Reply
(@martinb)
Joined: 11 months ago

Posts: 0

To copy the normals to some other channel, I have to retrieve them first, which is the slow part in what I am doing already. That’s why I am searching for a different way to get explicit normal information for a given point on a surface.

I’d settle with an efficient way to get the normal data for a vertex and then interpolate

In that thread, you (?) mention “if you copy the terrain normals to a map channel using the function Denis kindly posted” – what function is that? Maybe that’s what I need.

Thanks!
– MartinB

theres a link to it in the other thread

1 Reply
(@martinb)
Joined: 11 months ago

Posts: 0

Thanks, I’ll go searching then.

Edit: Is this the function you are referring to?

– MartinB