PixarAnimationStudios / OpenSubdiv

An Open-Source subdivision surface library.
graphics.pixar.com/opensubdiv
Other
2.9k stars 561 forks source link

Feature Request: bidirectional crease to surface-edge distance functions #1160

Open loren-osborn opened 5 years ago

loren-osborn commented 5 years ago

I don’t know if this is appropriate for OpenSubDiv, but I thought this is at least a good place to ask.

I’m wanting to add an option (in Blender) to be able to set edge creases from a bevel radius approximation and vise versa. (The main benefit of this is that you may wish to set similar curvatures with diverse geometries. This would allow calculating the correct crease value for a given curvature for each edge.) Given the relative angle of the edge faces and the distance between the limit surface and the control edge (at the edge midpoint) calculating the bevel radius to approximate it is fairly straightforward. Unfortunately I’m having trouble determining the distance between the limit surface and the control edge from the edge crease, and vise versa.

For comparison, the rough algorithm to determine the approximate bevel radius from the distance i’m looking for:

I realize there are all sorts of edge cases where this has divide by zero issues and other range errors and discontinuities, and I think I neglected to say that one of the normals should have been negated, but this is intended to give the general idea.

TL;DR: how do I compute the crease value from the distance between the control edge (midpoint) and the SS limit surface, and vise versa?

jilliene commented 5 years ago

Filed as internal issue #OSD-303

loren-osborn commented 5 years ago

I think I can clarify this request some:

This request really boils down to two items:

  1. Given a SS control cage edge, with relevant local geometry, how do I calculate between a OSD crease value, and the distance between a point on the control cage (the midpoint of the edge) and the corresponding point on the OSD limit surface bidirectionally?
  2. Should computation of this relationship be added to the OSD API? (Or is it possibly already there?)

As I’m really new to OSD, I really don’t have any meaningful opinion on the second point. The main issue with the first point is really compatibility:

So, can you clarify which crease variation of the CC SS algorithm does OSD implement. From that I expect I can derive the relationship I’m looking for.

Thanks in advance.