Method and system for constructing ray tracing acceleration structure
By combining TLAS and BLAS in the ray tracing system and using transformation matrices to simplify intersection testing, the problem of low ray tracing rendering performance on mobile devices is solved and efficient image rendering and low power consumption are achieved.
Patent Information
- Application Number
- CN202110784519.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2020-07-14
- Filing Date
- 2021-07-12
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2041-07-12
AI Technical Summary
Existing ray tracing systems struggle to perform efficiently when rendering images in real time on devices that have strict constraints on silicon area, cost, and power consumption, especially on mobile devices, mainly due to the difficulty in streamlining the processing involved in ray tracing.
A combination of the top-level acceleration structure TLAS and the bottom-level acceleration structure BLAS is used to simplify the intersection test of rays and scene objects by defining and using transformation matrices, reducing unnecessary computing and storage requirements, and optimizing the structure of the ray tracing system to adapt to the limitations of mobile devices. .
Improves the real-time rendering performance of ray tracing systems on mobile devices, reduces power consumption and silicon area requirements, and enables more efficient image rendering.
Smart Images

Figure CN113936091B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of ray tracing. Background Art
[0002] Ray tracing systems can simulate the way rays (e.g., rays) interact with a scene. For example, ray tracing techniques can be used in graphics rendering systems configured to generate images from 3-D scene descriptions. The images can be photo-realistic, or achieve other goals. For example, animated films can be produced using 3-D rendering techniques. The description of a 3D scene typically includes data that defines the geometric shapes in the scene. This geometric data is typically defined in terms of primitives, which are typically triangle primitives, but can sometimes be other shapes, such as other polygons, lines, or points, and spheres, Bezier patches, and procedural primitives can also be included in ray tracing.
[0003] Ray tracing mimics the natural interaction of light with objects in a scene, and complex rendering features can naturally arise from ray-traced 3-D scenes. Ray tracing can be parallelized relatively easily on a pixel-by-pixel level because pixels are typically independent of each other. However, in cases such as ambient occlusion, reflections, caustics, etc., it is difficult to pipeline the processing involved in ray tracing due to the distribution and different positions and directions of travel of rays in a 3-D scene. Ray tracing allows realistic images to be rendered, but typically requires a high level of processing power and a large working memory, making ray tracing difficult to implement for real-time rendering of images (e.g., for gaming applications), particularly on devices that may have strict restrictions on silicon area, cost, and power consumption, such as on mobile devices (e.g., smart phones, tablet computers, laptop computers, etc.).
[0004] At a very broad level, ray tracing involves: (i) identifying intersections between rays and geometry (e.g., primitives) in a scene, and (ii) in response to identifying the intersections, performing some processing (e.g., by executing a shader program) to determine how the intersections contribute to the image being rendered. Execution of the shader program may cause additional rays to be emitted into the scene. These additional rays may be referred to as "secondary rays."
[0005] There is a lot of processing involved in identifying intersections between rays and geometry in a scene. In a very simple approach, each ray can be tested against each primitive in the scene, and then when all intersection hits have been determined, the closest intersection can be identified. For scenes that may have millions or billions of primitives, where the number of rays to be processed may also be in the millions, this approach is not feasible. Therefore, ray tracing systems typically use acceleration structures that characterize the geometry in the scene in a way that reduces the work required for intersection testing. However, even with prior art acceleration structures, it is difficult to perform intersection testing at a rate suitable for real-time rendering of images (e.g., for gaming applications), particularly on devices that have strict constraints on silicon area, cost, and power consumption, such as on mobile devices (e.g., smartphones, tablet computers, laptop computers, etc.).
[0006] Modern ray tracing architectures typically use an acceleration structure based on a bounding volume hierarchy - specifically a bounding box hierarchy. Primitives are grouped together into bounding boxes that enclose the primitives. These bounding boxes are in turn grouped together into larger bounding boxes that enclose them. Intersection testing then becomes easier because if a ray misses a bounding box, it does not need to be tested against any of the bounding box's children.
[0007] In a modern hierarchical approach, two types of acceleration structures can be identified: a bottom-level acceleration structure (BLAS); and a top-level acceleration structure (TLAS). A BLAS groups primitives together, i.e., a BLAS has leaf nodes that are object primitives (typically triangles, but other geometrically and procedurally defined shapes are possible). The top level of a BLAS is a single root node. For example, a BLAS can be used to describe a model of a single object in a scene or a group of objects in a scene. A TLAS describes a high-level scene, starting with the root node at the top level and ending at the BLAS at the lowest level. Specifically, a TLAS can refer to multiple instances of the same BLAS. For example, a BLAS can simulate a single chair. A TLAS can simulate a concert hall and include hundreds of chair BLAS instances, each representing a different chair in a different position and / or orientation in the hall. Using instances in this way provides the efficiency of not having to create the same model for the same object multiple times.
[0008] Intersection testing is done by traversing the hierarchy. If a given ray "hit" a bounding box (node), then the ray needs to be tested against each child of that bounding box (node). This continues down through the hierarchy until the ray misses all children of a node, or hits at least one primitive. Summary of the invention
[0009] This Summary is provided to introduce a selection of concepts in a simplified form that are further described below in the Detailed Description. This Summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.
[0010] According to a first aspect, there is provided a computer-implemented method of constructing a ray tracing acceleration structure for a scene defined relative to a global coordinate system, the acceleration structure comprising a top-level acceleration structure TLAS having leaf nodes referencing one or more instances of a bottom-level acceleration structure BLAS. The method may comprise one or more of the following: defining one or more TLAS nodes; for each TLAS node, determining a first bounding volume, and associating the node with a transformation matrix, the transformation matrix mapping between the first bounding volume and a second bounding volume in the global coordinate system.
[0011] Optionally, the method further comprises defining a plurality of transformation matrices of the TLAS, and associating the node comprises associating the node with a local transformation matrix of the plurality of local transformation matrices that maps between the first bounding volume and a second bounding volume in the global coordinate system. The plurality of transformation matrices may each represent a different, optionally affine, mapping.
[0012] Optionally, determining the first bounding volume comprises selecting a bounding volume from a set of candidate bounding volumes. Each candidate bounding volume may be associated with a different transformation matrix in a plurality of transformation matrices. Further optionally, selecting may comprise comparing the set of candidate bounding volumes and selecting the best bounding volume according to a predefined heuristic, and optionally, the predefined heuristic may be capable of selecting the candidate bounding volume using one of the following: minimum volume, minimum surface area, or minimum cross-sectional area in a particular direction.
[0013] Optionally, associating the node with a local transformation matrix of the plurality of transformation matrices comprises storing an indication of a corresponding transformation matrix of the TLAS node, and optionally, wherein storing the indication comprises storing an index identifying a particular transformation matrix.
[0014] Optionally, the first bounding volume is an oriented bounding volume and the second bounding volume is an axis-aligned bounding volume. The first bounding volume may be an oriented bounding volume box and the second bounding volume may be an axis-aligned bounding volume box, or wherein the first bounding volume may be an oriented ellipsoid and the second bounding volume may be a sphere or an axis-aligned ellipsoid.
[0015] Optionally, the method may further include performing an intersection test using TLAS in a ray tracing system.
[0016] According to a second aspect, there is provided a computer-implemented method for tracing a ray of a scene defined relative to a global coordinate system by an acceleration structure, the acceleration structure comprising a top-level acceleration structure TLAS having leaf nodes referencing one or more instances of a bottom-level acceleration structure BLAS. The method may include one or more of the following: evaluating whether a ray intersects a node of the TLAS, the node having a first bounding volume defined in a global coordinate system, wherein the evaluation comprises: identifying a transformation matrix associated with the node, the transformation matrix representing a mapping between the first bounding volume of the node and a second bounding volume in the global coordinate system; transforming the ray using the identified transformation matrix to test whether the ray intersects the node.
[0017] Optionally, identifying comprises identifying the transformation matrix from a plurality of transformation matrices defined for TLAS.
[0018] Optionally, the accelerating structure is constructed according to any of the above-mentioned variations of the first aspect.
[0019] According to a third aspect, there is provided a ray tracing system configured to construct a ray tracing acceleration structure for a scene defined relative to a global coordinate system, the acceleration structure comprising a top-level acceleration structure TLAS having leaf nodes that reference one or more instances of a bottom-level acceleration structure BLAS. The system may include a module configured to perform one or more of the following: define one or more TLAS nodes; for each TLAS node, determine a first bounding volume and associate the node with a transformation matrix that maps between the first bounding volume and a second bounding volume in the global coordinate system; and store the TLAS in a memory, including the second bounding volume and the association between the node and the transformation matrix.
[0020] Optionally, the module may be further configured to define a plurality of transformation matrices for TLAS, and wherein associating the node comprises associating the node with one of the plurality of transformation matrices. The module may be configured to define the boundary volume by selecting the boundary volume from a set of candidate boundary volumes. Each candidate boundary volume may be associated with a different one of the plurality of transformation matrices, and / or the selection may comprise comparing the set of candidate boundary volumes and selecting the best boundary volume according to a predefined heuristic.
[0021] Optionally, storing the association between the node and the transformation matrix comprises storing an index identifying the transformation matrix.
[0022] Optionally, the first bounding volume is an oriented bounding volume and the second bounding volume is an axis-aligned bounding volume. The first bounding volume may be an oriented bounding volume box and the second bounding volume may be an axis-aligned bounding volume box, or wherein the first bounding volume may be an oriented ellipsoid and the second bounding volume may be a sphere or an axis-aligned ellipsoid.
[0023] According to a fourth aspect, there is provided a ray tracing system configured to trace rays of a scene defined relative to a global coordinate system through an acceleration structure, the acceleration structure comprising a top-level acceleration structure TLAS having leaf nodes that reference one or more instances of a bottom-level acceleration structure BLAS. The system may include intersection test logic configured to perform one or more of the following: identify a transformation matrix associated with a node of the TLAS, the node having a first bounding volume defined in a global coordinate system, the transformation matrix representing a mapping between the first bounding volume of the node and a second bounding volume in the global coordinate system; transform the ray using the identified transformation matrix; and evaluate whether the ray intersects the node.
[0024] Optionally, the test logic is configured to identify the transformation matrix from a plurality of transformation matrices defined for TLAS.The system may be configured to perform a method according to any of the above variations of the first aspect.
[0025] According to another aspect, there is provided a computer readable code configured to, when the code is run, cause the method of any one of the above variations of the first or second aspect to be performed.
[0026] According to another aspect, there is provided a graphics processing system configured to perform the method of any one of the above variations of the first or second aspect.
[0027] According to another aspect, a computer-implemented method of creating a bounding volume hierarchy (BVH) for a model is provided, the model being defined relative to a local coordinate system of the model. The method may include one or more of the following steps: defining a plurality of BVH nodes within the model; establishing a plurality of local transformation matrices for the BVH; and for each of the plurality of BVH nodes, determining a first bounding volume and associating the node with one of the plurality of local transformation matrices that maps between the first bounding volume and a second bounding volume in the local coordinate system.
[0028] According to another aspect, a method for constructing a ray tracing acceleration structure for a scene defined relative to a global coordinate system is provided, the scene comprising a model, the model being defined relative to a local coordinate system of the model, and wherein the model is instantiated in the scene by applying a model transformation matrix to position the model in the global coordinate system, the method comprising one or more of the following: accessing multiple local transformation matrices of a bounding volume hierarchy BVH for the model, the BVH comprising multiple branch nodes and multiple local transformation matrices, each branch node being associated with an OBB and one of the multiple transformation matrices; and for an instance of the model, updating the local transformation matrix of the BVH to a set of instance transformation matrices by combining each individual local transformation matrix with the model transformation matrix, so that the branch nodes of the instance of the model each become associated with one of the instance transformation matrices.
[0029] According to another aspect, a computer-implemented method is provided for tracing a ray of a scene defined relative to a global coordinate system through an acceleration structure, the scene including a model, the model being defined relative to a local coordinate system of the model, and wherein the model is instantiated in the scene by applying a model transformation matrix to position the model in the global coordinate system. The method may include one or more of: determining that a ray intersection test is required for a node of an acceleration structure representing an instance of the model; and evaluating whether the ray intersects a node of a bounding volume hierarchy BVH of the instance of the model, the node having a first bounding volume defined in the model coordinate system, wherein the evaluation includes: identifying an instance transformation matrix associated with the node from a plurality of instance transformation matrices defined for the BVH, and transforming the ray using the identified instance transformation matrix to perform a test to find out whether the ray intersects a branch node, wherein the identified transformation matrix represents a combination of an inverse matrix of the model transformation matrix and a mapping between a first bounding volume of the node and a second bounding volume in the local coordinate system.
[0030] According to another aspect, a ray tracing system configured to create a bounding volume hierarchy (BVH) for a model is provided, the model being defined relative to a local coordinate system of the model. The system may include a module configured to perform one or more of the following: define a plurality of BVH nodes within the model, establish a plurality of local transformation matrices for the BVH; for each of the plurality of BVH nodes, determine a first bounding volume, and associate the node with one of the plurality of local transformation matrices that maps between the first bounding volume and a second bounding volume in the local coordinate system; and store the BVH in a memory, including the second bounding volume and an association between the node and one of the plurality of local transformation matrices.
[0031] According to another aspect, a ray tracing system configured to construct a ray tracing acceleration structure for a scene defined relative to a global coordinate system, the scene comprising a model, the model being defined relative to a local coordinate system of the model, and wherein the model is instantiated in the scene by applying a model transformation matrix to position the model in the global coordinate system. The system may include a module configured to perform one or more of the following: accessing from a memory a plurality of local transformation matrices of a bounding volume hierarchy BVH for the model, the BVH being created by a ray tracing system according to any of the above-mentioned variations of the fourth aspect; for an instance of the model, updating the plurality of local transformation matrices of the BVH into a set of instance transformation matrices by combining each individual local transformation matrix with the model transformation matrix, so that a plurality of nodes of the instance of the model each become associated with one of the instance transformation matrices; and storing the set of instance transformation matrices in a memory.
[0032] According to another aspect, a ray tracing system is provided that is configured to trace rays of a scene defined relative to a global coordinate system through an acceleration structure, the scene including a model, the model being defined relative to a local coordinate system of the model, and wherein the model is instantiated in the scene by applying a model transformation matrix to position the model in the global coordinate system. The system may include intersection test logic configured to perform one or more of the following: determining that a ray intersection test is required for a node of an acceleration structure representing an instance of the model; identifying an instance transformation matrix associated with a node of an instance of the model having a first bounding volume defined in the model coordinate system from a plurality of instance transformation matrices defined for a bounding volume hierarchy (BVH), wherein the identified transformation matrix represents a combination of an inverse matrix of the model transformation matrix and a mapping between the first bounding volume of the node and a second bounding volume in the local coordinate system;
[0033] transforming the ray using the identified instance transformation matrix; and evaluating whether the ray intersects the node.
[0034] A ray tracing graphics processing system may be embodied in hardware on an integrated circuit. A method of manufacturing a ray tracing graphics processing system at an integrated circuit manufacturing system may be provided. An integrated circuit definition data set may be provided that, when processed in the integrated circuit manufacturing system, configures the system to manufacture the ray tracing graphics processing system. A non-transitory computer readable storage medium may be provided that has a computer readable description of the ray tracing graphics processing system stored thereon that, when processed in the integrated circuit manufacturing system, causes the integrated circuit manufacturing system to manufacture an integrated circuit embodying the ray tracing graphics processing system.
[0035] An integrated circuit manufacturing system can be provided, which includes: a non-transitory computer-readable storage medium on which a computer-readable description of a ray tracing graphics processing system is stored; a layout processing system, which is configured to process the computer-readable description to generate a circuit layout description of an integrated circuit embodying the ray tracing graphics processing system; and an integrated circuit generation system, which is configured to manufacture the ray tracing graphics processing system based on the circuit layout description.
[0036] A computer program code for performing any of the methods described herein may be provided. A non-transitory computer readable storage medium may be provided on which computer readable instructions are stored which, when executed at a computer system, cause the computer system to perform any of the methods described herein.
[0037] As will be apparent to those skilled in the art, the above-described features may be combined as appropriate and may be combined with any aspects of the examples described herein. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Examples will now be described in detail with reference to the accompanying drawings, in which:
[0039] Figure 1 shows a model instantiated multiple times in a scene to be ray traced;
[0040] Figure 2 Shown for Figure 1 The acceleration structure of the scene presented in ;
[0041] Figure 3 shows how axis-aligned bounding volume boxes (AABBs) and oriented bounding volume boxes (OBBs) can be used to bound parts of a model;
[0042] Figure 4 shows different ways in which ray intersection testing can be performed;
[0043] Figure 5 A model of a palette with associated bounding volume hierarchy, acceleration structure, and local transformation matrix is shown;
[0044] Figure 6 Shows the use of Figure 5 A scene constructed from multiple instances of a model having associated acceleration structures;
[0045] Figure 7 A method for constructing a bounding volume hierarchy is shown;
[0046] Figure 8 A method for constructing an acceleration structure containing a model instance is shown;
[0047] Fig. 9 A method for tracing rays in a bounding volume hierarchy is shown;
[0048] Fig.10 A method for building a top-level acceleration structure is shown;
[0049] Fig.11 A method for tracing rays in a top-level acceleration structure is shown;
[0050] Fig.12 A computer system is shown in which a graphics processing system is implemented; and
[0051] Fig.13 A manufacturing system for producing an integrated circuit embodying a graphics processing system is shown.
[0052] The accompanying drawings illustrate various examples. It will be appreciated by the skilled person that the element boundaries (e.g., boxes, groups of boxes, or other shapes) shown in the accompanying drawings represent an example of boundaries. In some examples, it may be the case that an element can be designed as multiple elements, or multiple elements can be designed as one element. Where appropriate, common reference numerals are used throughout the accompanying drawings to indicate similar features. DETAILED DESCRIPTION
[0053] The following description is given by way of example to enable those skilled in the art to make and use the invention. The invention is not limited to the embodiments described herein, and various modifications to the disclosed embodiments will be apparent to those skilled in the art. Embodiments are now described only by way of example.
[0054] As mentioned above, modern ray tracing systems use a hierarchical approach to build acceleration structures to help perform intersection tests. The scene is represented in world space (i.e., a global coordinate system defined for the entire scene) by a combination of a top-level acceleration structure (TLAS) and one or more bottom-level acceleration structures (BLAS). Both TLAS and BLAS can have their own acceleration structures in the form of a bounding volume hierarchy (BVH). In this way, the top-level acceleration structure can be subdivided into sub-volumes or nodes in a hierarchical manner, and each of the nodes in the lowest hierarchical level in the TLAS references the bottom-level acceleration structure (BLAS). For ease of reference, the bottom-level nodes can also be referred to as leaf nodes (wherein the nodes of the higher levels are referred to as branch nodes). The bottom-level acceleration structure is a model representing, for example, a single object or a collection of objects. The leaf nodes of the BLAS are geometric or procedural primitives used to build the model. A single BLAS can be referenced or "instantiated" multiple times by different (or even the same) TLAS nodes.
[0055] Figure 1 A scene 100 illustrating the use of an example is shown. The scene 100 has a world space or global coordinate system indicated by axes 102. Within the world space coordinate system, several instances of a model 104 have been positioned to contribute to the overall scene 100. The model 104 is defined within its own model coordinate system (or "local" coordinate system) indicated by axes 106. As can be seen, the axes 106 of the model space are different from the axes 102 of the world space. Each instance of the model 104 is positioned in the scene 100 by referencing the model (e.g., by a pointer) in conjunction with a transformation. A transformation can be defined as a matrix that determines the position of a model instance in world space (i.e., where the model appears relative to the three-dimensional axes 102 of the global coordinate system), as well as other affine operations such as rotation, reflection, or stretching of the initial model 104. For example, in the scene 100, the instance of the model 104 on the right side of the scene is transformed not only by a specific translation in world space, but also by a reflection of the base model 104. For completeness, note that the boxes around instances of models in the scene are only used to guide the eye, and appear to overlap due to the perspective of the scene. Overlapping boxes are not intended to indicate overlapping instances.
[0056] Figure 2 Shows Figure 1 How a scene can be decomposed according to the acceleration structure 200 for ray tracing. Figure 2 The lowest level of the acceleration structure 200 is shown as instances of the reference model 104 (instances 104A-D) and instances of the second model (instances 214A and 214B). When the acceleration structure shown at 200 ends with instances of the reference model, it is actually the top-level acceleration structure (and the model referenced by those instances in the TLAS will be described by the bottom-level acceleration structure, with its own bounding volume hierarchy, which is not shown).
[0057] At the top level of the acceleration structure 200 is node 202, which may also be referred to as a root node. Node 202 effectively represents the entire scene. However, the scene is further subdivided into smaller parts or volumes at a granularity greater than instances of individual models. Thus, at the next level in the acceleration structure, there are additional branch nodes 204 and 206 representing sub-volumes within the overall scene 100. These branch nodes may then be further subdivided to lead to additional child branch nodes (e.g., node 204 links to nodes 208 and 210). Alternatively, nodes may reference model instances (e.g., as shown in nodes 206, 208, and 210), i.e., they may reference leaf nodes of the TLAS. Although not shown, a given branch node may also refer to child branch nodes and child leaf nodes. For the sake of completeness, note that, for simplicity, Figure 2 The acceleration structure is illustrated as a binary tree, but the acceleration structure need not be defined as a binary tree, and, for example, an alternative acceleration structure may be in the form of an N-ary tree.
[0058] Acceleration structure 200 may be used to help determine whether a ray intersects any object in scene 100. As an example, a ray entering the scene would begin at node 202 and be scheduled for testing against nodes 204 and 206, which are children of node 202. In this case, testing a node means determining whether the ray intersects the bounding volume of the node.
[0059] For example, if not all of scene 100 is encapsulated by the bounding volumes of nodes 204 and 206 (e.g., because a portion of scene 100 contains empty space that is not assigned to either node), and no node intersections are found, then the ray will be found to miss an object in the scene, and no further traversal of the acceleration structure will be required (although note that this does not mean that all ray tracing operations must terminate - e.g., a "miss shader" may be invoked to determine how to represent a miss).
[0060] By contrast, if one (or more, if the nodes have overlapping bounding volumes) nodes are found to intersect, the children of the intersecting node are scheduled to be tested against the ray. This is repeated, into BLAS instances, and (within the BVHs of those instances) down to the level of the individual primitives that make up the model.
[0061] Thus, it will be appreciated that determining the final primitive that a ray intersects may require testing the ray against many nodes higher up in the acceleration structure, and many nodes will be found to be missed. However, this is more efficient than testing each ray directly against each primitive, and it will be appreciated that determining misses for nodes at high levels in the hierarchy avoids the need to test any child nodes (and child nodes of child nodes, etc.) and therefore any primitives encapsulated by those nodes.
[0062] Whether a ray intersects a node depends on the bounding volume associated with the node. Different bounding volume shapes are possible, but modern systems tend to rely on box-shaped bounding volumes because they are relatively efficient in space and relatively simple in computation for testing against rays. By comparison, spherical bounding volumes may require fewer values than boxes to define, and may be computationally simpler to test for intersection with rays, but they may be very inefficient for boundary objects. Even if, for example, a circular object (such as a wheel) is relatively poorly defined by a sphere (i.e., there are many empty volumes within the sphere) when viewed from a direction perpendicular to the wheel axis, even if the sphere appears to tightly define the wheel when viewed parallel to the wheel axis. Inefficient definition is undesirable because it results in false positives when performing intersection tests (in the context of this document, this means that when the ray will not hit the underlying primitive or sub-bounding volume within the bounding volume, the hit to the bounding volume is determined). That is, even if the ray does not actually intersect with the object represented by the bounding volume, it will be correctly determined that the ray intersects with the bounding volume. To some extent this is unavoidable, and to avoid it completely the bounding volume must be synonymous with the surface of the object, at which point rays are effectively tested against each individual primitive. Thus there is a balance to be struck, and a bounding box is generally preferred to achieve that balance.
[0063] Bounding boxes can be further divided into two types. As the name implies, axis-aligned bounding boxes (AABBs) are defined by faces / edges that are parallel to the axes of the coordinate system defined by the box. Oriented bounding boxes (OBBs) do not have to be so aligned, i.e., they can be at an angle to the axes of the coordinate system (but if it is optimally oriented, the OBB can be an AABB). This means that OBBs can define objects more tightly than AABBs (e.g., forming a box of smaller volume) because there are more degrees of freedom about how to arrange the box around the object. As described above, this tighter boundary can result in fewer false positive hits, which improves the efficiency of traversing the acceleration structure.
[0064] Figure 3 Shows how AABBs and OBBs have different benefits. Figure 3 A) and B) in the figure are the front view and side view of the model house. Figure 3304 and 306. AABB 302 closely bounds the bulk of the house in the model, making it the desired bounding volume for that portion of the model (note that the bounding box is shown spaced apart from the walls of the house for ease of understanding, but in the case of box 302 it could be drawn right next to the walls of the house). That is, AABBs work particularly well when the underlying geometry is well aligned with the local axes. However, the sloping roof section of the model is more problematic. Even with the roof split into two parts, front and back, both AABBs 304 and 306 still include considerable empty space (e.g., Figure 3 (best seen in B)—most of AABBs 304 and 306 are empty space, which in turn means that many rays found to intersect those AABBs may not intersect the underlying geometry of the roof. In this case, the surface of the roof may be better represented by two OBBs, Figure 3 C) are shown as 308 and 310. Thus, based solely on the degree to which the box bounds the underlying geometry, it can be seen that OBB may be beneficial when the underlying geometry is not well aligned with the local axes.
[0065] However, AABBs are also advantageous in the sense that they can be stored with fewer values (since the axes for each box do not need to be stored). An AABB can be stored with 6 values per box, whereas an OBB would require 12 values if the axes were to be stored explicitly with the OBB. This is important when considering the impact of obtaining bounding box data for performing ray tracing for many rays and / or complex hierarchies. It is also computationally simpler to perform intersection tests on AABBs than on OBBs (e.g., because the coordinates of a face are more likely to include zero or one, particularly if a unit AABB is used). Another advantage of AABBs is that the computation of the parent AABB for a set of child AABBs is relatively simple (i.e., by determining the maximum / minimum distance along the axis that the child AABB faces).
[0066] As a result of the above considerations, conventional ray tracing systems typically use AABBs to build acceleration structures. However, it is now recognized that the introduction of instances in modern ray tracing systems opens up the possibility of combining some of the benefits of OBBs and AABBs.
[0067] As mentioned above, instancing allows the same model to be utilized multiple times in world space. Even if a particular scene does not use multiple versions of the same model, the scene will still be constructed by taking the model constructed in its own local coordinate system and transforming it to its position in world space. That is, the ray tracing framework must perform a transformation on the model to place it in world space, regardless of whether the model is used multiple times.
[0068] Consider a model with a bounding volume hierarchy (BVH) composed of AABBs, which is instantiated within a scene by referencing the underlying model and a model-to-world space transformation matrix (e.g., a 4×3 matrix in homogeneous coordinate representation). The model-to-world space transformation matrix (also referred to herein as the model transformation matrix) is defined to place the model and its associated BVH in world space. Since the model will be arbitrarily arranged in world space, it will be understood that after the transformation, the AABB of the model BVH in the model coordinate system actually becomes an OBB in the world space coordinate system. It will also be understood that transforming the model to world space using a given matrix to test against a ray defined in world space is mathematically equivalent (in terms of determining whether an intersection occurs) to transforming the same ray by the inverse matrix of the given matrix, thereby testing the ray against the same model defined in the model coordinate system. As a result, when performing an intersection test with a ray, it is therefore beneficial to actually transform the ray into the model's coordinate system by using the inverse matrix of the transformation matrix that places the model in world space. That is, it is beneficial to perform the test in this manner so that the computational advantages of testing against AABBs can be achieved. This also avoids the need to transform the entire BVH to world space, allowing the same BVH to be reused for each instance of the model.
[0069] As a result, an instance-based ray tracing system must retrieve matrices and perform transformations each time it is desired to test against an instance model, whether transforming rays into model space or transforming models into world space. In addition, as described above, each model must be considered instantiated, even if it is only used once. Therefore, it has been recognized that further benefits can be provided by utilizing transformations that are always performed in this way. In particular, assuming that the system requires a mechanism for performing these transformations, further transformations (which can be mathematically combined with existing transformations being performed) can be included to allow efficient use of OBBs. By determining the OBB for the nodes within the model to be instantiated, and by recognizing that a transformation is required anyway to bring the ray into the coordinate system of the model, the further transformations can be combined into one matrix operation to apply to the ray, thereby accounting for the transformation between the OBB and the AABB in the model system. As a result, even if the basic geometry of the OBB is initially determined, the transformed ray can be effectively tested against the AABB.
[0070] This is Figure 4 The 2D example is further illustrated. Figure 4 Aspects of the same ray intersection system in different coordinate systems are shown, where the same elements in the different coordinate systems are represented by the same reference numerals with different letter suffixes ("w" represents Figure 4 A) in the world space, "m" represents Figure 4 B) in the model space, and "t" represents Figure 4 The transformation space of C) in . Figure 4 404w is at an angle to the world space axes. An OBB 406w for the object is also shown. In world space, a ray 408w is shown, and it is desired to determine whether the ray will intersect the object 402w. As described above, since the boxes are rotated compared to the axes (i.e., box 404 is actually an OBB in world space, but an AABB in model space), testing the ray against box 404w in world space will not be as computationally efficient as testing the same box 404m in model space. Figure 4 B) shows the Figure 4 A) is the same system as in FIG. 4, but in the object coordinate system. Also shown is the transformation matrix M representing the transformation of object 402m from local / model space to world space. Obj_to_World The arrow at Figure 4 extends between the objects in A) and B). Thus, we can see that Figure 4 Ray 408m in B) has been transformed by the inverse of the transformation that originally placed the object in world space (and Figure 4 The object in B) is now untransformed). It can be seen that Figure 4 During the transformation between A) and B) in FIG. 4 , the relative orientation of ray 408 and object 402 is maintained (so the answer to the question of whether the ray intersects the object is unchanged). However, in this coordinate system, the test is less computationally difficult because box 404m is now an AABB in the relevant (i.e., model) coordinate system for the test. Figure 4 C) in FIG. 404 takes into account a further transformation to align the OBB 406t with the coordinate system, effectively transforming it into an AABB. Also shown is the transformation matrix M representing the transformation performed. OBB_to_AABB The arrow at Figure 4 406 and 408. Again, it can be seen that applying this transformation to both OBB 406 and ray 408 does not change the relative orientation of the ray and the object, and therefore does not change the result of whether the ray will intersect the object. Figure 4 As shown in B), since the axes of box 406t are aligned with the axes of the test coordinate system and are therefore effectively AABBs, the test is also computationally relatively simple. Figure 4 B) and C) in the figure can be seen immediately, compared with Figure 4 C) in block 406t tests ray 408t, instead of using Figure 4Performing the corresponding test at block 404m in B) will result in a "miss" at block 406t rather than a "hit" at block 404m (which will then require further testing of lower level bounding volumes to ultimately determine that the underlying object 402 was not hit). Figure 4 The test in C) provides the benefits of both AABBs (in terms of computational simplicity) and OBBs (in terms of tightly bounded objects and therefore earlier detection of misses). This can be achieved in practice, for example, by defining the OBB in the node's model space according to a transformation matrix that maps between the OBB and the AABB in model space, and storing the AABB and associated transformation matrix. The transformation matrix can then be used to transform the ray (along with the inverse of the transformation that originally placed the object in world space) before testing the ray against the AABB mapped to the OBB by the transformation matrix.
[0071] in other words, Figure 4 The test in C) in effectively exploits the following observations: (1) it is the relative orientation of the ray and bounding volume that is important for determining intersection, not the orientation of the ray / bounding volume system with respect to the coordinate system, and (2) the orientation of the ray / bounding volume system with respect to the coordinate system is important for the efficiency of computing the intersection. Furthermore, practical exploitation of these observations identifies that instance-based ray tracing systems already apply transformations to each instance model, so performing an OBB-to-AABB transformation can be combined with existing transformation operations in an efficient manner (as discussed in more detail below and in Figure 4 As shown in Figure 4 An arrow is indicated between A) and C) in FIG. 1 that represents the total transformation to be performed on the ray used for the intersection test, which is equivalent to (M Obj_to_World ) -1 *M OBB_to_AABB ). For completeness, note that in a practical implementation, for any mapping between world and object space in an instance-based ray tracing system, one needs to take into account the floating point round-off errors introduced by the transformations, and the effect these errors may have on the results of the intersection tests. However, this is beyond the scope of this discussion.
[0072] However, identifying the optimal OBB for each node in the BVH of a model can itself be computationally expensive.
[0073] Thus, it has been determined that when analyzing a model to create a BVH, it is advantageous to use only OBBs that can be mapped to AABBs via one of a fixed set or palette of predetermined transformations (e.g., representing rotations or other transformations such as affine transformations). In this case, the set is "fixed" in the sense of a finite number of nodes (or just fewer than the number of branch nodes) than the number of nodes in the model (typically much less). This is based on the understanding that, for example, there is only a small incremental testing benefit to having an OBB offset from the AABB by 1° (in a given direction), while for arbitrary geometry, the greatest benefit can be expected to be achieved by selecting an OBB offset from the AABB by 45°. That is, in the 1° example, most rays that would intersect the AABB will still intersect the OBB; conversely, in the 45° example, a large number of rays that would intersect the AABB can be expected to not intersect the OBB. In this way, by using a relatively small alignment set of OBBs, a significant advantage in intersection testing (i.e., early identification of misses) can be achieved. The system may store a set of local transforms once for a model in memory, and may store an OBB for a node (with a corresponding AABB to which it will be mapped, unless the system assumes a single unit AABB and the transforms take into account scaling and translation, but this may be undesirable if there are many nodes in the model) with an indication (e.g., a simple index) of the associated one of the set of local transforms for the particular node.
[0074] The palette of matrices stored with the model BVH may be referred to as a palette or set of "local transformation matrices" because they represent transformations within the local coordinate system of the model, i.e., the mapping between OBBs and AABBs in the local coordinate system. Palettes may be defined for all nodes in the BVH or for multiple nodes representing a subset of all nodes (e.g., only branch nodes in the BVH, or only certain elements of the model, such as nested instances, as discussed in more detail below).
[0075] This method is Figure 5 and Figure 7 Shown in. Figure 5 A basic 2D model of a person 500 with an associated bounding volume hierarchy is shown, while Figure 7 is a flow chart of the method steps. Figure 7 Method 700 begins at step 702 by receiving a model to be used in constructing a scene to be ray traced. The BVH of the model is defined by the ray tracing system, although, for example, a developer who created the model may provide hints as to what may be appropriate. In any case, at step 704, the ray tracing system identifies nodes (e.g., regions of the model) to form a BVH structure. Figure 5, the BVH is shown on the model 500 as dashed boxes 510 and 518, and the tree diagram 530 (which is a partial acceleration structure - even though the bottom-most node in the tree diagram 530 is still a branch node, because the diagram does not show the nodes of the final primitives within the bounding box, the tree diagram 530 is not a complete BLAS, but is useful for understanding the purpose of the present invention). Figure 5 In the example of FIG. 5 , a palette of transformation matrices 540 has been established, corresponding to Figure 7 Step 708. How to build the palette is discussed in more detail below. The tree diagram also indicates an index identifying a particular matrix in the matrices stored in the palette 540, also as described below.
[0076] To create the bounding volume hierarchy of model 500, it is divided into six components: head 501, torso 502, left arm 503, right arm 504, left leg 505, and right leg 506. It may also be desirable to further group the two legs together into another node, and similarly group the head and torso into another node. After identifying the relevant nodes, we then group them according to Figure 7 Step 710 determines the OBB for each node. Each OBB is related to the AABB in the model coordinate system by one of the local transformation matrices in the option board 540. As a result, each component has its own associated bounding volume OBB: head OBB 511, torso OBB 512, left arm OBB 513, right arm OBB 514, left leg OBB 515, and right leg OBB 516. There is also a total bounding volume for the model 510. The OBBs for the legs are further grouped together into another "parent" leg OBB 518, and similarly, a parent upper body OBB 517 is defined for the head and torso. A tree diagram 520 defines this structure as a series of nodes. The root node 520 corresponds to the overall model bounding box 510. This node is linked to four child branch nodes: upper body node 527, left arm node 523, right arm node 524, and leg node 528. The left arm node 523 and the right arm node 524 do not have additional child branch nodes associated with them. However, the upper body node 527 is associated with two additional child (branch) nodes, the head node 511 and the trunk node 512, while the leg node 528 is associated with the left leg node 525 and the right leg node 526.
[0077] Notice, Figure 5The example provides a single bounding volume for each node, but this need not be the case. For example, a single acceleration structure node may be defined with respect to both the right leg 508 and the right arm 504. Both bounding volumes 518 and 514 may be associated with the conceptual node. Such an arrangement may be beneficial because it only requires one ray transformation (i.e., for the node) to perform two ray intersection tests (one test for each bounding volume). This saves the cost of the transformation compared to having separate nodes for separate bounding volumes. However, it will be apparent that, according to the present approach, each bounding volume associated with a node will therefore reference the same transformation matrix, which will require further consideration when defining the node. For example, legs 505 and 506 may be represented by different bounding boxes within one node, rather than as Figure 5 508 and right arm 504 into the same node, as they will both optimally reference the same local transformation matrix. However, it may not be desirable to associate these elements with the same node, as they are judged to be too far apart (and therefore the node will include many empty volumes). Conversely, it may be desirable to share a node with the head 501 and torso 502, as they are close to each other, but this will not be possible as they do not all share the same optimal local transformation matrix. Thus, a node may or may not be associated with more than one bounding volume.
[0078] It can be seen that OBBs 510-518 include some boxes that are aligned with the axes of the model coordinate system (and are therefore effectively AABBs) and some boxes that are at other angles. For example, head OBB 511 is rotated 45° relative to the axis, right arm OBB 514 and leg OBBs 515, 516 and 518 are rotated 55° counterclockwise (CCW), and left arm OBB 513 is rotated 55° clockwise (CW). It can also be seen that these OBBs are not necessarily the most perfect OBBs that can be defined (for example, a tighter OBB could be defined for the right leg 506). However, for each branch node, an OBB has been defined based on the best one of a finite set of local transformation matrices established in palette 540. Palette 540 contains a set of transformations that map between OBBs and AABBs in the model coordinate system (note that in this example the mapping is indicated as from OBB to AABB, also as Figure 4 (not shown, but it will be appreciated that the mapping may be defined in the other direction, with the inverse appropriately accounted for in later calculations). The first transform (with index 0) is the identity transform, which will be used for AABBs, and it will also be used for primitive intersection testing.
[0079] Stepping away from this example to consider transformations more generally, a set of transformations may be arbitrarily predefined, for example to represent a selection of transformations expected to yield test benefits, such as a combination of 45° rotations around the axes. Alternatively, they may be defined after analyzing the model. For example, a model (such as Figure 7 704) to determine the optimal OBB for each node, and the distribution of the ideal OBB can be used to define a representative set of transformations for the model. Alternatively, a palette of transformations can be constructed by using existing transformations (e.g., starting from an equivalent to an AABB), unless it can be determined that a new transformation will allow the formation of an OBB for the node that is more suitable than by using any existing transformation by more than a threshold amount. As an example, such a threshold can be set to, for example, a volume reduction (e.g., absolute, fractional, or percentage) compared to the volume reduction that can be achieved using the best existing transformation in the palette, or a surface area reduction, or a cross-sectional area reduction in a given direction (e.g., the principal axis of the OBB or the intended principal viewing direction). As another example, a candidate palette of transformations can be defined (e.g., 20 transformations, representing rotations equivalent to different icosahedrons), which can be reduced to a final palette (e.g., 4 or 8 transformations) based on the analysis of the model. The best approach will depend on the situation. For example, it can be determined that there is not much benefit to be gained by performing extensive analysis on a small model or a model that is not instantiated many times, and therefore, in any case, a small model is likely to be traversed by relatively few rays. Conversely, if it is known that the model will be instantiated many times in the scene, it may be worthwhile to perform a more detailed analysis to select a palette of transforms, since rays are likely to be tested against instances of the BVH relatively often, and so greater gains may be achieved in the speed with which intersection testing for the scene as a whole is completed through optimization of transform selection. In other cases, it may not be desirable to spend the time to perform an extensive analysis (regardless of model size or frequency of use), and so a predetermined palette of fixed transforms may be used throughout.
[0080] As will be apparent from the foregoing discussion, the order of steps 704, 706, 708, 710 may vary depending on the implementation. For example, if an analysis of the model is to be performed to identify the optimal OBB, the OBB may be determined before or concurrently with the palette of local transformations. In fact, if the analysis is combined with the analysis of the definition nodes, the analysis may even precede the definition of the BVH nodes. Thus, it will be appreciated that the present invention is not limited to a particular order of these steps.
[0081] The number of transforms in the palette is limited, but can be varied as desired, with different benefits arising from using relatively few transforms (e.g., simplicity / speed of BVH creation) as compared to using a larger number (e.g., a tighter fit of the BVH to the model), and different benefits may be desired in different environments. However, in an example implementation, the palette may include 4 transform matrices (e.g., including one transform matrix corresponding to the AABB - i.e., the identity matrix - and three single 45° rotations about each of the three coordinate axes) or 8 transform matrices (e.g., built based on the four transform matrices from the previous example, and adding three combinations of two 45° rotations (one about each of two different axes) and another combination of three 45° rotations (one about each of the three axes)). Other implementations may employ fewer than 4, or between 4 and 8, or more than 8 transform matrices.
[0082] In some implementations, the transformation matrix can be a 3×3 matrix for a 3D system (although other dimensional transformations can be used, for example, if perspective distortion is to be performed). However, for conventional 3×3 matrix transformations, there is scope to avoid storing 9 values (e.g., 9 floating point values) for each matrix, depending on the implementation. For example, by relying on the associated AABB for scaling, only 8 values can be stored. Alternatively, since the mapping between OBBs and AABBs is primarily rotational, instead of storing each transformation as a 3×3 matrix (e.g., 9 floating point values) as part of the model's acceleration structure, the transformations can be stored as quaternions (e.g., 4 floating point values). This can provide some advantages in reducing the data stored for the acceleration structure, but may incur a computational penalty if the quaternion needs to be converted back to a 3×3 matrix to be combined with the model transformation matrix. Whether this is worthwhile will depend on the application.
[0083] return Figure 5 For example, the process of determining the OBB for each node of the model 500 may include selecting an OBB from a set of candidate OBBs, for which each candidate OBB is mapped to a different AABB in the local coordinate system by one of the transformations in the palette 540. The best OBB for each node may be selected from the candidate OBBs according to a predetermined heuristic. For example, the selected OBB may be a candidate OBB with a minimum volume, a minimum surface area, or a minimum cross-sectional area in a particular direction.
[0084] In any case, with the set of local transforms established as shown in palette 540, the BVH 510 can be defined using OBBs that are each mapped to an AABB using one of the predetermined transforms. After the OBB for a given node has been determined, an indication of the associated one of the local transform matrices and the AABBs that can be mapped to the OBB using the indicated local transform matrix can be associated with the node. An indication of the appropriate transform matrix can be associated with each node, for example as an index linked to palette 530. This is shown in the tree diagram 530, for which each box representing a node indicates the associated index in palette 530. Then, according to Figure 7 At step 712 , the model and its BVH, along with the AABBs in the palette and the associations with the transforms, may be stored in memory along with the indexed palette 530 .
[0085] When a model is positioned or "instantiated" in a scene (e.g., as a BLAS within a TLAS), a model transformation matrix is defined for that positioning to bring the model into the overall world space coordinate system of the scene. Typically, this will be a single matrix transformation, although it can also be done as a combination of matrix transformations. As described above, rays can be transformed by the inverse of the model transformation matrix to bring the rays into the model coordinate system. To save matrix operations, once a model is instantiated, a separate local transformation matrix can be multiplied by the model transformation matrix (or, if multiple model transformation matrices are used, the local transformation matrix can be combined with only one of those model transformation matrices) and stored in memory as a collection or palette of "instance transformation matrices" associated with that particular instance of the model. In this way, different palettes of instance transformation matrices can be created for different instances of the model (because they will be associated with different model transformation matrices).
[0086] When these updated palettes are stored in memory, the index of the palette compared to the initial local transformation palette can remain unchanged. That is, if the palette of local transformation matrices is used to generate an instance transformation matrix palette, the matrices with the same index in the two palettes will be related by the model transformation matrix. In other words, the order of the matrices in the palette is maintained. As a result, the index associated with the node in the base model BVH will still correctly index the correct matrix in the palette of the instance transformation matrix. That is, because the BVH node simply indicates that the matrix in the palette is the appropriate matrix to be used (for example, by index), then after instantiation, in the instance transformation matrix palette, the indication will continue to point to the correct matrix. In other words, in addition to the palette of transformation matrices, no other data defining the BVH needs to be modified to illustrate the instance. This maintains the benefit of only needing to create a base model BVH once for multiple instances. In contrast, for example, if the local transformation matrix is explicitly stored for each node, the local transformation matrix needs to be updated for each node for each new instance, which will be much less efficient.
[0087] Thus, it is apparent that an advantage of the described system is that once the model transformation matrix is known, each set of instance transformation matrices can be computed once, rather than repeating the combination of the two transformations (the model transformation and the local transformation) each time a node in the model BVH is used in an intersection test. In other words, at the point where a ray is tested, the ray can be transformed in a single operation by the appropriate instance transformation matrix for the particular node, rather than by a series of operations applying the appropriate individual local transformation matrices as well as the model transformation matrix. Thus, the ray intersection test itself incurs little, if any, additional computational cost compared to conventional ray tracing systems that support instances (where matrix transformations are required to perform intersection testing anyway).
[0088] Figure 6 An example of the above example is shown, Figure 8 A corresponding method of constructing the acceleration structure 800 is shown. Figure 6 , the example 2D scene 610 includes multiple instances of the model 500. The instances can be grouped into an overall acceleration structure, as shown by the boxes in the scene 610 and the corresponding tree diagram. The tree node 620 corresponds to the entire scene 610, and the nodes 621, 622, 623, 624, 625 and 626 correspond to the boxes 611, 612, 613, 614, 615 and 616, respectively. It can be understood that the nodes 622-626 correspond to the model bounding box 510 and its associated bounding volume hierarchy. In other words, the tree diagram is a TLAS, and its bottom layer corresponds to an instance of the BLAS, which is the acceleration structure of the model 500.
[0089] In addition, each of blocks 612-616 is Figure 5An instance of the model frame 510 of , which has been positioned in the scene coordinate space by the model transformation matrix. Figure 6 As shown in the bottom flowchart, for each instance k, when the instance is created in the scene, the inverse of the model transformation matrix is combined with the palette of local transformation matrices of the model 500 to produce a palette of instance transformation matrices for the specific instance. That is, in order to be received ( Figure 8 After step 802 of the example above, an acceleration structure is built for the scene 610. For each instance of the model 500, a palette of local transformation matrices for the BVH of the model is accessed (step 804), and multiple local transformation matrices of the BVH are updated for the instance (step 806) to become a set of instance transformation matrices. The update is performed by combining each individual local transformation matrix with the model transformation matrix (note that the combination may involve combining the inverse of one or more of these matrices with other matrices, depending on how the transformation is defined) so that the branch nodes of the instance of the model each become associated with one of the instance transformation matrices. As described above, if the node already references the relevant transformation matrix by an index, this association with the instance transformation matrix can be achieved without modifying other data of the BVH, because the index can then be used to replace the palette of references to the instance transformation matrix. As will also be understood from the above, a different set of instance transformation matrices will be established for each instance of the model 500, because each instance uses a different model transformation matrix. This is in Figure 8 8 is represented by a loop around steps 804 and 806, indicating that those steps are repeated for each instance of each model until the acceleration structure is completed.
[0090] When it comes to tracing rays through scene 610, the instance transformation matrix may be used to transform the rays when performing intersection tests with the associated instances of the model. Fig. 9A method 900 for doing so is shown. When it is determined that a ray intersects a node (e.g., one of nodes 622, 623, 625, or 626) of an acceleration structure 620 representing an instance of a model 500 (step 902), it is then necessary to evaluate whether the ray intersects any branch nodes of the BVH for that instance of the model. In the first case, this will be done for each child of the root node. Only one such branch node is considered, which has an OBB defined in the model coordinate system and is stored in terms of an AABB and a reference to a transformation matrix that maps between the AABB and the OBB. The ray tracing system then identifies (step 904) the instance transformation matrix associated with the branch node from a palette of instance transformation matrices defined for that model instance. This can be accomplished, for example, using an index in a memory of a node stored in the acceleration structure 530. The ray can then be transformed using the identified instance transformation matrix (step 906). In other words, the ray can be transformed in one step by a matrix that represents a combination of the inverse of the model transformation matrix for placing a particular instance of model 500 and the mapping between the OBB for the branch node and the AABB in the model coordinate system. After the transformation is performed, an intersection test can be performed (step 908). For example, these steps of tracing the ray can be accomplished using fixed-function intersection test logic.
[0091] The above examples consider ray tracing in the context of instantiating individual models. However, it is also possible to have so-called "nested instantiations" where one model includes one or more instances of another model. For example, a scene may include multiple instances of the same plant model, but the plant model itself may have multiple instances of the same flower model, which in turn may include multiple instances of the same petals. However, this traditional nesting can lead to the problem of requiring a large number of transformations to build the scene. That is, referring back to the same example, each instance of the petal model will require a transformation to position it within the flower model, each instance of the flower model will require a transformation to position it within the plant model, and each instance of the plant model will require a transformation to position it at the scene. The combination of nested instances effectively results in a unique transformation being applied to the lowest level elements - in other words, if there are M plants, each with N flowers and P petals, then there are MxNxP transformation matrices, which will each require, for example, a separate 3×4 transformation matrix.
[0092] As a result, nested instancing can result in there being many transformations that need to be stored. Thus, a point arises where it is preferable to flatten the scene to reduce the number of nested instances (e.g., to only one level of instancing), but this comes with a disadvantage in the size of the data required to define each model and therefore the entire scene. That is, if a plant model is simplified to remove the nested models for flowers and petals, the equivalent data for each instance of those models must be added to the plant model itself. This reduces the number of transformations required, but increases the size of the device model.
[0093] An alternative to flattening the nested instances is to store a hierarchy of transformations. However, this again creates problems when it comes to testing ray intersections, because each ray must now be transformed by a series of matrices, and such matrix operations are expensive (as discussed above, the single matrix operation required to support instances of modern ray tracing systems is exploited to provide additional advantages without adding additional matrix operations at the point of testing rays).
[0094] In contrast, it can be observed that in many common situations where nested instantiation may be needed, there are a relatively small number of different orientations that are needed to nest the models. For example, when creating a scene that includes many instances of the same building, the building may be located on a grid-like road system, and therefore the building may only be located in one of four rotational positions. Similarly, the building itself may have four sides, each with multiple instances of the same window, but the window will only need to be instantiated in one of the four orientations corresponding to each of the four sides. In this case, it will be apparent that the instances can even share the same scale (e.g., the windows are the same size everywhere they appear, and the building is the same size throughout the scene), so that only the translation will be different for instances of the same orientation.
[0095] Thus, by applying the same principles as described above, it can become more manageable to support multiple levels of nesting without incurring the full cost of implementing traditional nesting. That is, for a two-level nesting of a scene comprising, for example, M buildings, each with N windows, there is no need to create M×N separate transformation matrices. Instead, the building model can store (in this case) a palette of 4 local transformation matrices (e.g., 3×3 matrices) to account for rotation and scaling, and only store an additional translation for each window instance (e.g., just another 3 floating point values). Each window instance (which would be represented by a node in the building's BVH) can then be stored in the building BVH with an indication of the associated transformation matrix from the palette of transformation matrices. The indication can be an index, which is cheaper to store than a full transformation matrix for each nested instance (even considering storing the translation values as well).
[0096] The foregoing description has focused on the use of OBBs and the transform mapping between OBBs and AABBs, since AABBs are computationally less expensive during intersection testing. However, it will be appreciated that the described methods and systems are equally applicable to other geometries, where a first bounding volume may be mapped to a second bounding volume that is computationally less expensive to perform intersection testing. In a general sense, any oriented bounding volume (OBV) may be associated with an axis-aligned bounding volume (AABV) by the described methods. For example, an oriented elliptical bounding volume of a node may be associated with a transform to an axis-aligned elliptical bounding volume or a (less flexible, but computationally cheaper) spherical bounding volume.
[0097] Although the foregoing description has focused on leveraging transformations that have been performed when instantiating a model in TLAS, it will be appreciated that similar benefits can be obtained when considering the nodes of TLAS itself in a system that supports BLAS instantiation.
[0098] TLAS nodes typically have bounding volumes defined in world space, and so are likely to have been defined as AABBs or other AABVs in world space. Thus, if both the AABVs and rays are defined in world space, no strict transformation between coordinate systems is required when testing for intersection of rays with TLAS AABVs. However, a hardware ray tracing system may not be able to distinguish between TLAS intersection tests and BLAS intersection tests in terms of its processing pipeline. In this case, when the test is performed, an identity transformation can effectively be applied to the ray or TLAS AABV, thereby performing the same steps as for a BLAS intersection test. Even if this is not the case, the system will have to be configured to perform the transformation used for BLAS testing (to handle instances) and so that the configuration can be extended to cover TLAS testing. As a result, for a ray tracing system that supports instances, OBV support can be incorporated into TLAS in the same way as for BLAS.
[0099] That is, one or more transformation matrices may be associated with a TLAS. Compared to the model BVH, it is preferred that each TLAS node stores one transformation, rather than using a palette of transformations for the TLAS that the node references, because the number of TLAS nodes is relatively small compared to the number in a BLAS. However, in some cases, it may still be desirable to have a palette of transformations. Fig.10 A method 1000 for creating a TLAS is shown. At step 1002, a scene is received, and at step 1004, a TLAS node is defined. As described above, a palette of transformations may optionally be defined for the TLAS, so this is not necessary in the example of FIG. Fig.10In any case, for each defined TLAS node, the OBV can be determined and the node can be associated with a transformation matrix that maps between the OBV and the AABV (step 1008). The associated matrix for each node can be stored in memory by indication (e.g., by index if the TLAS palette is used) along with the AABV with TLAS (step 1010). Fig.10 This can be repeated for each TLAS node as shown.
[0100] Similarly, when starting to trace a ray through a TLAS, one can evaluate whether the ray intersects a node of the TLAS, such as Fig.11 and method 1100. When determining to test a ray for TLAS (step 1102), a transformation matrix associated with a node (e.g., via an index stored for the node) that represents a mapping between the OBV and the AABV for the node in a global coordinate system can be identified at step 1104. Then, at step 1106, the ray can be transformed using the identified matrix, and then, at step 1108, the transformed ray can be used in an intersection test.
[0101] Fig.12 A computer system is shown in which the ray tracing graphics processing system described herein can be implemented. The computer system includes a CPU 1202, a GPU 1204, a memory 1206, and other devices 1214, such as a display 1216, a speaker 1218, and a camera 1222. A processing block or module 1210 is implemented on the GPU 1204 for performing the methods described herein. In other examples, the processing block or module 1210 can be implemented on the CPU 1202. The components of the computer system can communicate with each other via a communication bus 1220. The storage device 1212 is implemented as part of the memory 1206.
[0102] Although Fig.12 One implementation of a ray tracing graphics processing system is shown, but it will be appreciated that a similar block diagram could be drawn for an artificial intelligence accelerator system, for example, by replacing the CPU 1202 or GPU 1204 with a neural network accelerator (NNA) 1211, or by adding an NNA as an additional unit. In this case, processing block 1210 could be implemented in the NNA.
[0103] Figure 7-11The ray tracing method is shown as including a number of functional steps. This is illustrative only and is not intended to define a strict division between different logical elements of these steps. Each step may be provided in a hardware system in any appropriate manner. It should be understood that the intermediate values described herein as being formed during the creation of the bounding volume hierarchy and the acceleration structure may not be physically generated by the ray tracing graphics system at any point, and may merely represent logical values that conveniently describe the processing performed by the ray tracing graphics system between its inputs and outputs.
[0104] The ray tracing graphics processing system described herein can be embodied as hardware on an integrated circuit. The ray tracing graphics processing system described herein can be configured to perform any method described herein. Generally speaking, any of the functions, methods, techniques or components described above can be implemented in software, firmware, hardware (e.g., fixed logic circuitry) or any combination thereof. The terms "module", "function", "component", "element", "unit", "block" and "logic" can be used herein to generally represent software, firmware, hardware or any combination thereof. In the case of software implementation, a module, function, component, element, unit, block or logic represents a program code that performs a specified task when executed on a processor. The algorithms and methods described herein can be performed by one or more processors that execute code, which causes the processor to perform the algorithm / method. Examples of computer-readable storage media include random access memory (RAM), read-only memory (ROM), optical disks, flash memory, hard disk storage, and other memory devices that can use magnetic, optical and other technologies to store instructions or other data and can be accessed by a machine.
[0105] As used herein, the terms computer program code and computer readable instructions refer to any kind of executable code for execution by a processor, including code expressed in machine language, interpreted language, or scripting language. Executable code includes binary code, machine code, byte code, code that defines an integrated circuit (such as a hardware description language or netlist), and code expressed in programming language codes such as C, Java, or OpenCL. Executable code can be, for example, any kind of software, firmware, script, module, or library that, when properly executed, processed, interpreted, compiled, run in a virtual machine or other software environment, causes a processor of a computer system supporting the executable code to perform the tasks specified by the code.
[0106] A processor, computer or computer system may be any kind of device, machine or special purpose circuit, or a collection or part thereof, which has processing capabilities so that instructions can be executed. A processor may be or include any kind of general or special purpose processor, such as a CPU, GPU, NNA, system on chip, state machine, media processor, application specific integrated circuit (ASIC), programmable logic array, field programmable gate array (FPGA), etc. A computer or computer system may include one or more processors.
[0107] The present invention is also intended to cover software that defines the configuration of hardware as described herein, such as hardware description language (HDL) software for designing integrated circuits or for configuring programmable chips to perform desired functions. That is, a computer-readable storage medium having computer-readable program code in the form of an integrated circuit definition data set encoded thereon may be provided, which, when processed (i.e., run) in an integrated circuit manufacturing system, configures the system to manufacture a ray tracing graphics processing system configured to perform any of the methods described herein, or to manufacture a ray tracing graphics processing system including any of the apparatus described herein. The integrated circuit definition data set may be, for example, an integrated circuit description.
[0108] Thus, a method of manufacturing a ray tracing graphics processing system as described herein in an integrated circuit manufacturing system may be provided. In addition, an integrated circuit definition data set may be provided which, when processed in an integrated circuit manufacturing system, enables the method of manufacturing a ray tracing graphics processing system to be performed.
[0109] The integrated circuit definition data set may be in the form of computer code, for example as a netlist, code for configuring a programmable chip, as a hardware description language that defines hardware suitable for fabrication at any level in an integrated circuit, including as register transfer level (RTL) code, as a high-level circuit representation such as Verilog or VHDL, and as a low-level circuit representation such as OASIS (RTM) and GDSII. Higher-level representations that logically define hardware suitable for fabrication in an integrated circuit, such as RTL, may be processed on a computer system configured to generate a manufacturing definition of the integrated circuit in the context of a software environment that includes definitions of circuit elements and rules for combining those elements to generate a manufacturing definition of the integrated circuit defined by the representation. As is typically the case with software executed at a computer system to define a machine, one or more intermediate user steps (e.g., providing commands, variables, etc.) may be required to configure the computer system to generate a manufacturing definition of the integrated circuit to execute code that defines the integrated circuit to generate the manufacturing definition of the integrated circuit.
[0110] Now refer to Fig.13 An example of processing an integrated circuit definition data set at an integrated circuit manufacturing system to configure the system to manufacture a ray tracing graphics processing system is described.
[0111] Fig.13 An example of an integrated circuit (IC) manufacturing system 1302 is shown, which is configured to manufacture a ray tracing graphics processing system as described in any of the examples herein. Specifically, the IC manufacturing system 1302 includes a layout processing system 1304 and an integrated circuit generation system 1306. The IC manufacturing system 1302 is configured to receive an IC definition data set (e.g., defining a ray tracing graphics processing system as described in any of the examples herein), process the IC definition data set, and generate an IC (e.g., which embodies a ray tracing graphics processing system as described in any of the examples herein) based on the IC definition data set. Through processing of the IC definition data set, the IC manufacturing system 1302 is configured to manufacture an integrated circuit embodying a ray tracing graphics processing system as described in any of the examples herein.
[0112] The layout processing system 1304 is configured to receive and process an IC definition data set to determine a circuit layout. Methods for determining a circuit layout based on an IC definition data set are known in the art and may, for example, involve synthesizing RTL code to determine a gate-level representation of a circuit to be generated, for example, in terms of logic components (e.g., NAND, NOR, AND, OR, MUX, and FLIP-FLOP components). By determining location information for the logic components, the circuit layout may be determined based on the gate-level representation of the circuit. This may be done automatically or with user involvement in order to optimize the circuit layout. When the layout processing system 1304 has determined the circuit layout, it may output the circuit layout definition to the IC generation system 1306. The circuit layout definition may be, for example, a circuit layout description.
[0113] As is known in the art, IC generation system 1306 generates an IC according to the circuit layout definition. For example, IC generation system 1306 may implement a semiconductor device manufacturing process to generate an IC, which may involve a multi-step sequence of photolithography and chemical processing steps during which electronic circuits are gradually formed on a wafer made of semiconductor material. The circuit layout definition may be in the form of a mask that can be used in a photolithography process to generate an IC according to the circuit definition. Alternatively, the circuit layout definition provided to IC generation system 1306 may be in the form of a computer readable code that IC generation system 1306 may use to form a suitable mask for generating an IC.
[0114] The different processes performed by IC manufacturing system 1302 may all be performed at one location, such as by one party. Alternatively, IC manufacturing system 1302 may be a distributed system such that some processes may be performed at different locations and by different parties. For example, some of the following stages may be performed at different locations and / or by different parties: (i) synthesizing RTL code representing an IC definition data set to form a gate-level representation of a circuit to be generated; (ii) generating a circuit layout based on the gate-level representation; (iii) forming a mask based on the circuit layout; and (iv) using the mask to manufacture the integrated circuit.
[0115] In other examples, processing of an integrated circuit definition data set in an integrated circuit manufacturing system may configure the system to manufacture a ray tracing graphics processing system without processing the IC definition data set to determine a circuit layout. For example, the integrated circuit definition data set may define a configuration of a reconfigurable processor such as an FPGA, and processing of the data set may configure the IC manufacturing system to generate a reconfigurable processor having the defined configuration (e.g., by loading the configuration data into the FPGA).
[0116] In some embodiments, when processed in an integrated circuit manufacturing system, the integrated circuit manufacturing definition data set can cause the integrated circuit manufacturing system to generate an apparatus as described herein. Fig.13 An integrated circuit manufacturing system configured in the manner described can manufacture the apparatus described herein.
[0117] In some examples, the integrated circuit definition data set may include software that runs on, or in combination with, hardware defined at the data set. Fig.13 In the example shown, the IC generation system can be further configured by the integrated circuit definition dataset to load firmware onto the integrated circuit according to the program code defined at the integrated circuit definition dataset when manufacturing the integrated circuit, or otherwise provide the integrated circuit with program code for use with the integrated circuit.
[0118] Compared to known implementations, the implementation of the concepts set forth in this application in devices, equipment, modules and / or systems (and in the methods implemented herein) can cause performance improvements. Performance improvements can include one or more of improved computing performance, reduced waiting time, increased throughput and / or reduced power consumption. During the manufacture of such devices, equipment, modules and systems (e.g., in integrated circuits), a trade-off can be made between performance improvements and physical implementations to improve manufacturing methods. For example, a trade-off can be made between performance improvements and layout area to match the performance of known implementations, but using less silicon. For example, this can be accomplished by reusing functional blocks in a serial manner or sharing functional blocks between elements of devices, equipment, modules and / or systems. On the contrary, the concepts of improvements (such as reduced silicon area) that cause physical implementations of devices, equipment, modules and systems set forth in this application can be weighed against performance improvements. For example, this can be accomplished by manufacturing multiple instances of modules within a predefined area budget.
[0119] Applicants hereby independently disclose each individual feature described herein and any combination of two or more such features, to the extent that such feature or combination can be implemented according to the common general knowledge of a person skilled in the art based on the specification as a whole, regardless of whether such feature or combination of features solves any problem disclosed herein. In view of the foregoing description, it will be clear to a person skilled in the art that various modifications can be made within the scope of the invention.
Claims
1. A computer-implemented method of constructing a ray tracing acceleration structure for a scene defined relative to a global coordinate system, the acceleration structure comprising a top-level acceleration structure TLAS, the top-level acceleration structure having leaf nodes referencing one or more instances of a bottom-level acceleration structure BLAS, the method comprising: Define one or more TLAS nodes; as well as for each TLAS node, determining a first bounding volume in the global coordinate system, and associating the TLAS node with a transformation matrix that maps between the first bounding volume and a second bounding volume in the global coordinate system, Wherein the first bounding volume is an oriented bounding volume and the second bounding volume is an axis-aligned bounding volume.
2. The method of claim 1 , wherein the method further comprises defining a plurality of transformation matrices for the TLAS, and wherein associating the TLAS node comprises associating the TLAS node with one of the plurality of transformation matrices that maps between the first bounding volume and the second bounding volume in the global coordinate system, wherein, The number of the plurality of transformation matrices is less than the number of the TLAS nodes. The method of claim 2 , wherein the plurality of transformation matrices each represent a different mapping. The method according to claim 2 , wherein determining the first bounding volume comprises selecting a bounding volume from a set of candidate bounding volumes. The method of claim 4 , wherein each candidate bounding volume is associated with a different one of the plurality of transformation matrices. The method of claim 5 , wherein selecting comprises comparing the set of candidate bounding volumes and selecting the best bounding volume according to a predefined heuristic.
7. The method of claim 2, wherein associating the TLAS node with one of the plurality of transformation matrices comprises storing an indication of the corresponding transformation matrix of the TLAS node.
8. The method of claim 1, wherein the first bounding volume is an oriented ellipsoid and the second bounding volume is a sphere or an axis-aligned ellipsoid.
9. The method of claim 1, further comprising using the TLAS to perform intersection testing in a ray tracing system.
10. A computer-implemented method for tracing rays of a scene defined relative to a global coordinate system by an acceleration structure, the acceleration structure comprising a top-level acceleration structure TLAS, the top-level acceleration structure having leaf nodes referencing one or more instances of a bottom-level acceleration structure BLAS, the method comprising: evaluating whether a ray intersects a node of the TLAS, the node having a first bounding volume defined in the global coordinate system, wherein the evaluating comprises: identifying a transformation matrix associated with the node, the transformation matrix representing a mapping between the first bounding volume and a second bounding volume of the node in the global coordinate system; and transforming the ray using the identified transformation matrix to test whether the ray intersects the node, Wherein the first bounding volume is an oriented bounding volume and the second bounding volume is an axis-aligned bounding volume.
11. The method of claim 10, wherein identifying comprises identifying a transformation matrix from a plurality of transformation matrices defined for the TLAS.
12. The method according to claim 10 or 11, wherein the accelerating structure is constructed according to any one of claims 1 to 9.
13. A ray tracing system configured to construct a ray tracing acceleration structure for a scene defined relative to a global coordinate system, the acceleration structure comprising a top-level acceleration structure TLAS, the top-level acceleration structure having leaf nodes referencing one or more instances of a bottom-level acceleration structure BLAS, the ray tracing system comprising modules configured to: Define one or more TLAS nodes; For each TLAS node, determining a first bounding volume in the global coordinate system, and associating the TLAS node with a transformation matrix that maps between the first bounding volume and a second bounding volume in the global coordinate system; and storing the TLAS in a memory, including the second bounding volume and the associations between the TLAS nodes and the transformation matrices, Wherein the first bounding volume is an oriented bounding volume and the second bounding volume is an axis-aligned bounding volume.
14. The ray tracing system of claim 13, wherein the module is further configured to define a plurality of transformation matrices for the TLAS, and wherein associating the TLAS node comprises associating the TLAS node with a transformation matrix of the plurality of transformation matrices, wherein, The number of the plurality of transformation matrices is less than the number of the TLAS nodes.
15. The ray tracing system of claim 14, wherein the module is configured to define a bounding volume by selecting a bounding volume from a set of candidate bounding volumes.
16. The ray tracing system of claim 15, wherein each candidate bounding volume is associated with a different one of the plurality of transformation matrices, and / or wherein the selecting comprises comparing the set of candidate bounding volumes and selecting the best bounding volume according to a predefined heuristic.
17. The ray tracing system of any one of claims 13 to 16, wherein storing the association between the TLAS node and the transformation matrix comprises storing an index identifying the transformation matrix.
18. The ray tracing system of claim 13, wherein the first bounding volume is an oriented ellipsoid and the second bounding volume is a sphere or an axis-aligned ellipsoid.
19. A ray tracing system configured to trace rays of a scene defined relative to a global coordinate system via an acceleration structure, the acceleration structure comprising a top-level acceleration structure TLAS, the top-level acceleration structure having leaf nodes referencing one or more instances of a bottom-level acceleration structure BLAS, the ray tracing system comprising intersection testing logic, the intersection testing logic being configured to: identifying a transformation matrix associated with a node of the TLAS, the node having a first bounding volume defined in the global coordinate system, the transformation matrix representing a mapping between the first bounding volume and a second bounding volume of the node in the global coordinate system; transforming the ray using the identified transformation matrix; and evaluating whether the ray intersects the node, Wherein the first bounding volume is an oriented bounding volume and the second bounding volume is an axis-aligned bounding volume.
20. The ray tracing system of claim 19, the intersection testing logic configured to identify a transformation matrix from a plurality of transformation matrices defined for the TLAS.
21. The ray tracing system of claim 19, wherein the ray tracing system is configured to perform the method of any one of claims 1 to 12.
22. A graphics processing system configured to execute the method according to any one of claims 1 to 12.
