# how to estimate curvature on 3D mesh by using HLSL shaders?

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

## Recommended Posts

Hi all I want to know how to implement curvature shader , in other words how to estimate principle curvature on 3D triangular mesh. I shall be very grateful to you if could you give ideac Thanks

##### Share on other sites
If you want to calculate local vertex curvature, you need to take into account it's neigbours' relative positions. This cannot be done in purely shader logic, since a vertex shader has only the current vertex available as input data. However, once you have calculated the curvatures in your program, you can save them as per-vertex data and feed them to the shader that way.

##### Share on other sites
thanks Nik02

Thank you very much for your idea I am new for 3D world.... any body have visible example or tutorial

thanks

##### Share on other sites
any body have visible example or tutorial

##### Share on other sites
You haven't really provided enough information for anyone to give you a sample because we don't know what you're trying to do.

I know that if you want to compute smooth normals for a mesh (i.e. not just use the normal of the triangle the vertex is part of) you need to take into account the "curvature" of the area around the vertex.

The algorithm would go something like this:
for every vertex in the mesh{  for each triangle that uses this vertex  {    compute the normal of this triangle (use a cross product)  }  Normal of this vertex is the average of the normals of all the triangles that use the vertex.}

This will give your mesh a more "curved" look when it is illuminated because the normals are not just from the triangle faces; they are smoothed out over the surface of the mesh.

If this isn't what you're looking for, can you give more detail?

neneboricua

##### Share on other sites
Incidentally, curvature (AKA derivative of radius) can be calculated in a similar way that neneboricua explains the generation of smooth normals.

For each triangle sharing a vertex, compute the cross products to establish triangle normals. Then take the sum of [each triangles normal]/[triangle size] dot [original vertex normal] and divide the sum by the number of triangles. The resulting number, as far as I can tell, should represent the absolute weighted curvature at the vertex point.

To determine whether the curvature is convex or concave (the sign of curvature), you should analyze the directions of each neighbor triangle normals in relation to the normal of the vertex you are calculating the curvature for, and take the dominant side as the result.

This theory was formed during writing this post - take it as an untested concept :)

-Nik

##### Share on other sites
Quote:
 Original post by Nik02For each triangle sharing a vertex, compute the cross products to establish triangle normals. Then take the sum of [each triangles normal]/[triangle size] dot [original vertex normal] and divide the sum by the number of triangles. The resulting number, as far as I can tell, should represent the absolute weighted curvature at the vertex point. -Nik

I did something similar once, and I think something like this will work well. I don't see the logic behind dividing by the triangle size though - I'd weight according to the angle made by the triangle at that point, instead.

On a practical note, make sure you're normals are normalized! (i.e. have length one)

##### Share on other sites
I've had a look at my old code, and what I actually did is slightly different. It's still based on cross and dot products, and a weighted average, but the vectors involved are different. I'll try to explain it if you're interested.

##### Share on other sites
Thanks Geoffrey I am interested your method please explain your old code thank you very much for helping me.

##### Share on other sites
I must've thought about the triangle area contribution when I said "triangle size". However, the further the other vertices are from the current vertex, the less effect they should have towards the curvature.

Geoffrey, I'd also like very much to read about how you implemented a solution to this problem [smile]

1. 1
2. 2
3. 3
Rutin
22
4. 4
frob
18
5. 5

• 33
• 13
• 10
• 10
• 11
• ### Forum Statistics

• Total Topics
632566
• Total Posts
3007112

×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!