Hello,
I’m working on supporting OptiX 9 features in my wrapper library.
OptiX 9 has introduced new curve types suffixed with rocaps.
Is there any reference code to compute normal (and tangent) vectors of these new curves?
Thanks,
Hello,
I’m working on supporting OptiX 9 features in my wrapper library.
OptiX 9 has introduced new curve types suffixed with rocaps.
Is there any reference code to compute normal (and tangent) vectors of these new curves?
Thanks,
Hey @shocker.0x15,
Great to hear you’re integrating OptiX 9! Yes, there are example functions for computing normals for Rocaps curve types. See optixHair.cu
in the optixHair
SDK sample, and look for the functions normalQuadraticRocaps
and normalCubicRocaps
.
The tangent directions are the same for Rocaps and the other curve types- for example you can use the same tangent computation for OPTIX_PRIMITIVE_TYPE_FLAGS_ROUND_CUBIC_BEZIER_ROCAPS
as for OPTIX_PRIMITIVE_TYPE_FLAGS_ROUND_CUBIC_BEZIER
, and same goes for the B-spline and CatmullRom curves types.
–
David.
Thanks for the quick response.
I can see very simple normal computation compared to non-rocaps variants.
Is this the exact formula or some approximation?
The example normals code in optixHair
for Rocaps represents an exact formula. The non-Rocaps curve types are using the Phantom intersector, and Phantom’s normal calculation is more complex, while Rocaps is very simple – hit point minus corresponding skeleton point, normalized.
The one thing to be aware of about Rocaps is that the curve parameter comes out of the intersector with medium-low precision, and you need to use the curve parameter (u
) to evaluate the skeleton point that corresponds to a hit point. There is a method to refine the u parameter before computing the normal so that it’s higher precision. The code for this is in the optixCurves
SDK sample, in optixCurves.cu
, in the functions tuneCurveParameter()
and capsuleTune()
.
Refining or fine tuning the curve parameter may be needed when viewing Rocaps in close-up, and/or possibly with curves with high curvature. I haven’t yet seen cases where it matters when Rocaps are viewed from a distance and and small & thin (less than 1 or 2 pixels wide) on screen. There might be such cases, I just haven’t seen them, and I have seen cases with production grade hair & fur scenes where the u parameter refinement is unnecessary. It’s enough extra compute that it’s probably worth using the parameter fine tuning judiciously and sparingly. I wish I had a simple concrete rule for when to use tuning and when not to, but if you try it, I would love to hear about your experience with it. There is discussion of this refinement process in the Rocaps paper, and a live ShaderToy demo where you can get a sense for what happens when you disable parameter fine-tuning. In the ShaderToy demo, you can change USE_CAPSULE_NORMALS
to toggle parameter fine-tuning. Capsule normals on means no fine tuning, and capsule normals off means use fine tuning to create more coherent strand normals. In the default view, the artifacts with tuning off might take a minute to spot - look for small wiggles in the texture, or drag the control points to give the curve more curvature. You can also set TEXTURING
to 0 in order to see the actual banding artifacts in the normals when rotating to move the specular highlight around (or look at Fig. 7 in the paper, it also shows normal banding).
–
David.
Thanks for the detailed and quick response again!
I simply added rocaps variants to a sample code in my library to demonstrate curves, where colors visualize normal vectors.
First Row: Linear, Quadratic, Cubic, Catmull-Rom, Cubic Bezier, Ribbon (from left to right)
Second Row: Quadratic, Cubic, Catmull-Rom, Cubic Bezier (rocaps variants)
You can see normal vectors on the curves in the second row exhibit some artifacts.
I don’t know if the cause is missing of the parameter tuning you mentioned or just my mistake yet.
I’ll take a look into the tuning.
Thanks!
Ah no, jpeg compression by this forum makes the artifact hard to see.
This is a close-up of the quadratic B-spline rocaps
To me that does look like low-precision u parameter artifacts that the fine-tuning will resolve… if you want to render curves this large and need the normals to be artifact-free. It’ll be much harder to notice the banding with fur or hair, of course. One way to think about it is that Rocaps with a low-precision curve parameter isn’t any worse than the “quantization” of normals we get when using linear curves, and linear curves are good enough for production quality hair when sampled adequately and viewed from a distance. If any quantization is visible, I believe that increasing the sampling rate will work in both cases, while Rocaps has the option to fine-tune (use more compute) as an alternative to subdividing (using more memory).
–
David.
Great! Thanks for the follow-up, it’s good to know it works. If you have any suggestions about better places to put or to advertise the normal and fine-tuning utility functions, we’re happy to try to improve the packaging.
–
David.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.