View Full Version : Visualization of Gaussian curvature for NURBS surface.

Alexanov

01-12-2016, 06:08 AM

Hello everyone,

I need to visualize Gaussian curvature of NURBS surface like a colored surface. What is a best way to do it?

Should I use evaluators for that? Can I evaluate not just point on the surface and normal vector, but also tangent vectors?

Surfing in Internet for many days with no results at all.

carsten neumann

01-12-2016, 07:51 AM

OpenGL is a low level rendering API, it does not have functionality to compute geometric properties like curvature and only handles simple primitives: triangles, lines, and points - not more complex surface representations like NURBS. There are the evaluators inside GLU that can be used to turn a NURBS surface into a triangle based representation - off hand I'm not sure if it has support to compute curvature.

Assuming you have found a way to compute curvature at the vertices of the triangle approximation of your NURBS surface, you can store that as a vertex attribute and pass it to your shaders just like any other attribute (position, normal, texture coordinates) - in your shader you can turn the curvature value into a color (through some formula or by sampling a look up texture). Alternatively (in particular if you are not using shaders) you can turn the curvature value into a color on the CPU and pass that color as (secondary) color attribute to OpenGL.

GClements

01-12-2016, 10:39 AM

I need to visualize Gaussian curvature of NURBS surface like a colored surface. What is a best way to do it?

Should I use evaluators for that? Can I evaluate not just point on the surface and normal vector, but also tangent vectors?

If you can get the control points of a Bezier patch (i.e. the arguments to glMap2()), you can convert those to the coefficients of the numerator and denominator polynomials, differentiate those with respect to u and v, then convert the coefficients of the derivatives back to the control points for a Bezier patch. Thus you can generate a Bezier patch for the tangents (and second derivatives if needed), and also for the normal (which is the cross product of the tangents).

For a polynomial Bezier patch (where the control points all have the same W), the derivatives have the same or lower degree as the original. E.g. a cubic patch has coefficients up to u^3*v*3. The derivative w.r.t. u has coefficients up to u^2*v^3 while the derivative w.r.t. v has coefficients up to u^3*v^2 The normal will have derivatives up to u^5*v^5.

However, NURBS surfaces use rational patches, and for a rational Bezier patch (where control points have different W values and so X/W etc is the ratio of polynomials), the derivatives have a higher degree than the original because of the quotient rule:

d(g/h)/dx = (h*g' - g*h')/(h^2).

For a cubic patch, h and g both contain terms up to u^3*v^3. Differentiating w.r.t. u means that g' and h' will have terms up to u^2*v^3 so both h*g' and g*h' will have terms up to u^5*v^6 while h^2 has terms up to u^6*v^6, so the resulting patch will have degree 6 (order 7, i.e. 7x7=49 control points). The normal and second derivative will have degree 12 (order 13), but OpenGL only requires support for a maximum order of 8.

Depending upon what you want to do, tessellation shaders (which require OpenGL 4) may be of use.

Alexanov

01-12-2016, 11:29 AM

Alternatively (in particular if you are not using shaders) you can turn the curvature value into a color on the CPU and pass that color as (secondary) color attribute to OpenGL.

That's probably simplest way for me. Thank you for help.

Powered by vBulletin® Version 4.2.5 Copyright © 2018 vBulletin Solutions Inc. All rights reserved.