1RTC_GEOMETRY_TYPE_SUBDIVISEImObNr(e3e)Ray Tracing KerRnTeCl_sGE3OMETRY_TYPE_SUBDIVISION(3)
2
3
4
5 NAME
6 RTC_GEOMETRY_TYPE_SUBDIVISION - subdivision geometry type
7
8 SYNOPSIS
9 #include <embree3/rtcore.h>
10
11 RTCGeometry geometry =
12 rtcNewGeometry(device, RTC_GEOMETRY_TYPE_SUBDIVISION);
13
14 DESCRIPTION
15 Catmull-Clark subdivision meshes are supported, including support for
16 edge creases, vertex creases, holes, non-manifold geometry, and
17 face-varying interpolation. The number of vertices per face can be in
18 the range of 3 to 15 vertices (triangles, quadrilateral, pentagons,
19 etc).
20
21 Subdivision meshes are created by passing RTC_GEOMETRY_TYPE_SUBDIVISION
22 to the rtcNewGeometry function. Various buffers need to be set by the
23 application to set up the subdivision mesh. See rtcSetGeometryBuffer
24 and rtcSetSharedGeometryBuffer for more details on how to set buffers.
25 The face buffer (RTC_BUFFER_TYPE_FACE type and RTC_FORMAT_UINT format)
26 contains the number of edges/indices of each face (3 to 15), and the
27 number of faces is inferred from the size of this buffer. The index
28 buffer (RTC_BUFFER_TYPE_INDEX type) contains multiple (3 to 15) 32-bit
29 vertex indices (RTC_FORMAT_UINT format) for each face, and the number
30 of edges is inferred from the size of this buffer. The vertex buffer
31 (RTC_BUFFER_TYPE_VERTEX type) stores an array of single precision x, y,
32 z floating point coordinates (RTC_FORMAT_FLOAT3 format), and the number
33 of vertices is inferred from the size of this buffer.
34
35 Optionally, the application may set additional index buffers using dif‐
36 ferent buffer slots if multiple topologies are required for face-vary‐
37 ing interpolation. The standard vertex buffers (RTC_BUFFER_TYPE_VER‐
38 TEX) are always bound to the geometry topology (topology 0) thus use
39 RTC_BUFFER_TYPE_INDEX with buffer slot 0. User vertex data interpola‐
40 tion may use different topologies as described later.
41
42 Optionally, the application can set up the hole buffer (RTC_BUF‐
43 FER_TYPE_HOLE) which contains an array of 32-bit indices (RTC_FOR‐
44 MAT_UINT format) of faces that should be considered non-existing in all
45 topologies. The number of holes is inferred from the size of this buf‐
46 fer.
47
48 Optionally, the application can fill the level buffer (RTC_BUF‐
49 FER_TYPE_LEVEL) with a tessellation rate for each of the edges of each
50 face. This buffer must have the same size as the index buffer. The
51 tessellation level is a positive floating point value (RTC_FORMAT_FLOAT
52 format) that specifies how many quads along the edge should be generat‐
53 ed during tessellation. If no level buffer is specified, a level of 1
54 is used. The maximally supported edge level is 4096, and larger levels
55 are clamped to that value. Note that edges may be shared between (typ‐
56 ically 2) faces. To guarantee a watertight tessellation, the level of
57 these shared edges should be identical. A uniform tessellation rate
58 for an entire subdivision mesh can be set by using the rtcSetGeome‐
59 tryTessellationRate function. The existence of a level buffer has
60 precedence over the uniform tessellation rate.
61
62 Optionally, the application can fill the sparse edge crease buffers to
63 make edges appear sharper. The edge crease index buffer (RTC_BUF‐
64 FER_TYPE_EDGE_CREASE_INDEX) contains an array of pairs of 32-bit vertex
65 indices (RTC_FORMAT_UINT2 format) that specify unoriented edges in the
66 geometry topology. The edge crease weight buffer (RTC_BUF‐
67 FER_TYPE_EDGE_CREASE_WEIGHT) stores for each of these crease edges a
68 positive floating point weight (RTC_FORMAT_FLOAT format). The number
69 of edge creases is inferred from the size of these buffers, which has
70 to be identical. The larger a weight, the sharper the edge. Specify‐
71 ing a weight of infinity is supported and marks an edge as infinitely
72 sharp. Storing an edge multiple times with the same crease weight is
73 allowed, but has lower performance. Storing an edge multiple times
74 with different crease weights results in undefined behavior. For a
75 stored edge (i,j), the reverse direction edges (j,i) do not have to be
76 stored, as both are considered the same unoriented edge. Edge crease
77 features are shared between all topologies.
78
79 Optionally, the application can fill the sparse vertex crease buffers
80 to make vertices appear sharper. The vertex crease index buffer
81 (RTC_BUFFER_TYPE_VERTEX_CREASE_INDEX), contains an array of 32-bit ver‐
82 tex indices (RTC_FORMAT_UINT format) to specify a set of vertices from
83 the geometry topology. The vertex crease weight buffer (RTC_BUF‐
84 FER_TYPE_VERTEX_CREASE_WEIGHT) specifies for each of these vertices a
85 positive floating point weight (RTC_FORMAT_FLOAT format). The number
86 of vertex creases is inferred from the size of these buffers, and has
87 to be identical. The larger a weight, the sharper the vertex. Speci‐
88 fying a weight of infinity is supported and makes the vertex infinitely
89 sharp. Storing a vertex multiple times with the same crease weight is
90 allowed, but has lower performance. Storing a vertex multiple times
91 with different crease weights results in undefined behavior. Vertex
92 crease features are shared between all topologies.
93
94 Subdivision modes can be used to force linear interpolation for parts
95 of the subdivision mesh; see rtcSetGeometrySubdivisionMode for more de‐
96 tails.
97
98 For multi-segment motion blur, the number of time steps must be first
99 specified using the rtcSetGeometryTimeStepCount call. Then a vertex
100 buffer for each time step can be set using different buffer slots, and
101 all these buffers have to have the same stride and size.
102
103 Also see tutorial [Subdivision Geometry] for an example of how to cre‐
104 ate subdivision surfaces.
105
106 Parametrization
107 The parametrization for subdivision faces is different for quadrilater‐
108 als and non-quadrilateral faces.
109
110 The parametrization of a quadrilateral face uses the first vertex p0 as
111 base point, and the vector p1 - p0 as u-direction and p3 - p0 as v-di‐
112 rection.
113
114 The parametrization for all other face types (with number of vertices
115 not equal 4), have a special parametrization where the subpatch ID n
116 (of the n-th quadrilateral that would be obtained by a single subdivi‐
117 sion step) and the local hit location inside this quadrilateral are en‐
118 coded in the UV coordinates. The following code extracts the sub-patch
119 ID i and local UVs of this subpatch:
120
121 unsigned int l = floorf(0.5f*U);
122 unsigned int h = floorf(0.5f*V);
123 unsigned int i = 4*h+l;
124 float u = 2.0f*fracf(0.5f*U)-0.5f;
125 float v = 2.0f*fracf(0.5f*V)-0.5f;
126
127 This encoding allows local subpatch UVs to be in the range [-0.5,1.5[
128 thus negative subpatch UVs can be passed to rtcInterpolate to sample
129 subpatches slightly out of bounds. This can be useful to calculate de‐
130 rivatives using finite differences if required. The encoding further
131 has the property that one can just move the value u (or v) on a sub‐
132 patch by adding du (or dv) to the special UV encoding as long as it
133 does not fall out of the [-0.5,1.5[ range.
134
135 To smoothly interpolate vertex attributes over the subdivision surface
136 we recommend using the rtcInterpolate function, which will apply the
137 standard subdivision rules for interpolation and automatically takes
138 care of the special UV encoding for non-quadrilaterals.
139
140 Face-Varying Data
141 Face-varying interpolation is supported through multiple topologies per
142 subdivision mesh and binding such topologies to vertex attribute buf‐
143 fers to interpolate. This way, texture coordinates may use a different
144 topology with additional boundaries to construct separate UV regions
145 inside one subdivision mesh.
146
147 Each such topology i has a separate index buffer (specified using
148 RTC_BUFFER_TYPE_INDEX with buffer slot i) and separate subdivision mode
149 that can be set using rtcSetGeometrySubdivisionMode. A vertex at‐
150 tribute buffer RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE bound to a buffer slot
151 j can be assigned to use a topology for interpolation using the rtcSet‐
152 GeometryVertexAttributeTopology call.
153
154 The face buffer (RTC_BUFFER_TYPE_FACE type) is shared between all
155 topologies, which means that the n-th primitive always has the same
156 number of vertices (e.g. being a triangle or a quad) for each topolo‐
157 gy. However, the indices of the topologies themselves may be differ‐
158 ent.
159
160 EXIT STATUS
161 On failure NULL is returned and an error code is set that can be
162 queried using rtcGetDeviceError.
163
164 SEE ALSO
165 [rtcNewGeometry]
166
167
168
169 RTC_GEOMETRY_TYPE_SUBDIVISION(3)