Render Path-Traced Hair in Real Time with NVIDIA GeForce RTX 50 Series GPUs
Hardware support for ray tracing triangle meshes was introduced as part of
NVIDIA RTX
in 2018. But ray tracing for hair and fur has remained a compute-intensive problem that has been difficult to further accelerate. That is, until now.
NVIDIA GeForce 50 Series GPUs
include a major advancement in the acceleration of ray tracing for hair and fur: hardware ray tracing support for the linear swept sphere (LSS) primitive. This new primitive is a big step toward rendering high-quality digital humans in real time. The range of applications for realistic human rendering is ever-increasing and includes AI avatars, film and game characters, graphics research, high-performance scientific computing applications, synthetic data generation, and more.
LSS is available today in
NVIDIA OptiX
and in the
NVAPI SDK
. There are advanced examples of real-time hair using LSS with physically based shading models included in the
RTX Character Rendering
SDK which is part of
NVIDIA RTX Kit
. RTX Kit is a suite of neural rendering technologies to ray trace games with AI, render scenes with immense geometry, and create game characters with photorealistic visuals. RTX Kit was introduced during the
GeForce RTX 50 Series launch
.
What is the LSS primitive?
The LSS primitive is a thick, round 3D line with varying radii. Multiple linear swept spheres can be chained together to build 3D curves, sharing vertices where they overlap, similar to how triangles are used to build 3D surfaces. LSS is shaped like a cylindrical or conical tube with spheres optionally capping either end.
Figure 1. The shapes of a linear swept sphere
If the two endpoints are overlapped so the line has no length, then the line swept sphere becomes just a regular sphere. This can be used for hardware-accelerated particle rendering. To make spheres convenient and memory efficient, this special case of LSS for spheres is being exposed as a separate first-class sphere primitive.
Linear swept spheres aren’t normally meant to be shown in magnified close-up, as in Figure 1. Rather, they are intended to be small onscreen, maybe one pixel wide, give or take. When multiple linear swept spheres are chained together into strands and the camera is pulled back a bit, the sharp angles melt away and these thick lines become thin smooth curves.
Figure 2. Linear swept spheres appear smooth from a distance
LSS indexing
LSS comes with two indexing modes: an explicit list mode, and a semi-implicit mode called successive implicit. In list mode, each segment is specified explicitly using a pair of indices into your vertex buffer. In successive implicit mode, line segments are specified using one explicit index and one implicit index, where the second point is assumed to be the next vertex in the vertex buffer.
Because successive vertices in memory are common and convenient, successive implicit mode is an easy way to save 50% of the memory in the index buffer. Figure 3 shows an example where an explicit index buffer would contain [0,1,1,2,2,3,4,5,5,6]. With successive implicit indexing, the index buffer would be [0,1,2,4,5].
Figure 3. An example of two strands with vertex indices
Rendering strand-based curves using legacy hardware
For someone already using the CUDA-based ray tracing API framework
NVIDIA OptiX
, LSS is already available as the default linear curve type, and works on all GPUs that OptiX supports. The OptiX version of LSS automatically uses a software fallback on GPUs prior to NVIDIA Blackwell GPUs, and the new hardware-accelerated primitive on GeForce RTX 50 Series GPUs, without needing any code changes. If you’re not using OptiX, chances are you’ll need to use an alternative primitive.
When it comes to high performance, tessellated curves are the next best thing to LSS. One option is camera-facing or ray-facing quads. Ray-facing quads have a relatively low memory footprint, though they may need to be oriented during every frame of animation (either hair motion or camera motion).
Disjoint Orthogonal Triangle Strips (DOTS) provide a clever solution for tessellating curves that enables viewing from any angle without having to reorient the triangles every frame to face the camera. This way, if you render static curves, you won’t need to rebuild your bounding volume hierarchy (BVH) when the camera or hair moves. Because triangles have broad support, DOTS can take advantage of existing RTX hardware.
Anyone who wants to use LSS on GeForce RTX 50 Series GPUs can still support ray traced strands on older GPUs using DOTS. Some hair examples using both DOTS and LSS will be available as part of the
RTX Character Rendering SDK
that implements path tracing of realistic human hair and skin.
One advantage of LSS is that the geometry is naturally round, making it easy to shade and easy to avoid self-intersection when casting shadow and reflection rays. Tessellated curves like DOTS will typically need to have the geometric normal overridden by a custom shading normal, as shown in Figure 4. When rounded shading normals are used, then the appearance of DOTS can be similar to or even indistinguishable from the appearance of curves made out of linear swept spheres.
Figure 4. Disjoint Orthogonal Triangle Strips can match the appearance of linear swept spheres when shading normals are used
Benefits of using LSS
Some of the existing approaches to real-time hair include:
Textured cards
Ray-facing quads, tessellated tubes, orthogonal quads (DOTS)
Software higher-order curve primitives (cubic Bezier, for example)
Textured cards have been a good way to achieve a reasonable enough quality for hair in games on a very light budget. However, this kind of setup is extremely limited and does not allow much room for simulating or animating hair. Since a textured card has multiple strands per card, there is no control over individual strands, by design. Strand-based approaches are far more controllable and flexible, and this is one reason why strands are clearly the future of real-time hair rendering as the world’s hardware improves over time.
Figure 5. Rendering animated hair on humans is about 2x faster with LSS compared to DOTS, while also requiring about 5x less VRAM to store the geometry
Since triangles are well supported in hardware these days, tessellating curves into triangles (tubes, quads, DOTS) can be very fast to render. The downside is that tessellating takes time and can use a lot of memory. A quad requires four vertices, though two vertices can be shared with the next successive neighboring quad in the strand. So on average, camera facing quads will cost at least two vertices per strand segment. If tubes or DOTS are used, then the strand will end up with more than two vertices per segment on average.
LSS only needs one vertex per strand segment on average, so it uses much less memory than tessellated curves, while achieving higher rendering speeds. And LSS is of course much faster than software higher-order curve primitives, like the cubic B-spline. Depending on the needs and tolerance for quality, this extra performance may come with a memory tradeoff compared to cubic curves, for example, if more vertices are needed for smoothness.
What else can LSS be used for?
The RTX version of the linear swept sphere was designed mainly with hair and fur in mind, but it can be used for other applications including particles, molecular models, wireframe rendering, font and path rendering, and whatever else you can imagine.
Figure 6. Alternative uses of linear swept spheres include wireframe (left), particle rendering (center), and molecular models (right). Image credits: Bay Raitt, Valve; Stanford Dark Sky Simulations; University of Illinois
Get started with LSS
RT Cores in the NVIDIA GeForce RTX 50 Series GPUs introduce hardware support for a new primitive called linear swept spheres (LSS). LSS is a round 3D line primitive with varying thickness, enabling flexible approximation of various strand types. As a special case of LSS, the GeForce RTX 50 Series GPUs hardware primitive also supports spheres directly (without a swept linear segment), which is useful for applications like particle systems.
Rendering animated hair on humans is about 2x faster with LSS compared to DOTS, while also requiring about 5x less VRAM to store the geometry. This is similar for other common use cases. With LSS on GeForce RTX 50 Series GPUs and DOTS for earlier GPUs, there is now a way to get the highest possible hair ray tracing performance on all RTX GPUs.
When ray tracing in CUDA, LSS is currently available in
OptiX
. For DirectX, API for LSS can be found starting in the R570 version of the
NVAPI SDK
. Vulkan developers will be interested in the
Vulkan LSS extension
.
For examples of physically based hair rendering, check out the
RTX Character Rendering SDK
. To learn more about the latest AI and rendering technologies, check out the
NVIDIA RTX Kit
. Join the conversation about LSS on the
OptiX NVIDIA Developer Forum
.
使用 NVIDIA GeForce RTX 50 系列 GPU 实时渲染路径追踪头发
2018 年，
NVIDIA RTX
引入了对光线追踪三角形网格的硬件支持。但是，头发和毛皮的光线追踪仍然是一个计算密集型问题，一直难以进一步加速。那就是，直到现在。
NVIDIA GeForce 50 系列 GPUs
在加速毛发和毛皮光线追踪方面取得了重大进步：硬件光线追踪支持线性扫描球体 (LSS) 基元。这种新基元是向实时渲染高质量数字人迈出的一大步。逼真的人类渲染的应用领域与日俱增，包括 AI 虚拟形象、电影和游戏角色、图形研究、高性能科学计算应用、合成数据生成等。
LSS 现已在
NVIDIA OptiX
和
NVAPI SDK
中提供。
RTX Character Rendering SDK
是
NVIDIA RTX Kit
的一部分，其中包含使用基于物理性质的着色模型的 LSS 的高级实时毛发示例。RTX Kit 是一套神经渲染技术，可利用 AI 对游戏进行光线追踪、渲染具有宏大几何图形的场景，以及使用逼真视觉效果创建游戏角色。RTX Kit 在
GeForce RTX 50 Series
发布时推出。
什么是 LSS 基元？
LSS 基元是一条具有不同半径的粗而圆的 3D 线。可以将多个线性扫描球体链接在一起以构建 3D 曲线，在它们重叠的位置共享顶点，这与使用三角形构建 3D 表面的方式类似。LSS 的形状类似圆柱形或锥形管，球体的两端均可选择覆盖。
图 1. 线性扫描球体的形状
如果两个端点重叠，因此直线没有长度，则直线扫描球体仅会成为常规球体。这可用于硬件加速粒子渲染。为了方便球体和提高内存效率，我们将球体 LSS 的这种特殊情况作为单独的一级球体基元公开。
通常情况下，线性扫描球体并不像图 1 那样以放大镜头显示。相反，它们的屏幕尺寸较小，可能有 1 像素宽，可以取或取。当多个线性扫描球体被链式连接成多条链路，并将摄像头稍微往后拉时，清晰的角度会消失，这些粗壮的线条会变成纤细的平滑曲线。
图 2、线性扫描球体在一定距离下显得光滑
LSS 索引
LSS 提供两种索引模式：显式列表模式和称为连续隐式的半隐式模式。在列表模式下，系统会在顶点缓冲区中使用一对索引显式指定每个片段。在连续隐式模式下，使用一个显式索引和一个隐式索引指定线段，其中第二个点假定为顶点缓冲区中的下一个顶点。
由于内存中的连续顶点十分常见且方便，因此可以通过连续隐式模式在索引缓冲区中轻松节省 50% 的内存。图 3 显示了显式索引缓冲区包含 [0,1,1,2,2,3,4,5,5,6] 的示例。通过连续的隐式索引，索引缓冲区将为 [0,1,2,4,5]。
图 3. 带有顶点索引的两条线的示例
使用传统硬件渲染基于链的曲线
对于已经使用基于 CUDA 的光线追踪 API 框架
NVIDIA OptiX
的用户，LSS 已作为默认线性曲线类型提供，并且适用于 OptiX 支持的所有 GPU。OptiX 版本的 LSS 自动使用 NVIDIA Blackwell GPU 之前的 GPU 上的软件回退，以及 GeForce RTX 50 Series GPU 上的新硬件加速基元，而无需更改任何代码。如果您未使用 OptiX，则可能需要使用替代基元。
说到高性能，细分曲线是 LSS 的下一个最佳选择。其中一个选项是摄像头对焦或光线对焦四边形。尽管在动画的每一帧（毛发运动或相机运动）中，面向光线的四边形的显存占用相对较小，但其显存占用相对较小。
不交正交三角形条 (DOTS) 提供了一个巧妙的曲线细分解决方案，支持从任何角度进行查看，而无需重新调整每帧三角形的方向以面向摄像头。这样，如果渲染静态曲线，则无需在相机或头发移动时重建包围盒层次结构 (BVH)。三角形拥有广泛支持，因此 DOTS 可以利用现有的 RTX 硬件。
如果您想在 GeForce RTX 50 系列 GPUs 上使用 LSS，仍然可以使用 DOTS 在较旧的 GPU 上支持光线追踪链。一些同时使用 DOTS 和 LSS 的毛发示例将作为
RTX Character Rendering SDK
的一部分提供，该 SDK 可实现逼真的人类头发和皮肤的路径追踪。
LSS 的一个优点是几何体自然呈圆形，因此在投射阴影和反射光线时，很容易着色，并且很容易避免自交。像 DOTS 这样的细分曲线通常需要使用自定义着色法线覆盖几何法线，如图 4 所示。当使用圆周着色法线时，DOTS 的外观可能与由线性扫描球体构成的曲线相似，甚至无法区分。
图 4、在使用着色法线时，不交接正交三角形条可以与线性扫描球体的外观相匹配
使用 LSS 的优势
一些现有的实时头发处理方法包括：
纹理卡
面向光线的四边形，镶嵌管，正交四边形 (DOTS)
软件高阶曲线基元 (例如 cubic Bezier)
纹理卡是在预算有限的情况下，在游戏中实现合理的头发质量的好方法。但是，这种设置非常有限，没有足够的空间用于模拟头发或制作头发动画。由于一张纹理卡的每张卡有多个链，因此根据设计，无法控制单个链。基于链的方法更具可控性和灵活性，这也是为什么链显然是实时头发渲染的未来，因为世界的硬件会随着时间的推移而改进。
图 5、与 DOTS 相比，使用 LSS 在人类身上渲染动画毛发的速度大约快 2 倍，同时存储几何图形所需的 VRAM 也减少了大约 5 倍
由于硬件目前已大力支持三角形，因此可以非常快速地将曲线细分为三角形（管、四边形、DOTS）。缺点是细分需要时间，并且会占用大量内存。一个四边形需要四个顶点，不过两个顶点可以与链中的下一个相邻四边形共享。因此，面向四边形的摄像头平均每个链段至少会耗费两个顶点。如果使用管或 DOTS，则链的每个部分最终平均将包含两个以上的顶点。
LSS 的每个链段平均只需要一个顶点，因此与细分曲线相比，它使用的内存更少，同时实现了更高的渲染速度。当然，LSS 比软件高阶曲线基元 (如 cubic B-spline) 的速度要快得多。根据对质量的需求和容差，与 cubic curves 相比，这种额外的性能可能会带有内存权衡，例如，如果需要更多的顶点来实现平滑度。
LSS 还有哪些其他用途？
RTX 版本的线性扫描球体在设计时主要考虑了毛发和毛皮，但它可以用于其他应用，包括粒子、分子模型、线框渲染、字体和路径渲染以及您可以想象的其他任何应用。
图 6、线性扫描球体的其他用途包括线框 (左)、粒子渲染 (中心) 和分子模型 (右)。图片来源：Bay Raitt，Valve；Stanford Dark Sky Simulations；University of Illinois
开始使用 LSS
NVIDIA GeForce RTX 50 系列 GPU 中的 RT Cores 为一种称为线性扫描球体 (LSS) 的新基元引入了硬件支持。LSS 是一种厚度不同的 3D 圆线基元，支持灵活逼近各种链类型。作为 LSS 的一种特殊情况，GeForce RTX 50 系列 GPU 硬件基元还直接支持球体 (不包含扫描线性分割)，这对于像粒子系统这样的应用非常有用。
与 DOTS 相比，使用 LSS 在人类身上渲染动画毛发的速度大约快 2 倍，同时存储几何图形所需的 VRAM 也减少了大约 5 倍。这与其他常见用例类似。借助 GeForce RTX 50 系列 GPUs 上的 LSS 和早期 GPUs 上的 DOTS，现在可以在所有 RTX GPUs 上获得尽可能高的毛发光线追踪性能。
在 CUDA 中进行光线追踪时，LSS 目前可在
OptiX
中使用。对于 DirectX，可以从 R570 版本的
NVAPI SDK
开始找到适用于 LSS 的 API。Vulkan 开发者可能会对
Vulkan LSS 扩展
感兴趣。
有关基于物理效果的头发渲染示例，请查看
RTX Character Rendering SDK
。如需详细了解最新的 AI 和渲染技术，请查看
NVIDIA RTX Kit
。在
OptiX NVIDIA 开发者论坛
上加入有关 LSS 的对话。