rtcore_geometry.isph 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. // ======================================================================== //
  2. // Copyright 2009-2017 Intel Corporation //
  3. // //
  4. // Licensed under the Apache License, Version 2.0 (the "License"); //
  5. // you may not use this file except in compliance with the License. //
  6. // You may obtain a copy of the License at //
  7. // //
  8. // http://www.apache.org/licenses/LICENSE-2.0 //
  9. // //
  10. // Unless required by applicable law or agreed to in writing, software //
  11. // distributed under the License is distributed on an "AS IS" BASIS, //
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
  13. // See the License for the specific language governing permissions and //
  14. // limitations under the License. //
  15. // ======================================================================== //
  16. #ifndef __EMBREE_GEOMETRY_ISPH__
  17. #define __EMBREE_GEOMETRY_ISPH__
  18. /*! \ingroup embree_kernel_api_ispc */
  19. /*! \{ */
  20. /*! invalid geometry ID */
  21. #define RTC_INVALID_GEOMETRY_ID ((uniform unsigned int)-1)
  22. /*! maximal number of time steps */
  23. #define RTC_MAX_TIME_STEPS 129
  24. /*! maximal number of user vertex buffers */
  25. #define RTC_MAX_USER_VERTEX_BUFFERS 16
  26. /*! maximal number of index buffers for subdivision surfaces */
  27. #define RTC_MAX_INDEX_BUFFERS 16
  28. /*! \brief Specifies the type of buffers when mapping buffers */
  29. enum RTCBufferType
  30. {
  31. RTC_INDEX_BUFFER = 0x01000000,
  32. RTC_INDEX_BUFFER0 = 0x01000000,
  33. RTC_INDEX_BUFFER1 = 0x01000001,
  34. RTC_VERTEX_BUFFER = 0x02000000,
  35. RTC_VERTEX_BUFFER0 = 0x02000000,
  36. RTC_VERTEX_BUFFER1 = 0x02000001,
  37. RTC_USER_VERTEX_BUFFER = 0x02100000,
  38. RTC_USER_VERTEX_BUFFER0 = 0x02100000,
  39. RTC_USER_VERTEX_BUFFER1 = 0x02100001,
  40. RTC_FACE_BUFFER = 0x03000000,
  41. RTC_LEVEL_BUFFER = 0x04000001,
  42. RTC_EDGE_CREASE_INDEX_BUFFER = 0x05000000,
  43. RTC_EDGE_CREASE_WEIGHT_BUFFER = 0x06000000,
  44. RTC_VERTEX_CREASE_INDEX_BUFFER = 0x07000000,
  45. RTC_VERTEX_CREASE_WEIGHT_BUFFER = 0x08000000,
  46. RTC_HOLE_BUFFER = 0x09000001,
  47. };
  48. /*! \brief Supported types of matrix layout for functions involving matrices */
  49. enum RTCMatrixType {
  50. RTC_MATRIX_ROW_MAJOR = 0,
  51. RTC_MATRIX_COLUMN_MAJOR = 1,
  52. RTC_MATRIX_COLUMN_MAJOR_ALIGNED16 = 2,
  53. };
  54. /*! \brief Supported geometry flags to specify handling in dynamic scenes. */
  55. enum RTCGeometryFlags
  56. {
  57. RTC_GEOMETRY_STATIC = 0, //!< specifies static geometry that will change rarely
  58. RTC_GEOMETRY_DEFORMABLE = 1, //!< specifies dynamic geometry with deformable motion (BVH refit possible)
  59. RTC_GEOMETRY_DYNAMIC = 2, //!< specifies dynamic geometry with arbitrary motion (BVH refit not possible)
  60. };
  61. /*! \brief Boundary interpolation mode for subdivision surfaces.
  62. WARNING: This enum is deprecated, use RTCSubdivisionMode instead.
  63. */
  64. enum RTCBoundaryMode
  65. {
  66. RTC_BOUNDARY_NONE = 0, //!< ignores border patches
  67. RTC_BOUNDARY_SMOOTH = 1, //!< smooth border (default)
  68. RTC_BOUNDARY_EDGE_ONLY = 1, //!< soft boundary (default)
  69. RTC_BOUNDARY_EDGE_AND_CORNER = 2 //!< boundary corner vertices are sharp vertices
  70. };
  71. /*! \brief Interpolation mode for subdivision surfaces. The modes are
  72. * ordered to interpolate successively more linear. */
  73. enum RTCSubdivisionMode
  74. {
  75. RTC_SUBDIV_NO_BOUNDARY = 0, //!< ignores border patches
  76. RTC_SUBDIV_SMOOTH_BOUNDARY = 1, //!< smooth border (default)
  77. RTC_SUBDIV_PIN_CORNERS = 2, //!< smooth border with fixed corners
  78. RTC_SUBDIV_PIN_BOUNDARY = 3, //!< linearly interpolation along border
  79. RTC_SUBDIV_PIN_ALL = 4, //!< pin every vertex (interpolates every patch linearly)
  80. };
  81. /*! Intersection filter function for uniform rays. */
  82. typedef unmasked void (*uniform RTCFilterFuncUniform)(void* uniform ptr, /*!< pointer to user data */
  83. uniform RTCRay1& ray /*!< intersection to filter */);
  84. /*! Intersection filter function for varying rays. */
  85. typedef void (*uniform RTCFilterFuncVarying)(void* uniform ptr, /*!< pointer to user data */
  86. varying RTCRay& ray /*!< intersection to filter */);
  87. /*! Intersection filter function for ray packets of size N. */
  88. typedef unmasked void (*uniform RTCFilterFuncN)(uniform int* uniform valid, /*!< pointer to valid mask */
  89. void* uniform ptr, /*!< pointer to geometry user data */
  90. const uniform RTCIntersectContext* uniform context, /*!< intersection context as passed to rtcIntersect/rtcOccluded */
  91. struct RTCRayN* uniform ray, /*!< ray and previous hit */
  92. const struct RTCHitN* uniform potentialHit, /*!< potential new hit */
  93. uniform const size_t N /*!< number of rays in ray packet */);
  94. /*! Type of displacement callback functions */
  95. typedef unmasked void (*RTCDisplacementFunc)(void* uniform ptr, /*!< pointer to user data of geometry */
  96. uniform unsigned int geomID, /*!< ID of geometry to displace */
  97. uniform unsigned int primID, /*!< ID of primitive of geometry to displace */
  98. uniform const float* uniform u, /*!< u coordinates (source) */
  99. uniform const float* uniform v, /*!< v coordinates (source) */
  100. uniform const float* uniform nx, /*!< x coordinates of normal at point to displace (source) */
  101. uniform const float* uniform ny, /*!< y coordinates of normal at point to displace (source) */
  102. uniform const float* uniform nz, /*!< z coordinates of normal at point to displace (source) */
  103. uniform float* uniform px, /*!< x coordinates of points to displace (source and target) */
  104. uniform float* uniform py, /*!< y coordinates of points to displace (source and target) */
  105. uniform float* uniform pz, /*!< z coordinates of points to displace (source and target) */
  106. uniform size_t N /*!< number of points to displace */ );
  107. /*! Type of displacement callback functions */
  108. typedef unmasked void (*RTCDisplacementFunc2)(void* uniform ptr, /*!< pointer to user data of geometry */
  109. uniform unsigned int geomID, /*!< ID of geometry to displace */
  110. uniform unsigned int primID, /*!< ID of primitive of geometry to displace */
  111. uniform unsigned int time, /*!< time step to calculate displacement for */
  112. uniform const float* uniform u, /*!< u coordinates (source) */
  113. uniform const float* uniform v, /*!< v coordinates (source) */
  114. uniform const float* uniform nx, /*!< x coordinates of normal at point to displace (source) */
  115. uniform const float* uniform ny, /*!< y coordinates of normal at point to displace (source) */
  116. uniform const float* uniform nz, /*!< z coordinates of normal at point to displace (source) */
  117. uniform float* uniform px, /*!< x coordinates of points to displace (source and target) */
  118. uniform float* uniform py, /*!< y coordinates of points to displace (source and target) */
  119. uniform float* uniform pz, /*!< z coordinates of points to displace (source and target) */
  120. uniform size_t N /*!< number of points to displace */ );
  121. /*! \brief Creates a new scene instance.
  122. WARNING: This callback is deprecated, use rtcNewInstance2 instead.
  123. A scene instance contains a reference to a scene to instantiate and
  124. the transformation to instantiate the scene with. An implementation
  125. will typically transform the ray with the inverse of the provided
  126. transformation and continue traversing the ray through the provided
  127. scene. If any geometry is hit, the instance ID (instID) member of
  128. the ray will get set to the geometry ID of the instance. */
  129. RTCORE_DEPRECATED uniform unsigned int rtcNewInstance (RTCScene target, //!< the scene the instance belongs to
  130. RTCScene source //!< the geometry to instantiate
  131. );
  132. /*! \brief Creates a new scene instance.
  133. A scene instance contains a reference to a scene to instantiate and
  134. the transformation to instantiate the scene with. For motion blurred
  135. instances, a number of timesteps can get specified. An
  136. implementation will typically transform the ray with the inverse of
  137. the provided transformation and continue traversing the ray through
  138. the provided scene. If any geometry is hit, the instance ID (instID)
  139. member of the ray will get set to the geometry ID of the
  140. instance. */
  141. uniform unsigned rtcNewInstance2 (RTCScene target, //!< the scene the instance belongs to
  142. RTCScene source, //!< the scene to instantiate
  143. uniform size_t numTimeSteps = 1); //!< number of timesteps, one matrix per timestep
  144. /*! \brief Sets transformation of the instance */
  145. RTCORE_DEPRECATED void rtcSetTransform (RTCScene scene, //!< scene handle
  146. uniform unsigned int geomID, //!< ID of geometry
  147. uniform RTCMatrixType layout, //!< layout of transformation matrix
  148. const uniform float* uniform xfm //!< pointer to transformation matrix
  149. );
  150. /*! \brief Sets transformation of the instance for specified timestep */
  151. void rtcSetTransform2 (RTCScene scene, //!< scene handle
  152. uniform unsigned int geomID, //!< ID of geometry
  153. uniform RTCMatrixType layout, //!< layout of transformation matrix
  154. const uniform float* uniform xfm, //!< pointer to transformation matrix
  155. uniform size_t timeStep = 0 //!< timestep to set the matrix for
  156. );
  157. /*! \brief Creates a new triangle mesh. The number of triangles
  158. (numTriangles), number of vertices (numVertices), and number of time
  159. steps (1 for normal meshes, and up to RTC_MAX_TIME_STEPS for multi
  160. segment motion blur), have to get specified. The triangle indices
  161. can be set be mapping and writing to the index buffer
  162. (RTC_INDEX_BUFFER) and the triangle vertices can be set by mapping
  163. and writing into the vertex buffer (RTC_VERTEX_BUFFER). In case of
  164. multi-segment motion blur, multiple vertex buffers have to get filled
  165. (RTC_VERTEX_BUFFER0, RTC_VERTEX_BUFFER1, etc.), one for each time
  166. step. The index buffer has the default layout of three 32 bit
  167. integer indices for each triangle. An index points to the ith
  168. vertex. The vertex buffer stores single precision x,y,z floating
  169. point coordinates aligned to 16 bytes. The value of the 4th float
  170. used for alignment can be arbitrary. */
  171. uniform unsigned int rtcNewTriangleMesh (RTCScene scene, //!< the scene the mesh belongs to
  172. uniform RTCGeometryFlags flags, //!< geometry flags
  173. uniform size_t numTriangles, //!< number of triangles
  174. uniform size_t numVertices, //!< number of vertices
  175. uniform size_t numTimeSteps = 1 //!< number of motion blur time steps
  176. );
  177. /*! \brief Creates a new quad mesh. The number of quads (numQuads),
  178. number of vertices (numVertices), and number of time steps (1 for
  179. normal meshes, and up to RTC_MAX_TIME_STEPS for multi-segment motion
  180. blur), have to get specified. The quad indices can be set be mapping
  181. and writing to the index buffer (RTC_INDEX_BUFFER) and the quad
  182. vertices can be set by mapping and writing into the vertex buffer
  183. (RTC_VERTEX_BUFFER). In case of multi-segment motion blur, multiple
  184. vertex buffers have to get filled (RTC_VERTEX_BUFFER0,
  185. RTC_VERTEX_BUFFER1, etc.), one for each time step. The index buffer has
  186. the default layout of three 32 bit integer indices for each quad. An
  187. index points to the ith vertex. The vertex buffer stores single
  188. precision x,y,z floating point coordinates aligned to 16 bytes. The
  189. value of the 4th float used for alignment can be arbitrary. */
  190. uniform unsigned int rtcNewQuadMesh (RTCScene scene, //!< the scene the mesh belongs to
  191. uniform RTCGeometryFlags flags, //!< geometry flags
  192. uniform size_t numQuads, //!< number of quads
  193. uniform size_t numVertices, //!< number of vertices
  194. uniform size_t numTimeSteps = 1 //!< number of motion blur time steps
  195. );
  196. /*! \brief Creates a new subdivision mesh. The number of faces
  197. (numFaces), edges/indices (numEdges), vertices (numVertices), edge
  198. creases (numEdgeCreases), vertex creases (numVertexCreases), holes
  199. (numHoles), and time steps (numTimeSteps) have to get speficied at
  200. construction time.
  201. The following buffers have to get filled by the application: the face
  202. buffer (RTC_FACE_BUFFER) contains the number edges/indices (3 or 4)
  203. of each of the numFaces faces, the index buffer (RTC_INDEX_BUFFER)
  204. contains multiple (3 or 4) 32bit vertex indices for each face and
  205. numEdges indices in total, the vertex buffer (RTC_VERTEX_BUFFER)
  206. stores numVertices vertices as single precision x,y,z floating point
  207. coordinates aligned to 16 bytes. The value of the 4th float used for
  208. alignment can be arbitrary. In case of multi-segment motion blur,
  209. multiple vertex buffers have to get filled (RTC_VERTEX_BUFFER0,
  210. RTC_VERTEX_BUFFER1, etc.), one for each time step.
  211. Optionally, the application can fill the hole buffer
  212. (RTC_HOLE_BUFFER) with numHoles many 32 bit indices of faces that
  213. should be considered non-existing.
  214. Optionally, the application can fill the level buffer
  215. (RTC_LEVEL_BUFFER) with a tessellation level for each of the numEdges
  216. edges. The subdivision level is a positive floating point value, that
  217. specifies how many quads along the edge should get generated during
  218. tessellation. The tessellation level is a lower bound, thus the
  219. implementation is free to choose a larger level. If no level buffer
  220. is specified a level of 1 is used.
  221. Optionally, the application can fill the sparse edge crease buffers
  222. to make some edges appear sharper. The edge crease index buffer
  223. (RTC_EDGE_CREASE_INDEX_BUFFER) contains numEdgeCreases many pairs of
  224. 32 bit vertex indices that specify unoriented edges. The edge crease
  225. weight buffer (RTC_EDGE_CREASE_WEIGHT_BUFFER) stores for each of
  226. theses crease edges a positive floating point weight. The larger this
  227. weight, the sharper the edge. Specifying a weight of infinify is
  228. supported and marks an edge as infinitely sharp. Storing an edge
  229. multiple times with the same crease weight is allowed, but has lower
  230. performance. Storing the an edge multiple times with different
  231. crease weights results in undefined behaviour. For a stored edge
  232. (i,j), the reverse direction edges (j,i) does not have to get stored,
  233. as both are considered the same edge.
  234. Optionally, the application can fill the sparse vertex crease buffers
  235. to make some vertices appear sharper. The vertex crease index buffer
  236. (RTC_VERTEX_CREASE_INDEX_BUFFER), contains numVertexCreases many 32
  237. bit vertex indices to speficy a set of vertices. The vertex crease
  238. weight buffer (RTC_VERTEX_CREASE_WEIGHT_BUFFER) specifies for each of
  239. these vertices a positive floating point weight. The larger this
  240. weight, the sharper the vertex. Specifying a weight of infinity is
  241. supported and makes the vertex infinitely sharp. Storing a vertex
  242. multiple times with the same crease weight is allowed, but has lower
  243. performance. Storing a vertex multiple times with different crease
  244. weights results in undefined behaviour.
  245. */
  246. uniform unsigned int rtcNewSubdivisionMesh (RTCScene scene, //!< the scene the mesh belongs to
  247. uniform RTCGeometryFlags flags, //!< geometry flags
  248. uniform size_t numFaces, //!< number of faces
  249. uniform size_t numEdges, //!< number of edges
  250. uniform size_t numVertices, //!< number of vertices
  251. uniform size_t numEdgeCreases, //!< number of edge creases
  252. uniform size_t numVertexCreases, //!< number of vertex creases
  253. uniform size_t numHoles, //!< number of holes
  254. uniform size_t numTimeSteps = 1 //!< number of motion blur time steps
  255. );
  256. /*! \brief Creates a new hair geometry consisting of multiple hairs
  257. represented as cubic bezier curves with varying radii.
  258. WARNING: This function is deprecated, use rtcNewBezierHairGeometry instead.
  259. The number of curves (numCurves), number of vertices (numVertices),
  260. and number of time steps (1 for normal meshes, and up to
  261. RTC_MAX_TIME_STEPS for multi-segment motion blur), have to get
  262. specified at construction time. Further, the curve index buffer
  263. (RTC_INDEX_BUFFER) and the curve vertex buffer (RTC_VERTEX_BUFFER)
  264. have to get set by mapping and writing to the appropiate buffers. In
  265. case of multi-segment motion blur, multiple vertex buffers have to
  266. get filled (RTC_VERTEX_BUFFER0, RTC_VERTEX_BUFFER1, etc.), one for
  267. each time step. The index buffer has the default layout of a single
  268. 32 bit integer index for each curve, that references the start
  269. vertex of the curve. The vertex buffer stores 4 control points per
  270. curve, each such control point consists of a single precision
  271. (x,y,z) position and radius, stored in that order in
  272. memory. Individual hairs are considered to be subpixel sized which
  273. allows the implementation to approximate the intersection
  274. calculation. This in particular means that zooming onto one hair
  275. might show geometric artefacts. */
  276. RTCORE_DEPRECATED uniform unsigned int rtcNewHairGeometry (RTCScene scene, //!< the scene the curves belong to
  277. uniform RTCGeometryFlags flags, //!< geometry flags
  278. uniform size_t numCurves, //!< number of curves
  279. uniform size_t numVertices, //!< number of vertices
  280. uniform size_t numTimeSteps = 1 //!< number of motion blur time steps
  281. );
  282. /*! \brief Creates a new hair geometry, consisting of multiple hairs
  283. represented as cubic bezier curves with varying radii. The number of
  284. curves (numCurves), number of vertices (numVertices), and number of
  285. time steps have to get specified at construction time (1 for normal
  286. meshes, and up to RTC_MAX_TIME_STEPS for multi-segment motion
  287. blur). Further, the curve index buffer (RTC_INDEX_BUFFER) and the
  288. curve vertex buffer (RTC_VERTEX_BUFFER) have to get set by mapping
  289. and writing to the appropiate buffers. In case of multi-segment
  290. motion blur multiple vertex buffers have to get filled
  291. (RTC_VERTEX_BUFFER0, RTC_VERTEX_BUFFER1, etc.), one for each time
  292. step. The index buffer has the default layout of a single 32 bit
  293. integer index for each curve, that references the start vertex of
  294. the curve. The vertex buffer stores 4 control points per curve, each
  295. such control point consists of a single precision (x,y,z) position
  296. and radius, stored in that order in memory. Individual hairs are
  297. considered to be subpixel sized which allows the implementation to
  298. approximate the intersection calculation. This in particular means
  299. that zooming onto one hair might show geometric artefacts. */
  300. RTCORE_API uniform unsigned int rtcNewBezierHairGeometry (RTCScene scene, //!< the scene the curves belong to
  301. uniform RTCGeometryFlags flags, //!< geometry flags
  302. uniform unsigned int numCurves, //!< number of curves
  303. uniform unsigned int numVertices, //!< number of vertices
  304. uniform unsigned int numTimeSteps = 1 //!< number of motion blur time steps
  305. );
  306. /*! \brief Creates a new hair geometry, consisting of multiple hairs
  307. represented as cubic bspline curves with varying radii. The number
  308. of curves (numCurves), number of vertices (numVertices), and number
  309. of time steps have to get specified at construction time (1 for
  310. normal meshes, and up to RTC_MAX_TIME_STEPS for multi-segment motion
  311. blur). Further, the curve index buffer (RTC_INDEX_BUFFER) and the
  312. curve vertex buffer (RTC_VERTEX_BUFFER) have to get set by mapping
  313. and writing to the appropiate buffers. In case of multi-segment
  314. motion blur multiple vertex buffers have to get filled
  315. (RTC_VERTEX_BUFFER0, RTC_VERTEX_BUFFER1, etc.), one for each time
  316. step. The index buffer has the default layout of a single 32 bit
  317. integer index for each curve, that references the start vertex of
  318. the curve. The vertex buffer stores 4 control points per curve, each
  319. such control point consists of a single precision (x,y,z) position
  320. and radius, stored in that order in memory. Individual hairs are
  321. considered to be subpixel sized which allows the implementation to
  322. approximate the intersection calculation. This in particular means
  323. that zooming onto one hair might show geometric artefacts. */
  324. RTCORE_API uniform unsigned int rtcNewBSplineHairGeometry (RTCScene scene, //!< the scene the curves belong to
  325. uniform RTCGeometryFlags flags, //!< geometry flags
  326. uniform unsigned int numCurves, //!< number of curves
  327. uniform unsigned int numVertices, //!< number of vertices
  328. uniform unsigned int numTimeSteps = 1 //!< number of motion blur time steps
  329. );
  330. /*! \brief Creates a new curve geometry, consisting of multiple curves
  331. represented as cubic bezier curves with varying radii.
  332. WARNING: This function is deprecated, use rtcNewBezierCurveGeometry instead.
  333. The intersected surface is defined as the sweep of a varying radius
  334. circle perpendicular along the curve. The number of curves
  335. (numCurves), number of vertices (numVertices), and number of time
  336. steps have to get specified at construction time (1 for normal
  337. meshes, and up to RTC_MAX_TIME_STEPS for multi-segment motion
  338. blur). Further, the curve index buffer (RTC_INDEX_BUFFER) and the
  339. curve vertex buffer (RTC_VERTEX_BUFFER) have to get set by mapping
  340. and writing to the appropiate buffers. In case of multi-segment
  341. motion blur, multiple vertex buffers have to get filled
  342. (RTC_VERTEX_BUFFER0, RTC_VERTEX_BUFFER1, etc.), one for each time
  343. step. The index buffer has the default layout of a single 32 bit
  344. integer index for each curve, that references the start vertex of
  345. the curve. The vertex buffer stores 4 control points per curve, each
  346. such control point consists of a single precision (x,y,z) position
  347. and radius, stored in that order in memory. */
  348. RTCORE_DEPRECATED uniform unsigned int rtcNewCurveGeometry (RTCScene scene, //!< the scene the curves belong to
  349. uniform RTCGeometryFlags flags, //!< geometry flags
  350. uniform size_t numCurves, //!< number of curves
  351. uniform size_t numVertices, //!< number of vertices
  352. uniform size_t numTimeSteps = 1 //!< number of motion blur time steps
  353. );
  354. /*! \brief Creates a new curve geometry, consisting of multiple curves
  355. represented as cubic bezier curves with varying radii. The
  356. intersected surface is defined as the sweep of a varying radius
  357. circle perpendicular along the curve. The number of curves
  358. (numCurves), number of vertices (numVertices), and number of time
  359. steps have to get specified at construction time (1 for normal
  360. meshes, and up to RTC_MAX_TIME_STEPS for multi-segment motion
  361. blur). Further, the curve index buffer (RTC_INDEX_BUFFER) and the
  362. curve vertex buffer (RTC_VERTEX_BUFFER) have to get set by mapping
  363. and writing to the appropiate buffers. In case of multi-segment
  364. motion blur, multiple vertex buffers have to get filled
  365. (RTC_VERTEX_BUFFER0, RTC_VERTEX_BUFFER1, etc.), one for each time
  366. step. The index buffer has the default layout of a single 32 bit
  367. integer index for each curve, that references the start vertex of
  368. the curve. The vertex buffer stores 4 control points per curve, each
  369. such control point consists of a single precision (x,y,z) position
  370. and radius, stored in that order in memory. */
  371. RTCORE_API uniform unsigned int rtcNewBezierCurveGeometry (RTCScene scene, //!< the scene the curves belong to
  372. uniform RTCGeometryFlags flags, //!< geometry flags
  373. uniform unsigned int numCurves, //!< number of curves
  374. uniform unsigned int numVertices, //!< number of vertices
  375. uniform unsigned int numTimeSteps = 1 //!< number of motion blur time steps
  376. );
  377. /*! \brief Creates a new curve geometry, consisting of multiple curves
  378. represented as cubic bspline curves with varying radii. The
  379. intersected surface is defined as the sweep of a varying radius
  380. circle perpendicular along the curve. The number of curves
  381. (numCurves), number of vertices (numVertices), and number of time
  382. steps have to get specified at construction time (1 for normal
  383. meshes, and up to RTC_MAX_TIME_STEPS for multi-segment motion
  384. blur). Further, the curve index buffer (RTC_INDEX_BUFFER) and the
  385. curve vertex buffer (RTC_VERTEX_BUFFER) have to get set by mapping
  386. and writing to the appropiate buffers. In case of multi-segment
  387. motion blur, multiple vertex buffers have to get filled
  388. (RTC_VERTEX_BUFFER0, RTC_VERTEX_BUFFER1, etc.), one for each time
  389. step. The index buffer has the default layout of a single 32 bit
  390. integer index for each curve, that references the start vertex of
  391. the curve. The vertex buffer stores 4 control points per curve, each
  392. such control point consists of a single precision (x,y,z) position
  393. and radius, stored in that order in memory. */
  394. RTCORE_API uniform unsigned int rtcNewBSplineCurveGeometry (RTCScene scene, //!< the scene the curves belong to
  395. uniform RTCGeometryFlags flags, //!< geometry flags
  396. uniform unsigned int numCurves, //!< number of curves
  397. uniform unsigned int numVertices, //!< number of vertices
  398. uniform unsigned int numTimeSteps = 1 //!< number of motion blur time steps
  399. );
  400. /*! \brief Creates a new line segment geometry, consisting of multiple
  401. segments with varying radii. The number of line segments
  402. (numSegments), number of vertices (numVertices), and number of time
  403. steps have to get specified at construction time (1 for normal
  404. meshes, and up to RTC_MAX_TIME_STEPS for multi-segment motion
  405. blur). Further, the segment index buffer (RTC_INDEX_BUFFER) and the
  406. segment vertex buffer (RTC_VERTEX_BUFFER) have to get set by mapping
  407. and writing to the appropiate buffers. In case of multi-segment
  408. motion blur, multiple vertex buffers have to get filled
  409. (RTC_VERTEX_BUFFER0, RTC_VERTEX_BUFFER1, etc.), one for each time
  410. step. The index buffer has the default layout of a single 32 bit
  411. integer index for each line segment, that references the start
  412. vertex of the segment. The vertex buffer stores 2 end points per
  413. line segment, each such point consists of a single precision (x,y,z)
  414. position and radius, stored in that order in memory. Individual
  415. segments are considered to be subpixel sized which allows the
  416. implementation to approximate the intersection calculation. This in
  417. particular means that zooming onto one line segment might show
  418. geometric artefacts. */
  419. uniform unsigned int rtcNewLineSegments (RTCScene scene, //!< the scene the line segments belong to
  420. uniform RTCGeometryFlags flags, //!< geometry flags
  421. uniform size_t numSegments, //!< number of line segments
  422. uniform size_t numVertices, //!< number of vertices
  423. uniform size_t numTimeSteps = 1 //!< number of motion blur time steps
  424. );
  425. /*! Sets a uniform tessellation rate for subdiv meshes and hair
  426. * geometry. For subdivision meshes the RTC_LEVEL_BUFFER can also be used
  427. * optionally to set a different tessellation rate per edge.*/
  428. void rtcSetTessellationRate (RTCScene scene, uniform unsigned geomID, uniform float tessellationRate);
  429. /*! \brief Sets 32 bit ray mask. */
  430. void rtcSetMask (RTCScene scene, uniform unsigned int geomID, uniform int mask);
  431. /*! \brief Sets boundary interpolation mode for default subdivision surface topology.
  432. WARNING: This function is deprecated, use rtcSetSubdivisionMode instead.
  433. */
  434. RTCORE_DEPRECATED void rtcSetBoundaryMode(RTCScene scene, uniform unsigned int geomID, uniform RTCBoundaryMode mode);
  435. /*! \brief Sets boundary interpolation mode for specified subdivision surface topology */
  436. void rtcSetSubdivisionMode(RTCScene scene, uniform unsigned int geomID, uniform unsigned int topologyID, uniform RTCSubdivisionMode mode);
  437. /*! \brief Binds a user vertex buffer to some index buffer topology. */
  438. void rtcSetIndexBuffer(RTCScene scene, uniform unsigned geomID, uniform RTCBufferType vertexBuffer, uniform RTCBufferType indexBuffer);
  439. /*! \brief Maps specified buffer. This function can be used to set index and
  440. * vertex buffers of geometries. */
  441. void* uniform rtcMapBuffer(RTCScene scene, uniform unsigned int geomID, uniform RTCBufferType type);
  442. /*! \brief Unmaps specified buffer.
  443. A buffer has to be unmapped before the rtcEnable, rtcDisable,
  444. rtcUpdate, or rtcDeleteGeometry calls are executed. */
  445. void rtcUnmapBuffer(RTCScene scene, uniform unsigned int geomID, uniform RTCBufferType type);
  446. /*! \brief Shares a data buffer between the application and
  447. * Embree.
  448. WARNING: This function is deprecated, use rtcSetBuffer2 instead.
  449. * The passed buffer is used by Embree to store index and vertex
  450. * data. It has to remain valid as long as the mesh exists, and the
  451. * user is responsible to free the data when the mesh gets
  452. * deleted. One can optionally speficy a byte offset and byte stride
  453. * of the elements stored inside the buffer. The addresses
  454. * ptr+offset+i*stride have to be aligned to 4 bytes on Xeon CPUs and
  455. * 16 bytes on Xeon Phi accelerators. For vertex buffers, the 4 bytes
  456. * after the z-coordinate of the last vertex have to be readable
  457. * memory, thus padding is required for some layouts. If this
  458. * function is not called, Embree will allocate and manage buffers of
  459. * the default layout. */
  460. void rtcSetBuffer(RTCScene scene, uniform unsigned int geomID, uniform RTCBufferType type,
  461. const void* uniform ptr, uniform size_t byteOffset, uniform size_t byteStride);
  462. /*! \brief Shares a data buffer between the application and
  463. * Embree. The data has to remain valid as long as the mesh exists,
  464. * and the user is responsible to free the data when the mesh gets
  465. * deleted. For sharing the buffer, one has to specify the number of
  466. * elements of the buffer, a byte offset to the first element, and
  467. * byte stride of elements stored inside the buffer. The addresses
  468. * ptr+offset+i*stride have to be aligned to 4 bytes. For vertex
  469. * buffers and user vertex buffers the buffer has to be padded with 0
  470. * to a size of a multiple of 16 bytes, as Embree always accesses
  471. * vertex buffers and user vertex buffers using SSE instructions. If
  472. * this function is not called, Embree will allocate and manage
  473. * buffers of the default layout. */
  474. void rtcSetBuffer2(RTCScene scene, uniform unsigned int geomID, uniform RTCBufferType type,
  475. const void* uniform ptr, uniform size_t byteOffset, uniform size_t byteStride, uniform size_t size = -1);
  476. /*! \brief Enable geometry. Enabled geometry can be hit by a ray. */
  477. void rtcEnable (RTCScene scene, uniform unsigned int geomID);
  478. /*! \brief Update spefific geometry buffer.
  479. Each time geometry buffers got modified, the user has to call some
  480. update function to tell the ray tracing engine which buffers got
  481. modified. The rtcUpdateBuffer function taggs a specific buffer of
  482. some geometry as modified. */
  483. void rtcUpdate (RTCScene scene, uniform unsigned int geomID);
  484. /*! \brief Update spefific geometry buffer.
  485. Each time geometry buffers got modified, the user has to call some
  486. update function to tell the ray tracing engine which buffers got
  487. modified. The rtcUpdateBuffer function taggs a specific buffer of
  488. some geometry as modified. */
  489. void rtcUpdateBuffer (RTCScene scene, uniform unsigned int geomID, uniform RTCBufferType type);
  490. /*! \brief Disable geometry.
  491. Disabled geometry is not hit by any ray. Disabling and enabling
  492. geometry gives higher performance than deleting and recreating
  493. geometry. */
  494. void rtcDisable (RTCScene scene, uniform unsigned int geomID);
  495. /*! \brief Sets the displacement function. */
  496. void rtcSetDisplacementFunction (RTCScene scene, uniform unsigned int geomID, uniform RTCDisplacementFunc func, uniform RTCBounds *uniform bounds);
  497. /*! \brief Sets the displacement function. */
  498. void rtcSetDisplacementFunction2 (RTCScene scene, uniform unsigned int geomID, uniform RTCDisplacementFunc2 func, uniform RTCBounds *uniform bounds);
  499. /*! \brief Sets the intersection filter function for uniform rays. */
  500. void rtcSetIntersectionFilterFunction1 (RTCScene scene, uniform unsigned int geomID, uniform RTCFilterFuncUniform func);
  501. /*! \brief Sets the intersection filter function for varying rays. */
  502. void rtcSetIntersectionFilterFunction (RTCScene scene, uniform unsigned int geomID, uniform RTCFilterFuncVarying func);
  503. /*! \brief Sets the intersection filter function for ray packets of size N. */
  504. void rtcSetIntersectionFilterFunctionN (RTCScene scene, uniform unsigned int geomID, uniform RTCFilterFuncN func);
  505. /*! \brief Sets the occlusion filter function for uniform rays. */
  506. void rtcSetOcclusionFilterFunction1 (RTCScene scene, uniform unsigned int geomID, uniform RTCFilterFuncUniform func);
  507. /*! \brief Sets the occlusion filter function for varying rays. */
  508. void rtcSetOcclusionFilterFunction (RTCScene scene, uniform unsigned int geomID, uniform RTCFilterFuncVarying func);
  509. /*! \brief Sets the occlusion filter function for ray packets of size N. */
  510. void rtcSetOcclusionFilterFunctionN (RTCScene scene, uniform unsigned int geomID, uniform RTCFilterFuncN func);
  511. /*! Set pointer for user defined data per geometry. Invokations
  512. * of the various user intersect and occluded functions get passed
  513. * this data pointer when called. */
  514. void rtcSetUserData (RTCScene scene, uniform unsigned int geomID, void* uniform ptr);
  515. /*! Get pointer for user defined data per geometry based on geomID. */
  516. void* uniform rtcGetUserData (RTCScene scene, uniform unsigned int geomID);
  517. /*! Interpolates user data to some varying u/v location. The data
  518. * buffer specifies per vertex data to interpolate and can be one of
  519. * the RTC_VERTEX_BUFFER0/1 or RTC_USER_VERTEX_BUFFER0/1 and has to contain
  520. * numFloats floating point values to interpolate for each vertex of
  521. * the geometry. The P array will get filled with the interpolated
  522. * data, and the dPdu and dPdv arrays with the u and v derivative of
  523. * the interpolation. If the pointers P is NULL, the value will not
  524. * get calculated. If dPdu and dPdv are NULL the derivatives will not
  525. * get calculated. Both dPdu and dPdv have to be either valid or
  526. * NULL. These destination arrays are filled in structure of array
  527. * (SoA) layout. The buffer has to be padded at the end such
  528. * that the last element can be read safely using SSE
  529. * instructions. */
  530. void rtcInterpolate(RTCScene scene, uniform unsigned int geomID, varying unsigned int primIDs, varying float u, varying float v,
  531. uniform RTCBufferType buffer,
  532. varying float* uniform P, varying float* uniform dPdu, varying float* uniform dPdv, uniform size_t numFloats);
  533. /*! Interpolates user data to some varying u/v location. The data
  534. * buffer specifies per vertex data to interpolate and can be one of
  535. * the RTC_VERTEX_BUFFER0/1 or RTC_USER_VERTEX_BUFFER0/1 and has to contain
  536. * numFloats floating point values to interpolate for each vertex of
  537. * the geometry. The P array will get filled with the
  538. * interpolated datam the dPdu and dPdv arrays with the u and v
  539. * derivative of the interpolation, and the ddPdudu, ddPdvdv, and
  540. * ddPdudv arrays with the respective second derivatives. One can
  541. * disable 1) the calculation of the interpolated value by setting P
  542. * to NULL, 2) the calculation of the 1st order derivatives by
  543. * setting dPdu and dPdv to NULL, 3) the calculation of the second
  544. * order derivatives by setting ddPdudu, ddPdvdv, and ddPdudv to
  545. * NULL. These destination arrays are filled in structure of array
  546. * (SoA) layout. The buffer has to be padded at the end such that
  547. * the last element can be read safely using SSE
  548. * instructions. */
  549. void rtcInterpolate2(RTCScene scene, uniform unsigned int geomID, varying unsigned int primIDs, varying float u, varying float v,
  550. uniform RTCBufferType buffer,
  551. varying float* uniform P, varying float* uniform dPdu, varying float* uniform dPdv,
  552. varying float* uniform ddPdudu, varying float* uniform ddPdvdv, varying float* uniform ddPdudv,
  553. uniform size_t numFloats);
  554. /*! \brief Deletes the geometry. */
  555. void rtcDeleteGeometry (RTCScene scene, uniform unsigned int geomID);
  556. /*! @} */
  557. #endif