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

Started by
17 comments, last by Nik02 19 years, 5 months ago
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
Advertisement
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.

Niko Suni

thanks Nik02

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

thanks
any body have visible example or tutorial
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
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

Niko Suni

Quote:Original post by Nik02
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.
-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)
The Trouble With Robots - www.digitalchestnut.com/trouble
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.
The Trouble With Robots - www.digitalchestnut.com/trouble
Thanks Geoffrey I am interested your method please explain your old code thank you very much for helping me.
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]

Niko Suni

This topic is closed to new replies.

Advertisement