Intersection test method, intersection test module and medium in ray tracing system
By projecting the vertices of the convex polygon to a pair of axes orthogonal to the direction of the light rays, and determining the intersection parameters of the rays and edges according to the sorting and position of the projected vertices, the problem of large amount of intersection tests and calculations in the ray tracing system is solved, and the system performance improvement and resource optimization are achieved.
Patent Information
- Application Number
- CN202210262465.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2021-03-23
- Filing Date
- 2022-03-17
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2042-03-17
AI Technical Summary
In a ray tracing system, the computational work required to perform intersection tests of rays with multiple convex polygons is high, resulting in increased system delay, power consumption, and size.
Simplify the intersection test of rays and convex polygons by projecting the vertices of the convex polygon onto a pair of axes orthogonal to the direction of the rays and determine the intersection parameters of the rays and edges according to the sorting and position of the projected vertices.
This method reduces the complexity and computational volume of intersection tests in ray tracing systems, improves system performance, and reduces latency, power consumption, and size.
Smart Images

Figure CN115115757B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to techniques for performing intersection testing in a ray tracing system. Background Art
[0002] Ray tracing is a computational rendering technique used to generate an image of a scene (e.g., a 3D scene) by tracing a light path ('ray') through the scene, usually from the perspective of a camera. Each ray is modeled as originating from a camera and entering the scene through a pixel. As the ray traverses the scene, it may intersect with an object within the scene. The intersection between the ray and the object it intersects may be modeled to create realistic visual effects. For example, in response to determining that the ray intersects with the object, a shader program (i.e., a portion of a computer code) may be executed for the intersection. A programmer may write a shader program to define how the system reacts to an intersection (the intersection may, for example, result in one or more secondary rays being emitted into the scene), for example, to represent the reflection of the ray from the intersecting object or the refraction of the ray through the object (e.g., if the object is transparent or translucent). As another example, a shader program may cause one or more rays to be emitted into the scene for determining whether an object is in a shadow at an intersection. The result of executing the shader program (and processing the associated secondary rays) may be a color value of a pixel through which the ray passes.
[0003] Rendering an image of a scene using ray tracing can involve performing many intersection tests, such as performing billions of intersection tests to render an image of the scene. In order to reduce the number of intersection tests that need to be performed, a ray tracing system can generate an acceleration structure, wherein each node of the acceleration structure represents an area within the scene. The acceleration structure is typically hierarchical (e.g., having a tree structure) such that it contains multiple levels of nodes, wherein nodes near the top of the acceleration structure represent relatively large areas in the scene (e.g., the root node can represent the entire scene), and nodes near the bottom of the acceleration structure represent relatively small areas in the scene. A "tree node" refers to a node having a pointer to other nodes in a hierarchical acceleration structure, i.e., a tree node has child nodes in a hierarchical acceleration structure. A "leaf node" refers to a node having one or more pointers to one or more primitives, i.e., a leaf node does not have child nodes in a hierarchical acceleration structure. In other words, a leaf node of an acceleration structure represents an area in a scene that defines one or more primitives. The acceleration structure may have different structures in different examples, such as a grid structure, an octree structure, a space partitioning structure (e.g., a kd tree), or a bounding volume hierarchy. A node may represent a suitable shape or area (which may be referred to as a "box" in this article) in a scene. In some examples, a node represents an axis-aligned bounding box (AABB) in the scene.
[0004] An acceleration structure can be used to perform an intersection test on a ray by first testing the intersection of the ray with the root node of the acceleration structure (e.g., recursively). If the ray is found to intersect with a parent node (e.g., a root node), the test can be performed to the child nodes of the parent node. In contrast, if the ray is found not to intersect with the parent node, the intersection test of the child nodes of the parent node can be avoided, thereby saving computational effort. If the ray is found to intersect with a leaf node, the ray can be tested against the objects in the area represented by the leaf node to determine which object(s) the ray intersects with. Objects can be represented as convex polygons. Convex polygons are usually triangles, but they can also be other shapes, such as squares, rectangles, pentagons, hexagons, etc. If the ray is found to have more than one intersection point, the intersection point closest to the ray origin (i.e., the first intersection encountered by the ray in the scene) can be identified, and it can be determined that the ray intersects at this identified closest intersection point. It is possible that there are multiple closest hits for a ray, and in this case some tie-break logic may be used to select one of the multiple closest hits to use as the closest intersection to identify. For some types of rays, it may not be necessary to identify the closest intersection. For example, when processing shadow rays, an indication that there is at least one intersection is sufficient without determining which intersection is closest, and some APIs may allow the traversal of the acceleration structure for shadow rays to terminate in response to finding any intersection, thereby reducing the number of intersection tests that need to be performed.
[0005] A ray (r) can be defined as r=O+Dt, where O is a vector representing the origin of the ray, D is a vector representing the direction of the ray, and t represents the distance from the origin along the ray. Primitives can be represented as convex polygons or further strictly as convex polygons. A polygon (such as a triangle) is defined by an ordered set of planar vertices, whereby consecutive pairs of vertices define polygon edges, and given a fixed orientation (i.e., clockwise or counterclockwise), the total vertex order (its winding order) is used to indicate the front face of the polygon. A convex polygon is a polygon that has no internal angle greater than 180°. A strictly convex polygon is a polygon that has no internal angle greater than or equal to 180°. The origin and direction vectors defining the ray and the positions of the vertices defining the convex polygon can be represented by components in a spatial coordinate system. A spatial coordinate system can represent the world space of the scene being rendered, or it can represent the instance space of an object instance placed within the scene being rendered.
[0006] In order to determine whether a ray intersects a convex polygon, the intersection of the ray and the plane containing the convex polygon can be determined, and then it can be determined whether the intersection is on the inside of the polygon. A general method is to map the vertex (i.e., the coordinates in the world or instance space) to the plane via a projection parallel to the direction of the ray. If the ray is not contained, the plane can be freely specified so that both orthogonal projection and oblique projection are allowed. This simplifies the problem to a 2D problem, and there are many ways to determine whether a 2D point is inside a 2D convex polygon. For example, in the case where the convex polygon is a triangle, the intersection can be transformed into the UV coordinates of the triangle, which makes the intersection test simple. If it is determined that the ray intersects a point on the boundary of the polygon (i.e., an edge or vertex), problems may arise. In particular, objects are usually represented by multiple polygons, such as polygon meshes, resulting in shared vertices that define two or more convex polygons. In addition, polygons can have shared edges, that is, edges where both endpoints are shared vertices. An important type of shared vertex is a vertex at the center of a closed sector: a closed sector is defined as two or more polygons that share a vertex connected by shared edges, such that these shared edges are the only edges that share a vertex as one of their endpoints. If a ray intersects a point on a shared edge of a closed sector or a shared vertex, then in most cases it is expected that the ray will be found to intersect one or more of the polygons. An intersection test is described as "watertight" if the intersection test ensures that a ray that intersects a point on a shared edge of a closed sector or a shared vertex intersects at least one of the polygons. An intersection test is described as "non-redundantly watertight" if the intersection test ensures that a ray that intersects a point on a shared edge of a closed sector or a shared vertex intersects one (and only one) of the polygons, noting that in this case only a subset of its boundaries can be considered part of the polygon. If a ray that intersects a point on a shared edge is found to intersect zero polygons, it can appear as if the polygon mesh has a hole in it, so that the color behind the polygon mesh can be seen through the mesh in the rendered image (this can happen with non-watertight intersection tests but not for watertight intersection tests). For example, if the color behind a polygon mesh is significantly different from the color of the polygon mesh, these kinds of rendering errors can be very noticeable. In addition, if a ray that is found to intersect a point on a shared edge intersects more than one polygon, the color rendered at that location on that shared edge may depend on the order in which the polygons are tested for intersection, so that rendering may become non-deterministic. These kinds of rendering errors can be detrimental to the perceived quality of the rendered image. Additional reasons for having non-redundant strict intersection testing include: (i) to avoid redundant work, and (ii) to avoid shadow discontinuities at any double / multiple hits caused by repeated intersections in transparent objects.Testing a ray for intersection with a first polygon is typically performed independently of testing a ray for intersection with a second polygon, and it is noted that ensuring strictness, and in particular, ensuring non-redundant strictness for intersection tests is not straightforward.
[0007] Because intersection testing of rays against convex polygons (e.g., triangles) is performed multiple times in a ray tracing system, it can be beneficial to implement the functionality for performing these intersection tests in a dedicated hardware module, for example using fixed-function circuitry, rather than using a software module that executes on a general-purpose processing unit to implement these intersection tests. Software implementations are generally more flexible because software is easier to change than hardware implementations after it is designed and / or created. However, hardware implementations generally provide more efficient implementations in terms of latency and power consumption, so if the required functionality is known in advance, a hardware implementation may be preferred over a software implementation. When designing a hardware implementation of an intersection test module configured to perform intersection testing, there are generally the following competing goals: (i) having a smaller size (i.e., smaller silicon area), (ii) having lower latency, and (iii) having lower power consumption. Summary of the invention
[0008] 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.
[0009] A method of performing intersection testing of a ray with respect to a plurality of convex polygons in a ray tracing system is provided, wherein each of the convex polygons is defined by an ordered set of vertices, and wherein at least one of the vertices is a shared vertex for defining two or more of the convex polygons, the method comprising:
[0010] Projecting the vertices of the convex polygon onto a pair of axes orthogonal to the ray direction, wherein the origin of the pair of axes corresponds to the ray origin, and wherein the vertex ordering scheme defines an ordering of the projected vertices that is independent of an ordering of the vertices in an ordered set of vertices defining the convex polygon; and
[0011] For each convex polygon in ConvexPolygons:
[0012] for each edge of the convex polygon defined by two of the projected vertices, determining a parameter indicating which side of the edge the ray passes through, wherein if it is determined that the ray intersects a point on the edge, the parameter is determined based on whether an ordering of the projected vertices defining the edge defined by the vertex ordering scheme matches an ordering of vertices in an ordered set of vertices defining the convex polygon; and
[0013] determining whether the ray intersects the convex polygon based on the parameters determined for the edges of the convex polygon;
[0014] Wherein for each of two or more of the convex polygons, the ray is determined to intersect a point on an edge of the convex polygon.
[0015] Determining a parameter indicating which side of the edge the ray passes through may include determining a signed parameter using a function defining positions of two projected vertices of the edge; and wherein determining whether the ray intersects the convex polygon may be based on a sign of the signed parameter determined for the edge of the convex polygon.
[0016] Determining whether the light ray intersects the convex polygon may include: determining that the light ray intersects the convex polygon if the signed parameters determined for the edges of the convex polygon all have the same sign; and determining that the light ray does not intersect the convex polygon if it is not the case that the signed parameters determined for the edges of the convex polygon all have the same sign.
[0017] Determining whether the ray intersects the convex polygon may include determining that signed parameters of any edges of the convex polygon having zero magnitude have a particular sign; and determining that signed parameters of edges of the convex polygon having non-zero magnitude have signs consistent with each other.
[0018] This function can be the two projected vertices v that define the edge. i and v j The 2D cross product of the position f(v i ,v j ), which is defined as f(v i ,v j )=p i q j -q i p j , where p i and q i is the projected vertex v i The components along the corresponding axes of a pair of axes, and where p j and q j is the projected vertex v j Components along corresponding axes of a pair of axes.
[0019] If the 2D cross product of the positions of the two projected vertices defining the edge has a magnitude of zero, then you can be sure that the ray intersects a point on the edge.
[0020] The two projected vertices v that define the edge i and v j can be provided to the 2D cross product f(v) in an order defined by the ordering of the vertices in the ordered set of vertices defining the convex polygon. i ,vj ), and the sign of the signed parameter of the edge can be determined as follows: if the ray is determined not to intersect a point on the edge, then the sign is the same as f(v i ,v j ) has the same sign, and if the ray is determined to intersect a point on the edge, the sign is The symbol of , where according to the vertex sorting scheme, if the projected vertex v i At the projected vertex v j Before, v i <v j = 1, and according to the vertex sorting scheme, if the projection vertex v j At the projected vertex v i Before, v i <v j =0.
[0021] The two projected vertices v that define the edge i and v j can be provided to the 2D cross product in an order defined by the vertex ordering scheme, such that the 2D cross product is determined as f(max(v i ,v j ),min(v i ,v j )), where the sign of the signed parameter of the edge can be determined as The sign is the same as that of i At the projected vertex v j Before, v i <v j =1, max(v i ,v j )=v j And min(v i ,v j )=v i , and according to the vertex sorting scheme, if the projection vertex v j At the projected vertex v i Before, v i <v j =0, max(v i ,v j )=v i and
[0022] If it is determined that the ray intersects a point on an edge of a convex polygon, the method may further include performing an XOR operation using: (i) the sign of the signed parameter of the edge, and (ii) an indication of the perceived orientation of the convex polygon, wherein a determination of whether the ray intersects the convex polygon may be based on a result of the XOR operation.
[0023] The ordering of vertices according to the vertex ordering scheme may depend on a projection used to project the vertices of the convex polygon onto a pair of axes.
[0024] The vertex sorting scheme can sort the projected vertices so that: along the corresponding axis of a pair of axes, the vertices have components p i and q i The first projection vertex v i Along the corresponding axis of a pair of axes, the j and q j The second projection vertex v j Before, the condition was p i <p j Or the condition is (p i =p j And q i j ), and along the corresponding axis of a pair of axes has a component p i and q i The first projection vertex v i Along the corresponding axis of a pair of axes, the j and q j The second projection vertex v j After that, the condition is p i >p j Or the condition is (p i =p j And q i >q j ).
[0025] Determining whether the light ray intersects the convex polygon may include using parameters determined for the edges of the convex polygon to determine whether the light ray passes inside the edges of the convex polygon, wherein if it is determined that the light ray passes inside all edges of the convex polygon, it can be determined that the light ray intersects the convex polygon, and if it is determined that the light ray passes outside one or more edges of the convex polygon, it can be determined that the light ray does not intersect the convex polygon.
[0026] A light ray and a convex polygon may be defined in 3D space using a spatial coordinate system, and the projecting of the vertices of the convex polygon onto a pair of axes orthogonal to the light direction may include transforming the vertices of the convex polygon into a light ray coordinate system, wherein the light ray coordinate system has an origin at the light ray origin, and wherein the light ray coordinate system has three basis vectors, wherein a first basis vector of the basis vectors is aligned with the light ray direction; and wherein a second basis vector and a third basis vector of the basis vectors are respectively aligned with a pair of axes orthogonal to the light ray direction, wherein the second basis vector and the third basis vector: (i) are not parallel to each other, and (ii) have zero as a component when expressed in the spatial coordinate system. When expressed in the spatial coordinate system, the second basis vector and the third basis vector of the basis vectors of the light ray coordinate system may have a value of ±1 as a component.
[0027] The component D in the spatial coordinate system can be used x , D y and D z to define the light direction vector, and wherein the method may further include selectively displacing and / or inverting the light and the x, y and z components of the vertices defining the convex polygon before transforming the vertices of the convex polygon into the light coordinate system, so that D z ≥D x ≥0 and D z ≥D y ≥0.
[0028] A convex polygon may be a triangle.
[0029] The method may also include outputting an indication of a result of determining whether the ray intersects the convex polygon. The output indication may be used in a ray tracing system to render an image of the 3D scene.
[0030] The method may further include, if it is determined that the ray intersects the convex polygon, determining an intersection distance and a barycentric coordinate of the intersection, wherein the intersection distance and the barycentric coordinate may be used in a ray tracing system to render an image of the 3D scene.
[0031] An intersection test module for use in a ray tracing system is provided, the module being configured to perform intersection tests of a ray with respect to a plurality of convex polygons, wherein each of the convex polygons is defined by an ordered set of vertices, and wherein at least one of the vertices is a shared vertex for defining two or more of the convex polygons, the intersection test module being configured to:
[0032] Projecting the vertices of the convex polygon onto a pair of axes orthogonal to the ray direction, wherein the origin of the pair of axes corresponds to the ray origin, and wherein the vertex ordering scheme defines an ordering of the projected vertices that is independent of an ordering of the vertices in an ordered set of vertices defining the convex polygon; and
[0033] For each convex polygon in ConvexPolygons:
[0034] for each edge of the convex polygon defined by two of the projected vertices, determining a parameter indicating which side of the edge the ray passes through, wherein the intersection test module is configured to, if it is determined that the ray intersects a point on the edge, determine the parameter based on whether an ordering of the projected vertices defining the edge defined by the vertex ordering scheme matches an ordering of vertices in an ordered set of vertices defining the convex polygon; and
[0035] Whether the ray intersects the convex polygon is determined based on parameters determined for the edges of the convex polygon.
[0036] The intersection test module can be configured to, for each convex polygon in the convex polygons: determine a parameter indicating which side of the edge the ray passes through by determining a signed parameter using a function that defines the positions of two projected vertices of the edge; and determine whether the ray intersects the convex polygon based on the sign of the signed parameter determined for the edge of the convex polygon.
[0037] The intersection test module can be configured to determine, for each convex polygon in the convex polygons, whether the light ray intersects with the convex polygon by the following operations: if the signed parameters determined for the edges of the convex polygon all have the same sign, then it is determined that the light ray intersects with the convex polygon; and if it is not the case, then it is determined that the light ray does not intersect with the convex polygon: the signed parameters determined for the edges of the convex polygon all have the same sign.
[0038] The intersection test module can be configured to determine, for each convex polygon in the convex polygons, whether the ray intersects the convex polygon by: determining that the signed parameters of any edges of the convex polygon with zero magnitude have a specific sign; and determining that the signed parameters of the edges of the convex polygon with non-zero magnitude have signs consistent with each other.
[0039] The intersection test module may also be configured to output an indication of a result of determining whether the ray intersects the convex polygon, wherein the output indication may be used in a ray tracing system for rendering an image of the 3D scene.
[0040] An intersection testing module may be provided, configured to perform any of the methods described herein.
[0041] A computer readable code may be provided, which is configured to cause any of the methods described herein to be performed when the code is executed.
[0042] A method of performing intersection testing of a ray with respect to a plurality of convex polygons in a ray tracing system may be provided, wherein each of the convex polygons is defined by an ordered set of vertices, and wherein at least one of the vertices is a shared vertex for defining two or more of the convex polygons, the method comprising:
[0043] Projecting the vertices of the convex polygon onto a pair of axes orthogonal to the direction of the light ray, wherein the origin of the pair of axes corresponds to the origin of the light ray; and
[0044] For each convex polygon in ConvexPolygons:
[0045] For each edge of the convex polygon defined by two of the projected vertices, determine a signed parameter, wherein the sign of the signed parameter indicates which side of the edge the ray passes through, wherein the first of the projected vertices v defining the edge i The position of is given by the coordinates p along the corresponding axis of a pair of axes i and q i Define, and where the second projected vertex v in the projected vertex that defines the edge j The position of is given by the coordinates p along the corresponding axis of a pair of axes j and q j The definition is as follows, wherein if it is determined that the ray intersects a point on the edge, a module is used to determine the sign of the signed parameter, the module being configured to:
[0046] The p i ,q i 、p j and q j an indication as input of whether each of the coordinates is classified as negative, zero, or positive, and
[0047] For p i ,q i 、p j and q j valid combinations of coordinate classifications, an indication of the sign of the output signed parameter; and
[0048] determining whether the ray intersects the convex polygon based on the sign of the signed parameter determined for the edge of the convex polygon;
[0049] For two or more of the convex polygons, the ray is determined to intersect with points on the edges of the convex polygons.
[0050] An intersection test module for use in a ray tracing system may be provided, the module being configured to perform an intersection test of a ray relative to a plurality of convex polygons, wherein each of the convex polygons is defined by an ordered set of vertices, and wherein at least one of the vertices is a shared vertex for defining two or more of the convex polygons, the intersection test module being configured to:
[0051] Projecting the vertices of the convex polygon onto a pair of axes orthogonal to the direction of the light ray, wherein the origin of the pair of axes corresponds to the origin of the light ray; and
[0052] For each convex polygon in ConvexPolygons:
[0053] For each edge of the convex polygon defined by two of the projected vertices, determine a signed parameter, wherein the sign of the signed parameter indicates which side of the edge the ray passes through, wherein the first of the projected vertices v defining the edge i The position of is given by the coordinates p along the corresponding axis of a pair of axes i and q i Define, and where the second projected vertex v in the projected vertex that defines the edge j The position of is given by the coordinates p along the corresponding axis of a pair of axes j and q j The intersection test module is configured to determine the sign of the signed parameter using a module if it is determined that the ray intersects a point on the edge, wherein the module is configured to:
[0054] The p i ,q i 、p j and q j an indication as input of whether each of the coordinates is classified as negative, zero, or positive, and
[0055] For p i ,q i 、p j and q j valid combinations of coordinate classifications, an indication of the sign of the output signed parameter; and
[0056] Whether the ray intersects the convex polygon is determined based on the sign of the signed parameter determined for the edge of the convex polygon.
[0057] A method of performing an intersection test of a ray with a convex polygon in a ray tracing system may be provided, wherein the ray and the convex polygon are defined in 3D space using a spatial coordinate system, and wherein the ray is defined using a ray origin and a ray direction, the method comprising:
[0058] The intersection test is performed using a ray coordinate system, where the ray coordinate system has an origin at the ray origin, and where the ray coordinate system has three basis vectors,
[0059] where the first of the basis vectors is aligned with the light direction, and
[0060] wherein a second basis vector and a third basis vector of the basis vectors: (i) are both orthogonal to the first basis vector, (ii) are not parallel to each other, and (iii) have zero as a component when expressed in the spatial coordinate system; and
[0061] The results of performing the intersection test are output for use by the ray tracing system.
[0062] An intersection test module configured to perform an intersection test of a ray and a convex polygon for use in a ray tracing system may be provided, wherein the ray and the convex polygon are defined in a 3D space using a spatial coordinate system, and wherein the ray is defined using a ray origin and a ray direction, the intersection test module being configured to:
[0063] The intersection test is performed using a ray coordinate system, where the ray coordinate system has an origin at the ray origin, and where the ray coordinate system has three basis vectors,
[0064] where the first of the basis vectors is aligned with the light direction, and
[0065] wherein a second basis vector and a third basis vector of the basis vectors: (i) are both orthogonal to the first basis vector, (ii) are not parallel to each other, and (iii) have zero as a component when expressed in the spatial coordinate system; and
[0066] The result of performing the intersection test is output for use by a ray tracing system.
[0067] The intersection test module may be embodied in hardware on an integrated circuit. A method of manufacturing the intersection test module at an integrated circuit manufacturing system may be provided. An integrated circuit definition data set may be provided, which, when processed in the integrated circuit manufacturing system, configures the system to manufacture the intersection test module. A non-transitory computer readable storage medium may be provided, having stored thereon a computer readable description of the intersection test module, which, when processed in the integrated circuit manufacturing system, causes the integrated circuit manufacturing system to manufacture an integrated circuit embodying the intersection test module.
[0068] An integrated circuit manufacturing system can be provided, comprising: a non-temporary computer-readable storage medium having stored thereon a computer-readable description of an intersection test module; a layout processing system configured to process the computer-readable description to generate a circuit layout description of an integrated circuit embodying the intersection test module; and an integrated circuit generation system configured to manufacture the intersection test module based on the circuit layout description.
[0069] A computer program code for executing any of the methods described herein may be provided. A non-transitory computer readable storage medium may be provided having computer readable instructions stored thereon which, when executed at a computer system, cause the computer system to perform any of the methods described herein.
[0070] As will be apparent to those skilled in the art, the features described above may be combined as appropriate and may be combined with any aspects of the examples described herein. BRIEF DESCRIPTION OF THE DRAWINGS
[0071] Examples will now be described in detail with reference to the accompanying drawings, in which:
[0072] Figure 1 A ray tracing system according to examples described herein is shown;
[0073] Figure 2 The ray and two polygons, the basis vectors of the space coordinate system, and the basis vectors of the ray coordinate system are shown;
[0074] Figure 3 is a flow chart of a method of performing intersection testing of a ray relative to a plurality of convex polygons according to examples described herein;
[0075] Figure 4 is a flow chart of a first example method of determining a parameter for indicating which side of an edge of a polygon a ray passes;
[0076] Figure 5 is a flow chart of a second example method of determining a parameter for indicating which side of an edge of a polygon a ray passes;
[0077] Figure 6 The rays intersecting the polygon are shown;
[0078] Figure 7a A ray intersecting a point on an edge shared between two polygons is shown, with the winding order of the two polygons indicated;
[0079] Figure 7b Shown with Figure 7a where the ray intersects a point on an edge shared between two polygons, and Figure 7bindicates the directions of the edges of the two polygons according to the vertex ordering scheme;
[0080] Figure 8a A ray intersecting a vertex shared between five polygons forming a closed fan is shown, wherein the winding order of the five polygons is indicated;
[0081] Figure 8b Shown with Figure 8a where the ray intersects a vertex shared by five polygons forming a closed fan, and Figure 8b The directions of the edges of the five polygons according to the vertex ordering scheme are indicated;
[0082] Fig. 9 is a flow chart of a third example method of determining a parameter for indicating which side of an edge of a polygon a ray passes;
[0083] Fig.10 shows the perturbation ε that can be applied to the vertex positions;
[0084] Figures 11a to 11l Shows different cases where the 2D cross product can be exactly zero;
[0085] Figures 12a to 12j shows an additional situation where the 2D cross product may be determined to be zero due to underflow when a rounding mode other than the away-from-zero rounding mode is used to determine the 2D cross product;
[0086] Fig.13a shows the rotation and reflection of a pair of polygons in the "winding / orientation-dependent" scheme;
[0087] Fig.13b shows the rotation and reflection of a pair of polygons in the "winding / orientation independence" scheme;
[0088] Fig.13c A mesh of polygons forming a circular band is shown, with an indication of which edges are considered part of which polygons in the "winding / orientation-dependent" scheme;
[0089] Fig.13d A mesh of polygons forming a circular band is shown, with an indication of which edges are considered part of which polygons in the "independence from winding / orientation" scheme;
[0090] Fig.14 A computer system is shown in which a ray tracing system is implemented; and
[0091] Fig.15 An integrated circuit manufacturing system for producing an integrated circuit embodying a ray tracing system is shown.
[0092] The accompanying drawings show 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
[0093] The following description is given by way of example to enable one skilled in the art to make and use the invention.The present 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.
[0094] Embodiments are now described by way of example only.
[0095] Even with the use of acceleration structures, the amount of work involved in performing intersection tests in a ray tracing system is still significant. For example, ray tracing can be used to render an image of a 3D scene, where the image may have about one million pixels. The pixel color value is derived from some distribution of samples associated with a point in the image plane (usually, there is a one-to-one correspondence between pixels and sample positions, but areas of the image may have higher or lower sample densities, or may otherwise be independent of the arrangement of pixels). In the context of ray tracing, the samples themselves are associated with a distribution of primary rays (in a statistical sense) parameterized by the neighborhood of each sample position. In the simplest example, a single primary ray is traced for each sample, and the result of the sample is determined using the primary ray. In other examples, multiple rays can be generated based on a distribution (e.g., random sampling) and some cumulative or combined results derived from individual primary rays. When it is determined that a ray intersects an object in the scene, a shader can be executed that can cause another ray (i.e., a "secondary ray") to be emitted into the scene. Each primary ray can cause the emission of several secondary rays, all of which are traced through the scene to determine their intersection points. Therefore, it is not uncommon to trace tens or hundreds of millions of rays through the scene to render an image. As graphics rendering technology has advanced, scenes to be rendered have become increasingly complex, so it is not uncommon for there to be thousands of objects in a scene, each of which may be represented by many primitives (e.g., polygons, such as triangles). In addition, the image being rendered may represent a frame in a series of frames to be rendered in real time, such as to be displayed to a user in real time. For example, a user may be playing a game, where the rendered image represents the user's view of a 3D scene as the user plays the game. In order to make the series of frames look like a continuous stream of video data, several frames per second may be rendered, such as 24, 30, or 60 frames per second, as some examples. Therefore, it can be understood that there is a lot of work involved in performing intersection tests in a ray tracing system to render a scene to be output in real time.
[0096] One way to overcome this problem and perform ray tracing to render the scene to be output in real time is to have one or more supercomputers perform all the processing. This can be considered a "brute force" approach. However, in addition to the goal of having high performance (performing ray tracing to render the scene to be output in real time), there is also a competing goal of reducing the size (e.g., silicon area) and power consumption of the ray tracing system. For example, there may be a goal of implementing a ray tracing system on a mobile device such as a tablet computer or a smartphone, whose acceptable size and power consumption may be much lower than that of a supercomputer. Therefore, when designing a ray tracing system, there may be a trade-off between performance, power consumption, and area. Depending on how this trade-off is implemented, the examples described herein may allow for improved performance without significantly increasing power consumption and area (compared to the prior art described above in the background section). Alternatively, in different implementations of the trade-off, the examples described herein may allow for reduced power consumption and / or size of the ray tracing system without significantly reducing the performance of the ray tracing system (compared to the prior art described above in the background section). Different implementations may be designed to target different points in the trade-off between performance, power consumption, and silicon area.
[0097] As mentioned above, since objects are often represented as a collection of convex polygons (non-convex polygons can be described in terms of the union of convex polygons), testing rays for intersection with convex polygons (e.g., triangles) is an extremely frequent operation in ray tracing systems. Therefore, any optimizations that can be made to the way intersection testing is performed can be very useful in optimizing the ray tracing system in terms of reducing its latency, power consumption, and size.
[0098] Furthermore, since such objects typically describe connected surfaces, whereby adjacent polygons have one or more shared vertices or edges, it is important that gaps do not appear spuriously as ray intersections sweep across the interior of the object, thereby producing apparent structural defects (which may be referred to as "rendering artifacts" in the rendered image). These may appear due to rounding errors or approximations in the intersection tests of each polygon, whereby implicit perturbations of shared vertices and / or edges may cause adjacent polygons to become disconnected when expressed in terms of their respective intersection results. Implementations that prevent any such disconnects from occurring may be referred to as "tight".
[0099] While the appearance of gaps can be mitigated by increasing the bounds of each convex polygon to some extent to provide a certain margin of error, it is also desirable to achieve a behavior that exhibits some form of non-redundant strictness, i.e., to minimize the number of intersections reported between a single ray and a single object. Therefore, it is preferred for an embodiment to provide consistent results in various polygon intersection tests, especially in those tests with common vertices and / or edges, without modifying the polygon bounds. However, in the general case, it is generally not feasible to implement completely accurate tests, so we have to ensure that whatever errors are introduced are compatible with the purpose of ensuring non-redundant strictness. If we restrict ourselves to the case where an edge is only considered to be common if it is defined by a pair of common vertices (so that there is no "T-junction"), this can be achieved by decomposing each intersection test into a projection of a polygon vertex on a plane (not containing rays) and then performing an exact intersection test in that plane. This series of operations merges all errors into the contribution of each vertex, ensuring that the results are consistent on connected triangles, because the common vertices remain common after the transformation (thereby preserving the local topology) and subsequent intersection tests are accurate.
[0100] In the context of the above operations, an implementation may be referred to as "non-redundant and strict" if and only if a single positive intersection result is reported for any (exact) set of common vertex or edge intersections in the plane. In other words, intersection tests of rays with convex polygons are "strict" if it is ensured that a ray that intersects a point on a shared edge of multiple polygons or a shared vertex of a closed fan is determined to intersect at least one of the polygons that share edges or vertices. Furthermore, intersection tests of rays with convex polygons are "non-redundant and strict" if it is ensured that a ray that intersects a point on a shared edge of multiple convex polygons or a shared vertex of a closed fan is determined to intersect a single polygon of the polygons that share edges or vertices (i.e., the ray is determined to intersect one and only one of the polygons that share edges or vertices).
[0101] The examples described here further define this strictness property by stipulating that shared edges and vertices belong to polygons with a consistent orientation, either relative to each other (distinguishing between outward-facing and inward-facing polygons, i.e., according to their winding order) or relative to the perspective of a light (distinguishing between front-facing and back-facing polygons). In practice, there are several (non-mutually exclusive) scenarios (or any combination thereof) where the properties of "strict" and / or "non-redundantly strict" may or may not apply: (i) shared vertices that are not closed sectors (e.g., boundary vertices of a mesh); (ii) non-manifold geometry, i.e., edges shared by three or more polygons; (iii) shared edges or shared vertices of closed sectors with polygons specified with inconsistent winding order (i.e., the endpoints of any shared edge are given in the same order); (iv) shared edges or shared vertices of closed sectors with polygons that are specified with consistent winding order (i.e., the endpoints of any shared edge are given in reverse order) and have more than one orientation (i.e., clockwise and counterclockwise) from the viewpoint of the ray (e.g., silhouette edges or vertices); (v) non-simple geometry, i.e., intersections between polygons that are not at shared edges or shared vertices (e.g., interior intersections, T-junctions); and (vi) redundant geometry, i.e., intersections of shared edges or shared vertices of closed sectors shared by degenerate polygons. In case (vi), it is desirable to keep the "strict" or "non-redundantly strict" property, but only when degenerate polygons are omitted.
[0102] In the example described in this article, the vertices of the convex polygon are projected onto a pair of axes orthogonal to the direction of the light, wherein the origin of the pair of axes corresponds to the origin of the light. In this way, the intersection test process for testing whether the light intersects with the convex polygon in the 3D scene is simplified to a 2D problem, which enables us to ensure strict intersection as described above. A pair of axes are not parallel to each other. The light is located at the origin of a pair of axes. The direction vector of the light has a zero value along two axes in a pair of axes. Therefore, only when the polygon covers the origin of a pair of axes is it determined that the light intersects with the polygon, wherein the light may intersect or not intersect with the polygon at its boundary. This article describes different examples for ensuring the rigor of the intersection test when the light intersects with a point on the edge of the polygon.
[0103] In the examples described herein, a pair of axes represents two basis vectors of a ray coordinate system. The specific ray coordinate system described herein is particularly useful for use in performing intersection testing in a ray tracing system, although in other examples, a pair of axes may not be part of the specific ray coordinate system described herein.
[0104] For example, in the ray coordinate system described herein, some of the components in the basis vectors are zero when expressed in a spatial coordinate system. In addition, the ray can be rescaled so that the largest component of the ray direction vector has unit magnitude. Since the scale value is either 1.0 or 0.0, the choice of a ray coordinate system and rescaling the ray in the examples described herein can make two-thirds of the tests mathematically cheaper. This can be achieved by performing a small amount of pre-computation that is constant for the ray, and thus the cost of performing this pre-computation can be reduced because the pre-computation is performed once for the ray and can then be used in many intersection tests involving the ray. For example, in the case where the ray direction vector D has a component D x , D y and D z In this case, the light can be pre-calculated and stored and The value of (or and As described in more detail below, the axes may be swapped (eg, permuted) to ensure that D z is the principal component of the light direction vector, i.e. |D z |≥|D x | and |D z |≥|D y |. Since any valid ray direction vector has non-zero magnitude, this means that |D z |>0. As another example, the ray's and The value of (or and The value of x and D y is non-zero, or if D x or D y is zero, then by using the concept of signed infinity as defined, for example, in the IEEE floating point format. In some instances, zero values may be replaced with non-zero values that are small enough to behave like zero in the operations described herein, and / or infinite values may be replaced with finite values that are large enough to behave like infinity in the operations described herein, and these examples make it unnecessary to treat some zeros and infinities as special cases and also avoid at least some ambiguous results that may result from multiplying or dividing by zero or infinity. Note that and The value of (or and As another example, the values of the light rays can be pre-calculated and stored. values. After these values have been pre-computed, they can be used to perform intersection tests on the rays. Pre-computed values can be used for multiple intersection tests that can be performed in parallel. In some examples, the pre-computed values are stored so that they can be read rather than calculated for use in performing intersection tests on the rays. In addition, rescaling the rays so that the largest component of the ray direction vector has unit magnitude and / or the selection of a ray coordinate system so that one or more components of the basis vectors are zero makes the processing of the rays easier to implement. By reducing the number of tests that need to be performed in order to determine whether a ray intersects a convex polygon and / or simplifying the processing of rays to determine whether a ray intersects a convex polygon, the latency, size and / or power consumption of an intersection testing module in a ray tracing system can be reduced.
[0105] Figure 1A ray tracing system 100 is shown that includes a ray tracing unit 102 and a memory 104. The ray tracing unit 102 includes a processing module 106, an intersection testing module 108, and processing logic 110. The intersection testing module 108 includes one or more box intersection testing units 112, one or more polygon intersection testing units 114, a ray rescaling unit 116, and an example transformation unit 118. It should be noted that there may be more than one ray rescaling unit and / or more than one example transformation unit. In operation, the ray tracing unit 102 receives geometric data defining objects within a 3D scene. The ray tracing unit 102 also receives ray data defining rays to be tested for intersection. The rays may be primary rays or secondary rays. The processing module 106 is configured to generate an acceleration structure based on the geometric data and send the acceleration structure to the memory 104 for storage therein. After the acceleration structure has been stored in the memory 104, the intersection test module 108 can retrieve the nodes of the acceleration structure (e.g., including data defining the axis-aligned boxes corresponding to the nodes) from the memory 104 to perform ray intersection tests for the retrieved nodes. To avoid reading the entire acceleration structure at once, the intersection test module 108 retrieves a subset of boxes from a layer of acceleration structures from the memory 104 at each stage based on the results of the previous intersection test. The box intersection test unit 112 performs intersection tests to determine whether the ray intersects with each of the bounding boxes corresponding to the nodes of the acceleration structure (where a miss can eliminate large pieces of the hierarchical acceleration structure). If the leaf node is determined to intersect, the polygon intersection test unit 114 performs one or more polygon intersection tests to determine which object(s) (if any) the ray intersects with. In this example, the convex polygon is a triangle, but it is noted that in other examples, the convex polygon can be other shapes, such as squares, rectangles, pentagons, hexagons, etc., as long as they are planar. The result of the intersection test indicates which object in the scene the ray intersected, and the result may also indicate the location on the object where the ray intersected the object, (e.g., barycentric coordinates), and may also indicate the distance along the ray at which the intersection occurred, and may also indicate the perceived orientation of the object from the perspective of the ray (e.g., clockwise / counterclockwise or front / back). In some cases, the intersection determination may be based on whether the distance along the ray at which the intersection occurred is between the minimum clipping distance and the maximum clipping distance (t min With t max ). In some cases, the intersection determination may be based on the perceived orientation of the object (e.g., for backface culling). The result of the intersection test is provided to the processing logic 110. The processing logic 110 is configured to process the result of the intersection test to determine a rendering value for an image representing the 3D scene. The rendering value determined by the processing logic 110 may be transferred back to the memory 104 to be stored therein to represent the image of the 3D scene.
[0106] In the examples described herein, the ray tracing system uses an acceleration structure in order to reduce the number of intersection tests that need to be performed for a ray with a convex polygon. Note, however, that some other examples may not use an acceleration structure and may simply test the ray for a convex polygon without first attempting to reduce the number of intersection tests that need to be performed using the acceleration structure.
[0107] Typically, when performing an intersection test of a ray with a convex polygon, the ray is defined according to the components in the spatial coordinate system in which the convex polygon is defined. However, in the examples described herein, a ray coordinate system is derived with respect to the ray itself, and the convex polygon can be mapped onto the ray coordinate system. The term "spatial coordinate system" is used here to refer to the coordinate system in which the convex polygon is defined. The "spatial coordinate system" can be a world space coordinate system or an instance space coordinate system. In most of the examples described herein, the spatial coordinate system is a three-dimensional coordinate system, and the convex polygon is a region of three-dimensional space that is completely contained in a plane defined by n≥3 line segments, so that all internal angles are less than or equal to 180°. A strictly convex polygon is a convex polygon in which all internal angles are strictly less than 180°.
[0108] The term "ray coordinate system" is used herein to refer to a coordinate system that is specific to a ray and has its origin at the ray origin. It should be noted that in the examples described in detail herein, the origin of the ray coordinate system is the origin of the ray, but in other examples, the origin of the ray coordinate system can be adjusted by appropriately adjusting the minimum and maximum clipping distances (t min and t max ), any point along the light ray can be used as the origin of the light ray coordinate system. The light ray coordinate system has three basis vectors. The first basis vector in the basis vectors is aligned with the light direction. The second basis vector and the third basis vector in the basis vectors are both orthogonal to the first basis vector and are not parallel to each other. In the examples described herein, the second basis vector and the third basis vector of the light ray coordinate system are generally not orthogonal to each other, but in some examples, they may be orthogonal to each other. In addition, in the examples described herein, when expressed in the spatial coordinate system, the second basis vector and the third basis vector of the light ray coordinate system have 0 as a component. In some examples, when expressed in the spatial coordinate system, the second basis vector and the third basis vector of the basis vector of the light ray coordinate system have a value of ±1 (i.e., a magnitude of 1) for one component.
[0109] In the example described herein, the intersection test module 108 uses a ray coordinate system to perform an intersection test to determine whether a ray intersects a convex polygon, wherein the ray and the convex polygon are defined in 3D space using a spatial coordinate system. The result of performing the intersection test on the ray is output from the intersection test module 108 for use by the ray tracing system, for example, to determine which shader program the processing logic 110 executes for the ray.
[0110] By subtracting the ray origin from the positions of the vertices defining the convex polygon, the vertices defining the convex polygon are translated for use in performing intersection tests using the ray coordinate system. Subtracting the ray origin from the positions of the vertices defining the convex polygon means that the position of the polygon is then defined relative to the ray origin. By first displacing the vertices using the ray origin, all relative errors in downstream calculations are centered about the ray origin. Assuming this is also true for the box tester, this makes it easier to ensure conservatism (i.e., no error negation).
[0111] Figure 2 A ray 202 and two convex polygons 204 and 206 are shown. These two polygons are triangles, and they share edges, thereby forming a quadrilateral. Figure 2 , the directions of the two polygons are represented as clockwise from the perspective of the light. Polygon 204 is defined by an ordered set of vertices (v0, v1, v2), and polygon 206 is defined by an ordered set of vertices (v1, v3, v2). The edge between vertices v1 and v2 is shared by polygons 204 and 206. Since v1 and v2 are defined in opposite order in polygons 204 and 206, the edge has an opposite direction in one polygon as in the other, so the two polygons are considered to be defined as having consistent winding. As described above, light ray 202, r(t), can be represented as r(t)=O+Dt, where O is a vector representing the origin of the light ray and D is a direction vector of the light ray, where O=(O x ,O y ,O z ) and D=(D x ,D y ,D z ). The x, y, and z basis vectors of the spatial coordinate system are Figure 2 As described above, the spatial coordinate system may be the world space coordinate system of the scene being rendered, or the spatial coordinate system may be an instance space coordinate system of a set of example geometric shapes within the scene being rendered. The origin of the ray coordinate system used in the intersection test is the origin of the ray. The positions of the vertices defining polygons 204 and 206 are transformed by subtracting the ray origin from the positions of the vertices. Figure 2 In the example shown, ray 202 intersects polygon 204 at intersection point 208 .
[0112] Additionally, in some examples described herein, the x, y, and z components of the ray and the vertices defining the convex polygon are selectively displaced prior to performing the intersection test so that |D z |≥|D x | and |D z |≥|D y |(Note that in these examples, for effective ray directions, we must also use |D z|>0). Perform a selective permutation of the axis so that D z will be the principal component of the light direction.
[0113] Figure 2 The relationship of the ray 202 and the polygons 204 and 206 with respect to the basis vectors is shown after a translation and optional displacement of the axes of the ray and the polygons has been performed so that the origin of the ray is at the origin of the coordinate system and so that |D z |≥|D x | and |D z |≥|D y |. This ensures that D z Non-zero, because effective light cannot make D x =D y =D z =0.
[0114] The basis vectors of the light coordinate system are Figure 2 In the figure, they are represented as P, Q and S. The first basis vector S of the light coordinate system is set to be along the direction of the light, S = A (D x ,D y ,D z ), where A is a scalar value. In some examples, Make
[0115] As an example (hereinafter referred to as “first example”), the second basis vector and the third basis vector P and Q may be defined as and More generally, if Figure 2 As shown in the example in, P = B (D z ,0,-D x ) and Q=C(0,D z ,-D y ), where B and C are any non-zero scalar values. To give some other examples, B can be ±1, ±sgn(D z ) or ±sgn(D x ) or any product of these nonzero scalar values, for example, and C can be ±1, or ±sgn(D z ), or ±sgn(D y ), or any product of these nonzero scalar values, such as Note that for non-zero values α, if α is positive, then sgn(α) = +1, and if α is negative, then sgn(α) = -1. If α = 0, then sgn(α) can be +1 or -1, depending on the sign bit of the floating-point representation of α. Note that the standard floating-point representation allows both +0 and -0 to be represented separately, and that unsigned 0 is typically identified as +0. In other words, if the adopted base distinguishes between -0 and +0 (as is the case with the IEEE floating-point system), then as an example, sgn(+0) = +1 and sgn(-0) = -1, otherwise sgn(0) = 1. The set of common values of A can be the union of the sets of common values of B and C. Note that S is orthogonal to P and Q, as can be seen from PS = QS = 0. However, according to D x and D y For example, unless D x or D y is zero, otherwise P and Q will not be orthogonal to each other. As mentioned above, P and Q are not parallel to each other, for example, P and Q are parallel to each other at least far enough so as not to cause problems due to rounding losses, otherwise the system may degenerate into a 1D scene. Note that D z cannot be zero, because the selective permutation of the axes makes D z is the principal component of the light direction, and since a valid light direction vector must have a non-zero magnitude in order to define a line. Therefore, among the possible components of the light basis vectors P and Q, and The value of is always well-defined and has a magnitude ranging from zero to an inclusive value, while and The value of has a magnitude ranging from one to positive infinity, inclusive.
[0116] The choice of scalar values A, B, and C may affect the handedness of the system. Figure 2 In , the world (or instance) space axes form a left-handed system. If we order the ray space axes as (X', Y', Z') = (P, Q, S), then they form a system with the same handedness (if and only if the principal axis is positive). Each scalar value (from the scalar values A, B, and C) that is negative flips the handedness of the system, e.g. from left-handed to right-handed. If an even number of scalar values A, B, and C are negative, then they cancel and we are back to a left-handed system.
[0117] The sign of the mapping from the space coordinate system to the light coordinate system can affect the perceived primitive orientation (given a fixed primitive winding). For example, a negative sign of the mapping can invert the primitive orientation, and a positive sign of the mapping can preserve the primitive orientation. As an example, the sign of the mapping can be given as:
[0118] sgn(D z )XOR sgn(A)XOR sgn(B)XOR sgn(C)XOR sgn(σ)(1)
[0119] where sgn(σ) indicates whether the permutation reverses the mapping sign.
[0120] When reversing the handedness of the system twice results in the original handedness, the terms are XORed together. For example, if A = 1 / |D z |,B=sgn(D z ) / D x ,C=sgn(D z ) / D y , then expression (1) becomes sgn(D x )XOR sgn(D y )XOR sgn(D z )XOR sgn(σ).
[0121] sgn(D z ) comes from the sign of the determinant of the basis transformation matrix (i.e., the three ray coordinate axes as rows or columns, with A=B=C=1 and the principal components having been permuted to the last row or column), which gives the signed volume of the transformed unit cube, equal to As the main component, D z The value is at least So the magnitude of the determinant is at least After normalizing the result by the product of the basis vector magnitudes, this gives a measure of how far the matrix is from being singular, i.e. how far the light coordinate system is from being degenerate, and hence how far the orthogonal axes are from being parallel. It is beneficial to have magnitudes for D such that these expressions do not underflow or overflow, to avoid potential precision problems when transforming vertices into light coordinates.
[0122] In higher n-dimensional constructions, this determinant reduces to D z (n-2) ||D|| 2 , both of which prove that the construction works for all n>1, and that Dz only affects the sign when n is odd.
[0123] The values of sgn(A), sgn(B), and sgn(C) come from the rescaling based on the light coordinate system described above. The value of the permutation symbol sigma σ comes from the way the light components are reordered (i.e., "permuted" by sigma σ) to place the primary component in a specific position (e.g., the final / z coordinate). This leaves us with two choices of which positions the secondary coordinates go into. One of these choices corresponds to rotating all coordinates, and the other corresponds to transposing two of the coordinates. For example, to simplify multiplexing, the permutation involves a transposition when Y is the primary component, and a rotation otherwise. For example, if X is the primary component of the light direction vector, the permutation of the axes is a rotation (x,y,z)->(y,z,x); if Y is the primary component of the light direction vector, the permutation of the axes is a transposition (x,y,z)->(x,z,y); and if Z is the primary component of the light direction vector, the permutation of the axes is the identity (x,y,z)->(x,y,z). This example provides simple multiplexing because there are only two inputs for the first two components. Transposing both of the coordinates results in a change of sign of the determinant since it is equivalent to exchanging two rows in the basis change matrix.
[0124] In another example (not shown in the figure, hereinafter referred to as the “second example”), the second and third basis vectors P and Q are defined as and In this example ( Figure 2 not shown), In general, these two examples can be described as the second basis vector P, which is defined as Right now or and the third basis vector Q, which is defined as Right now or
[0125] In another example (not shown in the drawings, hereinafter referred to as the "third example"), and For example, the second basis vector P can be defined as Right now or And the third basis vector Q can be defined as Right now or Note that sgn(D i )D i =|D i |, and
[0126] In another example (not shown in the figure, hereinafter referred to as the "fourth example"), B = ±1 and C = ±1. For example, the second basis vector P can be defined as That is, P=(+D z ,0,-D z ) or P=(-D z ,0,+D x ), and the third basis vector Q can be defined as That is, Q=(0,+D z ,-D y ) or Q=(0,-D z ,+D y ).
[0127] In another example (not shown in the drawings, hereinafter referred to as the "fifth example"), and For example, the second basis vector P can be defined as Right now or And the third basis vector Q can be defined as Right now or
[0128] In another example (not shown in the figure and hereinafter referred to as the "sixth example"), and Therefore, the second basis vector P can be defined as Right now or And the third basis vector Q can be defined as Right now or Due to D z is the principal component of the light direction vector, so D x or D y can be zero. Therefore, in these examples, when processing and In one approach, D x or D y The values of may be perturbed by some small amount so that they are never exactly zero. For example, a zero value may be replaced with a non-zero value that is small enough to behave like zero in the operations described herein.
[0129] In another example (not shown in the figure and hereinafter referred to as the "seventh example"), and Therefore, the second basis vector P can be defined as Right now or And the third basis vector Q can be defined as Right now or Due to D z is the principal component of the light direction vector, so D x or D y can be zero. Therefore, in these examples, when processing and As mentioned above, in one approach, D x or D y The values of may be perturbed by some small amount so that they are never exactly zero. For example, a zero value may be replaced with a non-zero value that is small enough to behave like zero in the operations described herein.
[0130] The example basis vectors given in the second, third, fourth and fifth examples above all have consistent handedness, while the handedness of the basis vectors given in the sixth and seventh examples above may have consistent or opposite handedness, depending on D x and D y symbol.
[0131] In another example (not shown), B = ±sgn(D z ) and C = ±sgn(D z ). For example, the second basis vector P can be defined as That is, P=(+|D z |,0,-sgn(D z )D x ) or P=(-|D z |,0,+sgn(D z )D x ), and the third basis vector Q can be defined as That is, Q=(0,+|D z |,-sgn(D z )D y ) or Q=(0,-|D z |,+sgn(D z )D y ).
[0132] In another example (not shown), B = ±sgn(D x ) and C = ±sgn(D y ). For example, the second basis vector P can be defined as That is, P = (+sgn (D x )D z ,0,-|D x |) or P = (-sgn (Dx )D z ,0,+|D x |), and the third basis vector Q can be defined as That is Q=(0,+sgn(D y )D z ,-|D y |) or Q = (0, -sgn (D y )D z ,+|D y |).
[0133] In all of these examples: (i) S is orthogonal to P and Q, (ii) P and Q are not parallel to each other, and (iii) Q and Q have zero as a component when expressed in a spatial coordinate system. Furthermore, in some of these examples, P and Q have a value of ±1 as a component when expressed in a spatial coordinate system. Conditions (i) and (ii) together mean that P, Q, and S are always linearly independent. This means that the vectors are also spanning and thus form a basis. The fact that the determinant is never zero for valid (i.e., non-zero) ray directions also proves that the vectors form a non-degenerate basis.
[0134] Some error will be introduced into the projected quantities (e.g. by floating point evaluation), and the choice of basis vectors has to do with how this will affect the overall error in the intersection calculation. Given the general basis defined above, the components (p, q, s) of the projected vertex are given by the following matrix multiplication
[0135] Given,
[0136] Where (v x ,v y ,v z ) is the vertex component in world or instance space, after the ray origin has been subtracted, and possibly after the axes have been displaced and mirrored so that D z ≥D x , D z ≥D y and D z ≥ 0. The inverse mapping of these vertex components according to their projected counterparts is represented by
[0137] Given,
[0138] in is the squared length of the ray. The above expression is useful because it shows how errors in the computed projection components map to errors in the original vertex positions, giving an impression of the error behavior in a ray-independent manner (recall that a large number of different rays can be tested for a given primitive) in the sense that direct comparisons can be made between the perturbed vertex positions implied by one ray projection and another ray projection (assuming a shared ray origin).
[0139] For example, suppose we compute p and q as having a relative error ε p and ε q (practical for accurate floating point implementations) ′ and q′, so that
[0140]
[0141] Note that since s is not computed explicitly in this example, it can be described with zero effective error as described above. Now, using the earlier expression for the inverse mapping, we can write (v x ′ ,v y ′ ,v z ′ )(implicit offset vertex) to express the error, where
[0142]
[0143] If we replace (p,q,s) with our original projection expression, this simplifies to
[0144]
[0145] The first important thing to observe (in this example, where the projected coordinates are computed using relative errors) is that the implicit vertex error does not depend on the choice of values for A, B, or C (assuming that zero values are handled correctly, as described elsewhere). This allows us to decide on these quantities based on their relative values without having to consider their impact on the error analysis.
[0146] Next, we can calculate the total squared relative error ε by 2 Written as
[0147]
[0148] in is the squared length of the vertex not at the ray origin relative to the vertex at the ray origin. Now we can see why D z is the main axis is important; the above equation includes D x / D z and Dy / D z For a finite ε x and ε y , these two terms may become unbounded, and the error in the calculated projection component is due to D z tends to zero.
[0149] For example, with v z ≠0,ε p ≠0,ε q =0,D x =D y And D z / D x →0 as an example. We use
[0150]
[0151] In the first line we use the substitution ε y = 0, in the second row we used D x =D y , in the third row we used D z / D x →0, in fact v z ≠0. So we see that about the vertex component v x (and v y ) is washed out in the projection as D z / D x → 0, as should be intuitively clear from reference to the matrix expression for (p, q, s). Of course, if D z is the major axis, then D z / D x (and D z / D y ) is constrained to unity below so that the above anomaly does not occur (and an upper limit on the total error can easily be constructed from the error bounds on the projection components).
[0152] The "reciprocal basis" is the basis vector P = B (D z ,0,-D x ) and Q=C(0,D z ,-D y ), B is and C is In other words, B is a function with D in its denominator. x , and C is a fraction with D in its denominator y For example, the inverse basis can make and Make and As another example, the reciprocal bases can make and Make and One advantage of using a reciprocal basis is that each reciprocal can be evaluated with some precision (usually less precise than comparable floating point operations), and then those evaluations can be treated as if they were exact, essentially perturbing the direction of the ray directions for the sake of improving the precision of all intersection testers (improving consistency across the board). Another advantage of using a reciprocal basis is that it provides more flexibility in how the intersection distances are computed, if desired. In particular, if the intersection points are determined (relative to the ray basis coordinate system) for example by barycentric interpolation (p x ,p y ,p z ), then the intersection parameter t can optionally be calculated as or For example, if the components corresponding to the axes with the smallest range for the components of a given convex polygon are chosen, this can provide excellent error characteristics. This is in contrast to a non-reciprocal basis, since the inversion involved is performed without increasing the storage for each ray. and The computation of is less cost-effective. Precomputing these additional terms may also sacrifice some consistency in the ray definition, since the computed reciprocal cannot usually be considered exact. Since the reciprocal basis projection operation also involves the form and The product of the vertex components of , so these intermediate products can be retained so that the intersection parameter t is directly interpolated from the centroid without any further scaling (described in more detail later in this document).
[0153] Table 1 below shows eight examples of different ray formats (denoted A to H) and basis vectors (up to the sign) that can be used in the different examples. The phrase "up to the sign" here means that P and Q can be scaled by any unit value, i.e., limited to the set {-1.+1}. Table 1 also shows the number of multiplications and multiplication operations to be performed for each ray of the different ray formats, the number of multiplication operations to be performed for each vertex projected into the 2D ray space with its corresponding basis, and the multiplications and multiplication operations to be performed for each primitive of the intersection distance calculation.
[0154]
[0155] Table 1: Example ray formats and basis vectors
[0156] Different options for ray formats and base vectors can be compared to each other based on the total cost of all floating point operations (FLOPs) from ray format encoding, base projection, and distance calculations. When preprocessing rays into a given format (e.g., one of the options shown as A to H in Table 1) is decoupled from polygon intersection testing and performed once per ray, and assuming that a single ray is tested against multiple vertices, it is often beneficial to offload the FLOP cost from base projection to ray format encoding to minimize the former. When a single ray is tested against multiple primitives, it is also beneficial to offload the FLOP cost from distance calculations to ray format encoding to minimize the former.
[0157] Options B, D, F, and H are generally all improvements over A, C, E, and G respectively, as they move the inverse from the (per-primitive) distance calculation to the (per-ray) ray format encoding.
[0158] Option B (and Option A) are the default ray format / basis, which is the most intuitive way to perform intersection testing, but is not the most efficient in terms of the number of floating point operations that need to be performed. Option F (and Option E) reduces the number of multiplication operations performed per vertex in the base projection by two relative to Option B (and Option A).
[0159] Options C, D, G, and H use reciprocal bases. Option D (and Option C) reduces the number of multiplications performed per vertex in the basis projection by one, and reduces the number of multiplications performed per primitive in the distance calculation by one, relative to Option B (and Option A).
[0160] Option H (and Option G) reduces the number of multiplication operations performed per vertex in the base projection by two relative to Option B (and Option A).
[0161] Using a ray coordinate system with basis vectors as described in the above example can simplify some of the processing involved in intersection testing. Specifically, if a basis vector has 0 as a component value, then multiplication and / or addition operations involving the basis vector (e.g., such as for performing a dot product or a cross product) will not include multiplication and / or addition operations for components that are 0, thereby reducing the number and / or complexity of operations that need to be performed. Similarly, if a basis vector has ±1 as a component value, then multiplication and / or addition operations involving the basis vector (e.g., such as for performing a dot product or a cross product) will not include multiplication operations for components that are ±1, thereby reducing the number and / or complexity of operations that need to be performed. Reducing the number of operations performed tends to reduce the delay and power consumption of the intersection test module 108, and in addition, reducing the complexity of the operations performed tends to improve accuracy. In addition, when the intersection test module 108 is implemented in a fixed-function circuit system, then reducing the number and / or complexity of operations performed tends to reduce the size (i.e., silicon area) of the intersection test module 108. For example, the fixed function circuit system may include one or more multiplication and addition components (e.g., a fused single rounding multiplication and addition unit) to perform multiplication and addition using the second basis vector and the third basis vector of the ray coordinate system. In a single rounding floating point implementation (i.e., rounding is applied to the accurate final result to ensure that the output can represent the value), this is more accurate and generally smaller in area than the product and sum of multiplication rounding (both products and sums). Its area can even be comparable to a multiplication rounding implementation with lower accuracy, which is unlikely to occur for more complex operations. There is no associativity between floating point addition and multiplication operations (unlike the real numbers that approximate them). The reduction operation reduces the possible sorting, so there may be other benefits in terms of result consistency.
[0162] In the main example described in this article, the ray data of the light has n=3 coefficients. However, in other examples, the ray data may have more than three coefficients. The construction of the described ray coordinate system can be applied to any dimension n≥2. For example, n basis vectors of the ray coordinate system can be defined, where the first basis vector of the basis vectors of the ray coordinate system is aligned with the ray direction, and there are (n-1) other basis vectors that are orthogonal to the first basis vector. If n>2, no pairs of basis vectors in the (n-1) other basis vectors are parallel. In addition, when expressed in a spatial coordinate system, the (n-1) other basis vectors have zeros for (n-2) components. The n basis vectors of the ray coordinate system form the basis of an n-dimensional space (the basis vectors are linearly independent and therefore spanning). For example, in four-dimensional space, the ray direction vector may be D=(D w ,D x ,D y ,D z ), and the four basis vectors of the light coordinate system can be: S = A (D w ,Dx ,D y ,D z ), P=B(D z ,0,0,-D w ) and Q=C(0,D z ,0,-D x )、R=D(0,0,D z ,-D y ), where in this example the selective permutation of the axes ensures that D z is the principal component of the light direction vector, i.e. |D z |≥|D w |、|D z |≥|D x | and |D z |≥|D y |. In this example, A, B, C, and D are non-zero scalars, and they may be chosen so that one of the coefficients is unified, for example, as described above for the three-dimensional example. In this example, the four dimensions may correspond to three spatial dimensions and one temporal dimension. In the 4D case, an expression for the sign of the determinant (similar to expression (1) given above for the 3D case) may be given as:
[0163] sgn(A)XOR sgn(B)XOR sgn(C)XOR sgn(D)XOR sgn(σ)(2)
[0164] As an example, if the principal component of the light direction vector is the W or Y axis, the permutation σ may reverse the mapping sign, but if the principal component of the light direction vector is the X or Z axis, the permutation σ may not reverse the mapping sign. In particular, in this example, changing the order of the components so that the principal components are in the final position may include four cycles of the principal axis of W and a transposition of the principal axis of Y, flipping the sign in both cases. z The sign of is not a factor of expression (2) because n is an even number (ie, n=4).
[0165] Returning to the 3D case, in some examples, the light and the convex polygon are transformed from the space coordinate system into the light coordinate system, where the intersection test is performed in the light coordinate system. The test in the light coordinate system can be performed by determining whether the light intersects with the convex polygon defined by its vertices defined in the light coordinate system. However, in some other examples, the light and the convex polygon do not need to be completely transformed into the light coordinate system. In these other examples, the polygon can be projected onto a pair of axes corresponding to the second basis vector and the third basis vector of the light coordinate system, but the component of the polygon along the direction of the light (i.e., in the direction of the first basis vector of the light coordinate system) may not be determined. It should be noted that it is simple to define the light in the light coordinate system because the origin of the light is at the origin of the light coordinate system and the direction of the light is parallel to the S axis, so that the component values of the light along the P and Q axes of the light coordinate system are zero.
[0166] In the above example, the axes are selectively permuted to ensure that D z are the principal components of the light direction vector. Furthermore, the axes can be optionally inverted (or "reflected") to ensure that all components of the light direction vector are non-negative, i.e. D z >0,D x ≥0 and D y ≥ 0. The selective inversion of the axes makes the light direction vector point to an octant of the spatial coordinate system with positive values for x, y, and z. z are the principal components of the light direction vector, which means and is in the range of 0 to 1 and means and In the interval from 1 to positive infinity. On axis D z ≥D x ≥0 and D z ≥D y ≥0 after selective substitution and selective inversion.
[0167] Returning to the changed sign of the basis forces D x , D y and D z The non-negative signs of sgn(A), sgn(B), or sgn(C) mean that any occurrence of them in the determinants sgn(A), sgn(B), or sgn(C) are forced to 1, simplifying the sign post-manipulation. However, since the vector coordinates must be inverted / reflected to match the inversion / reflection of the ray coordinates, the signs must be post-manipulated by sgn(Dx), sgn(Dy), and sgn(Dz). Thus, for the particular choices of A, B, and C given in the example above, this results in the same sign-manipulated expression.
[0168] A mapping indication of the sign of the basis change map may be stored, where the mapping indication whether the mapping from the space coordinate system to the ray coordinate system affects the perceived polygon orientation. The mapping indication may be used during intersection testing of the ray with the polygon to ensure that the correct orientation (perceived by the ray in the original space coordinate system) is output.
[0169] Figure 3 is a flow chart of a method for performing intersection testing of a ray with respect to a plurality of convex polygons (e.g., triangles), the intersection testing being performed by the polygon intersection testing unit 114 of the intersection testing module 108. Prior to the intersection testing of the ray with respect to the polygons performed by the polygon intersection testing unit(s) 114, the ray may be tested for intersection with a box representing a node of an acceleration structure by the box intersection testing unit(s), wherein if it is determined that the ray intersects a leaf node of the acceleration structure of the reference polygon, the ray is scheduled to intersect the polygon.
[0170] In step S302, data defining the light ray 202 and data defining the vertices of the convex polygons 204 and 206 are obtained at the intersection test module 108. Specifically, data defining the light ray origin and the components of the light ray direction in the spatial coordinate system are obtained. The data defining the light ray origin may be three components of the light ray origin position in the spatial coordinate system. x , O y and O z .exist Figure 3 In the example shown, the data defining the direction of the light includes three components D of the light direction in the spatial coordinate system: x , D y and D z Alternatively, as described above, some different values defining the light direction may have been pre-calculated and stored in the memory, so that the pre-calculated values can be read in step S302. For example, three values may be read to define the light direction data, and these three values may be and In other examples, different pre-computed values can be read to define the ray direction, for example and D z As another example, you can read and As another example, you can read and In other examples, other values can be pre-calculated and read that can be used to define the direction of the light. The roles of these three values are different, and they are not always needed. The first and key purpose of the triangle tester is intersection determination. This uses the first two values, such as and as well as or similar, possibly with some sign depending on the choice of B and C. These are used to generate P and Q, relative to which the primitive vertices are projected. The barycentric coordinates of the intersection can be derived from the intersection determination without the need for additional input. A secondary purpose of the triangle tester is orientation determination (e.g., for backface culling). In determinant form, this additionally uses the third value The sign of is used to ensure the correct result. The third final purpose of the triangle tester is to calculate the intersection distance. This also uses the magnitude of the third value, which is or |D z | to correctly rescale the distance values. If the third purpose is not needed (for example, when the ray has infinite range or t min and t max has been pre-scaled accordingly), then this may not be necessary or |D z | as input. If the second purpose is not needed (e.g., when there is no distinction between hitting either side of the primitive), then sgn(D z ). Alternatively, the intersection distance calculation can be used or Any of the above is combined with the corresponding components of the intersection point to determine the intersection distance.
[0171] In reference Figure 3 In the depicted example, data defining the x, y and z components of the positions of the vertices of the convex polygons 204 and 206 are read in step S302 .
[0172] In step S304, the intersection test module 108 (eg, the ray rescaling unit 116) selectively permutes and / or inverts the x, y, and z components of the data defining the ray and the vertices of the convex polygon so that D z ≥D x ≥0 and D z ≥D y ≥0. The permutation of the axes can be thought of as rearranging the axes. Specifically, the permutation of the axes includes rotation of three axes, transposition of two axes, or identity (i.e., without changing the axes). It should be noted that a permutation involving transposition of two axes will change the handedness of the coordinate system, while a permutation not involving transposition of two axes will not change the handedness of the coordinate system. The permutation of the axes is performed so that the principal component of the ray direction is D z (That is, make sure |D z |≥|D x | and |D z |≥|D y|). For example, if the original z component of the light direction vector has a larger magnitude than the original x and y components of the light direction vector, no permutation is used (which can be considered as a permutation using the identity operation); if the original x component of the light direction vector has a larger magnitude than the original y and z components of the light direction vector, the permutation may include a rotation of the three axes such that the x component becomes the z component, the z component becomes the y component, and the y component becomes the x component; and if the original y component of the light direction vector has a larger magnitude than the original x and z components of the light direction vector, the permutation includes a transposition of the y and z axes such that the y component becomes the z component, and the z component becomes the y component (and the x component remains the x component). Selective permutation may be performed only in step S304 (i.e., no selective inversion is performed), but in reference to Figure 3 In the described method, selective inversion of the zero axis, one or more axes is performed so that the ray direction enters an octant with positive x, y, and z. "Inversion" of an axis may be referred to as "reflection", "reversal", or "negation", and may involve changing the sign of all component values along the axis in question in a dimension. The data defining the ray includes the ray origin and the ray direction, and the data defining the convex polygon includes three or more vertex locations. It should be noted that inverting an odd number of axes will invert the perceived orientation of the polygon.
[0173] In step S306, the intersection test module 108 projects the vertices of the convex polygon onto a pair of axes orthogonal to the direction of the light, wherein the origin of the pair of axes corresponds to the light origin. This projection of the vertices of the convex polygon onto a pair of axes orthogonal to the direction of the light may include transforming the vertices of the convex polygon into the above-mentioned light coordinate system. As described above, the light coordinate system has an origin at the light origin, so step S306 may include subtracting the respective components of the light origin from the respective components of the data defining the positions of the vertices of the polygon ( x , O y and O z ), thereby determining the components defining the positions of the vertices of the polygon relative to the light origin. As described above, the light coordinate system has three basis vectors, wherein the first basis vector is aligned with the light direction; and wherein the second basis vector and the third basis vector of the basis vectors are respectively aligned with a pair of axes orthogonal to the light direction, wherein the second basis vector and the third basis vector: (i) are not parallel to each other, and (ii) have 0 as a component when expressed in the spatial coordinate system. As described above, in some examples, when expressed in the spatial coordinate system, the second basis vector and the third basis vector may have ±1 as a component.
[0174] The projection can be in the form of a dot product. 3D vertex v = (v x ,v y ,v z ) and 3D basis vector P = (Px ,P y ,P z ) and Q=(Q x ,Q y ,Q z ) together with the projection to the 2D light space coordinates (p,q) as follows:
[0175] vp=P·v=P x v x +P y v y +P z v z
[0176] vq=Q·v=Q x v x +Q y v y +Q z v z
[0177] Using the example P of the basis described here y =0 and Q x =0, so that:
[0178] p=P x v x +P z v z
[0179] q=Q y v y +Q z v z
[0180] This can be implemented as separate multiplications and additions, or alternatively as a (single-rounded) fused DP2 (2D dot product), in the latter case this will ensure that the computed components have bounded relative errors with the properties discussed previously.
[0181] In addition, for some examples of radicals described herein, P x or P z can be equal to ±1 respectively, and Q y or Q z can be equal to ±1, so that:
[0182] p=±v x +P z v z
[0183] q=±v y +Q z v z
[0184] or:
[0185] p=P x v x ±v z
[0186] q=Q y v y ±v z
[0187] Any of these may be implemented via separate multiplications and additions, or alternatively as a (single-rounded) FMA (fused multiply-add), in which case the FMA will ensure that the computed components have bounded relative errors with the properties discussed previously.
[0188] As described above, a mapping indication is stored to indicate whether the mapping from the spatial coordinate system to the light coordinate system (i.e., steps S304 and S306) has changed the perceived direction of the polygon. If the perceived direction of the polygon has changed, this is taken into account during the intersection process, such as in step S318, to ensure that the mapping from the spatial coordinate system to the light coordinate system in steps S304 and S306 does not prevent the intersection test module from correctly determining whether the light intersects the polygon.
[0189] Figure 6 Shows when Figure 2 The two polygons 204 and 206 are shown as being projected onto a pair of axes aligned with basis vectors P and Q (i.e., the second and third basis vectors of the light coordinate system). In this projection, the light ray is located at the origin and directed into the page, i.e., the components of the light ray direction vector along the P and Q axes are zero. Thus, the intersection position 208 of the light ray with the polygon 204 is represented by Figure 6 is at the origin. Figure 6 Indicates the orientation of the two polygons 204 and 206 in Figure 2 are clockwise, as determined by the winding order of the vertices in the ordered set of vertices that define the polygon. Figure 6 In , the light coordinate system basis vectors P and Q are shown as being at right angles to each other, even though they may not be orthogonal in the space coordinate system. However, it is clear that this visualization does not affect the intersection determination of the convex polygon (i.e., whether it covers the origin).
[0190] In step S308, parameter k is set to zero. Parameter k is used to indicate a specific convex polygon.
[0191] In step S310, parameter e is set to zero. Parameter e is used to represent a particular edge of a convex polygon. Note that the winding order of a polygon (i.e., the order of its vertices) specifies the direction of each of its edges, so that each edge given below is implicitly a directed edge. In the example where the polygon is a triangle, the maximum value of parameter e (e max ) is 2. In other words, the parameter E can take values of 0, 1, or 2 to indicate the three sides of a triangle. In the example where the polygon has n sides, the maximum value of the parameter e (e max ) is n-1. Each edge of a convex polygon is defined by two projected vertices as an ordered pair, indicating the direction of the edge. For example, Figure 6 The polygon 204 shown has a first edge defined by projected vertices v0 and v1, i.e., pointing from v0 to v1, a second edge defined by projected vertices v1 and v2, i.e., pointing from v1 to v2, and a third edge defined by projected vertices v2 and v0, i.e., pointing from v2 to v0. Similarly, Figure 6 The polygon 206 shown has a first edge defined by projected vertices v1 and v3, i.e., pointing from v1 to v3, a second edge defined by projected vertices v3 and v2, i.e., pointing from v3 to v2, and a third edge defined by projected vertices v2 and v1, i.e., pointing from v2 to v1. The edge between projected vertices v1 and v2 is shared between polygons 204 and 206, although polygons 204 and 206 are indicated in opposite directions to be specified in a consistent winding order. In some examples, the method may iterate only once on each unique edge, rather than iterating individually on each of the N edges of the convex polygon, to take advantage of the sharing of some edges.
[0192] In step S312, the polygon test unit 114 of the intersection test module 108 determines a parameter w, which indicates which side of the e-th edge of the k-th polygon the ray passes through. For example, w may be a signed parameter that uses a function (referred to herein as a "2D cross product") f(v i ,v j ) to determine. Define the two projected vertices v of the edge i and v j The 2D cross product of the position f(v i ,v j ) is defined as f(v i ,v j )=p i q j -q i p j , where p i and q i is the projected vertex v i The components along the corresponding axes of a pair of axes, and where p j and q jis the projected vertex v j The component along the corresponding axis of a pair of axes. In other examples, other functions that define the positions of the two projected vertices of the edge can be used to determine the parameter w. For example, the function can return p i q j and q i p j This will avoid performing a subtraction, but will not provide a value for determining the barycentric coordinates. The symbol w of the e-th edge of the k-th polygon represents the angle from the edge (from v i Point to v j ) to see whether the ray passes to the left or right of the edge. Passing on the "left" side of the edge corresponds to a counterclockwise rotation from the first endpoint to the second endpoint relative to the origin. Passing on the "right" side of the edge corresponds to a clockwise rotation from the first endpoint to the second endpoint relative to the origin. For the above as f = (v i ,v j )=p i q j -q i p j The form of a "2D cross product" is given, and the first axis points right and the second axis points upward, left / counterclockwise corresponds to positive results for f, and right / clockwise corresponds to negative results for f. In the IEEE floating-point specification, negative values have a sign bit of 1, while positive values have a sign bit of 0. Assuming a left-handed system (according to Figure 2 ), and aligning the first axis P and the second axis Q to the right and upwards respectively in projected space means that the third axis S (the direction of the light) points into the page, giving the perceived orientation of the correction. In a right-handed system, the third axis S points out of the page, giving the perceived direction of the error. In summary, we have the following correspondence: For a left-handed system: For the sign bit f; and For the sign bit f. For a right-handed system: For the sign bit f; and For the sign bit f. In some examples, "counterclockwise" is encoded as 1, and "clockwise" is encoded as 0. Therefore, in a right-handed system, the sign bit of w gives the correct sign state; where as in a left-handed system, the sign bit of w gives the opposite sign state, so the orientation result is reversed. To achieve this, a wind-up flag can be provided to the user to set when a left-handed spatial coordinate system is required, indicating that all edges should be considered to point in the opposite direction.
[0193] In different implementations, the 2D cross product is used in different ways to determine the parameter w. Figure 4 and Figure 5 Describe two examples in detail. For example, define the two projected vertices v of the edgei and v j can be supplied to the 2D cross product f(v i ,v j ), the order being inherited from the ordered set of vertices defining the convex polygon (i.e., its winding order). For example, the 2D cross product of the shared edges of polygons 204 and 206 would be given as f(v1, v2) = p1q2 - q1p2 for the edge of polygon 204, and f(v2, v1) = p2q1 - q2p1 for the edge of polygon 206.
[0194] Function f(v i ,v j )=p i q j -q i p j , referred to here as the "2D cross product", is a 2D analog to the 3D triple product: it computes the signed area of the parallelogram defined by the first side between the origin and (p0,q0) and the second side between the origin and (p1,q1). This is equivalent to producing a row (p1,q1) with i=0,1. i ,q i ). This is also equivalent to treating the endpoints as complex numbers, taking the complex conjugate of the first endpoint, multiplying it by the second endpoint and looking at the imaginary component. Considering all cases geometrically, find the sine of the angle between the two endpoints and the origin (i.e. the intersection), scaled by the distance of the two endpoints from the origin. Sine is an odd function, so we have a signed function, i.e., if we rotate counterclockwise from the first endpoint to the second endpoint, we get a positive result, and if we rotate clockwise from the first endpoint to the second endpoint (with standard axes), we get a negative result.
[0195] After determining the parameter w using the 2D cross product of the e-th edge of the k-th polygon in step S312, then in step S314, the polygon testing unit 114 of the intersection testing module 108 determines e=e max In other words, it determines whether the w parameter has been determined for all the sides of the k-th polygon. If not, the method proceeds to step S316, where the parameter e is incremented, and then the method returns to step S312 so that the parameter w can be determined for the next side of the k-th polygon. If it is determined in step S314 that the w parameter has been determined for all the sides of the k-th polygon (i.e., if e=e max ), the method proceeds to step S318.
[0196] In step S318, the polygon intersection test unit 114 of the intersection test module 108 determines whether the ray intersects the polygon based on the w parameter determined for the edge of the k-th polygon. For example, the determination of whether the ray intersects the k-th polygon can be based on the sign of the w parameter determined for the edge of the k-th polygon. In one example, if the w parameters determined for the edges of the k-th polygon all have the same sign, it is determined that the ray intersects the k-th polygon; and if the w parameters determined for the edges of the k-th polygon do not all have the same sign, it is determined that the ray does not intersect the convex polygon. In this way, step S318 includes using the parameters determined for the edges of the convex polygon to determine whether the ray passes inside the edge of the convex polygon, wherein if it is determined that the ray passes inside all edges of the convex polygon, it is determined that the ray intersects the convex polygon, and wherein if it is determined that the ray passes outside one or more edges of the convex polygon, it is determined that the ray does not intersect the convex polygon.
[0197] In some examples, once an edge test indicates that a ray passes outside an edge of a polygon, it may be determined that the ray does not intersect the polygon without having to perform edge tests for all edges of the polygon. For example, after we have processed at least 2 edges, if there are one or more determined strictly positive w parameters and one or more strictly negative w parameters for an edge of the polygon, step S314 may be modified to also identify, and in this case, the polygon may be marked as a "miss" without determining w parameters for any remaining edges of the polygon.
[0198] In addition, for intersections to be determined, and for all n signs that w matches, the signs of w may need to match a predetermined value (e.g., when backface culling is used), and if they do not match the predetermined value, the polygons may be discarded. For example, if culling is enabled for clockwise / counterclockwise primitives or forward / backward primitives (e.g., backface culling), the primitives may be discarded once a single edge test result is determined. For example, if counterclockwise primitives are being culled, any primitives with intersections on the left side of the edge may be discarded, and similarly, if clockwise primitives are being culled, any primitives with intersections on the right side of the edge may be discarded. In addition, many edges may be shared (possibly with opposite directions) within a single batch of convex polygons, and in such cases, each unique edge may be tested once, and the results of the shared edge may be replicated (possibly with opposite signs) across the two polygons that share the edge.
[0199] In some examples, the presence of one or more w parameters having zero magnitude can be treated as a special case. For example, if all edges of the polygon have non-zero magnitude w parameters, then it can be determined that the ray intersects the k-th polygon only if all edges have matching signs of their w parameters (similar to as described above), but if one or more w parameters have zero magnitude, then intersection is determined only if all zero magnitude w parameters (for edges of non-zero projection length) have a particular sign (e.g., a positive sign, or a negative sign in other examples) and all remaining edges with non-zero w parameters have mutually consistent signs. In these examples, the sign of the one or more w parameters having zero magnitude does not necessarily have to match the sign of the one or more w parameters having non-zero magnitude to determine that the ray intersects the polygon. Thus, determining whether the ray intersects the convex polygon (in step S318) includes: (i) determining that the signed parameter w of any edge of the convex polygon having a zero magnitude has a particular sign (e.g., positive in some instances and negative in other instances), and (ii) determining that the signed parameter w of the edge of the convex polygon having a non-zero magnitude has a sign that is consistent with each other (although not necessarily consistent with the sign of the w parameter having a zero magnitude). In addition, in some examples, if all edges generate w parameters having zero magnitude, it can be determined that the ray does not intersect the kth polygon, which indicates degeneracy. In other words, in order to omit degenerate polygons, if the 2D cross product of all edges of the convex polygon has a zero magnitude, it can be determined that the ray does not intersect the convex polygon. If culling is enabled, primitives can be discarded based on the sign of the edge having a non-zero w parameter, as described in the previous paragraph. In addition, as described above and in addition to the previous paragraph, once any pair of edges having a non-zero w parameter is determined to have a conflicting sign, or in some examples, once the w parameter is determined to have a zero magnitude, it is not necessary to determine all nw parameters. In the latter case, if the w parameter (for edges of non-zero projection length) does not have the necessary sign, then it can be determined that no intersection occurred. Alternatively, for non-degenerate strictly convex polygons, if exactly two w parameters (for edges of non-zero projection length) both have the necessary sign (ensuring sign consistency for the remaining edges with non-zero w parameters), then it can be determined that an intersection did occur, since at most two w parameters (for edges of non-zero projection length) can have a magnitude of zero (one zero w parameter indicates an edge intersection, and two zero w parameters indicate a vertex intersection). In a "sign equality test", a pair of equal signs of zero parameters (for edges of non-zero projection length) also determine an intersection, but this property is not typically exploitable since edges with zero w parameters are typically not distinguished in this intersection test. The latter case assumes that culling has not been enabled, since this may require checking the sign of one of the edges with a non-zero w parameter.
[0200] In some examples, the signed parameter w of the edge is equal to the 2D cross product of the edge. In other examples, the signed parameter w is equal to the 2D cross product multiplied by a positive constant (e.g., 1 / 2). In other examples, the signed parameter w is equal to the 2D cross product multiplied by a negative constant (e.g., -1), but in this case, all orientation determinations are reversed. Figure 6 In the example shown, the 2D cross product of the first side of the polygon 204 defined by vertices v0 and v1 is given by f(v0,v1)=p0q1-q0p1, and by considering Figure 6 It is understood that this is a negative non-zero value. For a given winding (such as Figure 6 ), a negative non-zero value of the 2D cross product of the edges indicates that the ray can pass inside the convex polygon when the ray passes to the right of the edge, while a positive non-zero value of the 2D cross product of the edges indicates that the ray passes outside the convex polygon when the ray passes to the left of the edge. Conversely, for a polygon with a counterclockwise orientation as viewed ( Figure 6 (not shown in ), a negative non-zero value of the 2D cross product of the edge, from the perspective of the (directed) edge, indicates that the ray passes outside the convex polygon when the ray passes to the right of the edge, while a positive non-zero value of the 2D cross product of the edge, from the perspective of the (directed) edge, indicates that the ray can pass inside the convex polygon when the ray passes to the left of the edge. For any orientation of the polygon observed, a zero value of the 2D cross product of the edge indicates that the ray exactly intersects the edge, that is, the boundary of the convex polygon. f(v1,v2)=p1q2-q1p2 gives the 2D cross product of the second side of the polygon 204 defined by vertices v1 and v2, and by considering Figure 6 As can be appreciated, this is a negative value, thereby indicating that the ray can pass inside the convex polygon when the ray passes to the right of the second side. f(v2,v0)=p2q0-q2p0 gives the 2D cross product of the third side of the polygon 204 defined by vertices v2 and v0, and by considering Figure 6 As can be appreciated, this is a negative value, thereby indicating that the ray can pass inside the convex polygon when the ray passes to the right of the third side. After examining all three sides of the convex polygon 204, the w parameters based on the 2D cross product have the same sign (specifically, they are all negative, indicating a clockwise orientation as observed), so it is determined that the ray passes inside the polygon 204 and intersects it. As can be seen, the intersection point 208 is inside the polygon 204.
[0201] f(v1,v3)=p1q3-q1p3 gives the 2D cross product of the first side of the polygon 206 defined by vertices v1 and v3, and by considering Figure 6As will be appreciated, this is a negative value. Polygon 206 has a clockwise orientation given its winding, so when a ray passes to the right of the first side of polygon 206 defined by vertices v1 and v3, the ray can pass on the inside of the convex polygon. f(v3,v2)=p3q2-q3p2 gives the 2D cross product of the second side of polygon 206 defined by vertices v3 and v2, and by considering Figure 6 As can be appreciated, this is a negative value, thereby indicating that the ray can pass inside the convex polygon when the ray passes to the right of the second side. f(v2,v1)=p2q1-q2p1 gives the 2D cross product of the third side of the polygon 206 defined by vertices v2 and v1, and by considering Figure 6 As can be appreciated, this is a positive value, thereby indicating that the ray does pass on the outside of the convex polygon when it passes to the left of the third side. Therefore, it is not the case that the w parameters based on the 2D cross product have the same sign for all sides of polygon 206. In particular, the w parameters for the first and second sides of polygon 206 based on the 2D cross product are negative, while the w parameters for the third side of polygon 206 based on the 2D cross product are positive. Therefore, it is determined that the ray does not intersect polygon 206, and a consistent orientation cannot be established. It can be seen that intersection point 208 is outside polygon 206. Note that for a valid convex polygon, it is impossible for the ray to pass on the outside of all sides of the polygon (e.g., for a polygon with a clockwise orientation as viewed, it is impossible for the ray to pass on the left of all sides of the polygon), so if the w parameters based on the 2D cross product have the same sign for all sides of the polygon, this indicates that the ray passes on the inside of all sides, so that the ray is determined to intersect the polygon (e.g., if the w parameters for all sides of a polygon with a clockwise orientation have the same sign, this indicates that the ray passes on the right of all sides). It should also be noted that for a valid convex polygon and a counterclockwise orientation as seen, it is impossible for the ray to pass to the right of all the edges of the polygon, so if the w parameter based on the 2D cross product has the same sign for all the edges of the polygon, then this indicates that the ray passes to the left of all the edges, so that the ray is determined to intersect the polygon. Therefore, it can be inferred that for a convex polygon of unknown orientation, if the w parameter has the same sign for all the edges of the polygon, then its observed orientation is indicated by any of the signs of its edges.
[0202] After step S318, the method proceeds to step S320, where the polygon test unit 114 of the intersection test module 108 outputs an indication of the result of the determination of whether the ray intersects the k-th polygon. This indication may be a binary indication (e.g., a one-bit flag) to indicate a 'hit' or 'miss' of the ray relative to the polygon. In other examples, the indication may have a different form. In addition to the indication of whether an intersection occurred, there may be additional output attributes, such as barycentric coordinates, orientation (clockwise / counterclockwise or forward / backward), and / or intersection distance.
[0203] In step S322, the polygon testing unit 114 of the intersection testing module 108 determines whether there are more polygons to test. If so, the method proceeds to step S324, where the parameter k is incremented, and then the method returns to step S310 so that steps S310 to S320 can be performed on the next polygon to determine whether the ray intersects the next polygon. When there are no more polygons to test, the method proceeds to step S326. Step S326 can be performed before, after, or during step S322, i.e., step S326 can be performed after step S320, regardless of whether there are more polygons to test.
[0204] In step S326, the outputted indications are used (e.g., by processing logic 110) in ray tracing system 100 to render an image of the 3D scene. For example, in addition to the indication that the ray intersects the polygon, in step S320, polygon intersection test unit 114 of intersection test module 108 may also output an intersection distance (i.e., the distance between the ray origin and the point where the ray intersects the polygon) and an indication of the location where the ray intersects the polygon (e.g., defined in barycentric coordinates), and may output this information to processing logic 110. In step S326, all intersection tester output attributes are processed along with other external attributes, such as scene data (e.g., light source, cube map), instance data, primitive / polygon IDs, vertex data (e.g., position, normal, texture coordinates), texture addresses, secondary ray data, etc., to determine color values and / or generate additional secondary rays for future traversals.
[0205] If the barycentric coordinates are output in step S320, the barycentric coordinates can be determined using the magnitude of the w parameters of the different sides of the polygon that the ray intersects. For example, in the case where the polygon is a triangle with vertices v0, v1, and v2, for the intersection of the ray at the intersection point v, the w value gives twice the signed area of the sub-triangle formed by the vertices (v, v0, v1), (v, v1, v2), and (v, v2, v0), until a uniform non-zero rescaling from the ray space projection. The barycentric coordinates (which can be called "face coordinates") are found by normalizing the three w weights (i.e., summing them and dividing by the total) so that their sum is 1. In particular, the three w weight factors are normalized to output all uniform scaling. As described above, all non-zero weights have the same sign for an intersection point, so their magnitudes (rather than their signed values) can be normalized, which reduces the complexity of floating point operations because it is simpler to add three values that are known to be non-negative than to add three values whose signs are unknown. The resultant barycentric coordinates α, β, and γ, corresponding to the edges (v1, v2), (v2, v0), and (v0, v1), respectively, define the intersection of the ray with the convex polygon ι = O + αv0 + βv1 + γv2. Finally, note that since the barycenter sums to one by definition, only two of the three values need to be output (although all three weights must be calculated to perform normalization, as described above).
[0206] If the intersection distances are output in step S320, they may be calculated based on the ray lengths rather than the actual Euclidean distances. For example, the ray length may be divided by And the intersection distance can be determined based on the length of the ray from the ray origin. In other words, the value of τ is calculated, where ι=O+Dτ is the intersection of the ray and the convex polygon. This value can be determined based on the intersection equation Dτ=αv0+βv1+γv2 using the barycentric coordinates. In some examples, based on the equation (obtained by multiplying both sides of the intersection equation by the projection matrix), the projection coordinates s0, s1, and s2 (where in general s = A(D x v x +D y v y +D z v z )) can be used to determine τ. Then the centroid interpolated coordinates are divided by To obtain τ. For example, for The rescaled light, and for its and The values of have been pre-calculated and stored, and the square rescaled ray length can be calculated Then τ can be determined as Here we see that we need To prevent the intersection distance from being z The factor is overcomputed, and it is tempting to store this quantity in the ray format. Note that if we do not rescale the ray along its direction (using A=1), but if we wish to preserve the benefits of ray rescaling in the remaining projection operations (e.g. so that we can encode and D x , D y and D z ), then additional storage can be used), then the additional scaling factor is not required. It should also be noted that in one example, if the pre-calculated This avoids the need to rescale the barycentric interpolated convex polygon coordinates, but this will also require additional storage. In other examples, one component of the intersection equation is used to determine τ, thereby equivalently determining D x τ=αv 0x +βv 1x +γv 2x , D y τ=αv 0y +βv 1y +γv 2y and D z τ=αv 0z +βv 1z +γv 2z .exist or In examples that have been pre-computed and stored, the last of these three options is usually the most efficient, so that the intersection distance can be calculated by multiplying the barycentric interpolated vertex z component by the pre-computed inverse. If a reciprocal basis is used (for which, as well as or some of its scaling factors can be pre-computed and stored), the projection operation includes the term and (which can be thought of as mapping the coordinates into "t" space), or possibly, as in the rescaling example, including the term and v z (rescaled t-space). Since we can write So the intersection distance can be determined without any further calculations other than barycentric interpolation of the scale value (feature in the projection calculation), unless the ray has been rescaled, in which case the factor As in the case of a general non-reciprocal rescaled basis. Alternatively, if, for example, it is inconvenient to generate the scaled vertex components (in t-space), the barycentric interpolation result can be obtained by and An appropriate scaling in and has been pre-computed and stored, this can again involve In either case, the scaled and unscaled reciprocal cardinality provides flexibility in choosing which axis should be used for interpolation, which, as previously described, allows choosing the axis with the most attractive error characteristics for a given convex polygon (e.g., by choosing the axis with the smallest range of values over the entire convex polygon).
[0207] exist Figure 3 In the example shown, data defining the light and data defining the vertices of the polygon are read in step S302, and then in step S304, the x, y and z components of the light and the vertices defining the polygon are selectively replaced and / or inverted so that D z ≥D x ≥0 and D z ≥D y ≥ 0. However, the order of the parts of these two steps (steps S302 and S304) may be different in different examples. For example, the x, y, and z components of the light may be selectively permuted and / or inverted before the data is obtained. It is useful to perform such selective permutation and / or inversion of the x, y, and z components of the light data before reading in the data, so that we know D before reading in the data. z ≥D x ≥0 and D z ≥D y ≥ 0. This allows certain pre-calculations to be performed on the ray data, and the pre-calculated data can be stored in a storage device (e.g., memory on ray tracing unit 102) before being read into intersection test module 108. This means that the processing involved in this pre-calculation can be performed once for a ray, and used multiple times if the ray is involved in multiple intersection tests. As described above, the pre-calculated ray direction data read by the intersection test module can include and D z or The value of and D z or or and D z or The values of are used to give only some examples, while in other examples other values may be pre-computed and read in order to define the ray direction. Along with the pre-computed ray data, an indication (e.g., a 2-bit enumeration) indicating the major axis of the permutation is stored, as well as the original sign of the inverted ray direction component, so that the same pre-computation can be applied to the polygon vertices when the ray is tested against them (and the orientation determination is post-modified if appropriate). Here, the (only) overhead is the additional 2 bits for indicating the major axis, but this (negligible) additional storage is outweighed by avoiding finding the principal components of the ray direction each time a polygon is tested against the ray.
[0208] As described above, if a ray intersects a point on the edge of a polygon, problems may occur during the intersection test process. For example, if a ray intersects a point on a shared edge, or if a ray intersects a shared vertex of a closed fan shared by multiple polygons, then in order to make the intersection test process "rigorous", the polygon intersection test unit 114 should determine in most cases that the ray intersects at least one of the polygons. In order to make the intersection test process "non-redundant strict", the polygon intersection test unit 114 should determine in most cases that the ray intersects one and only one of the polygons. As described in detail above, there are some exceptions to these definitions of the meaning of "rigorous" and "non-redundant strict" intersection tests. If the intersection test process is not rigorous, rendering errors may be introduced into the rendered image, such as cracks in the geometry, which is undesirable. One way to implement a "rigorous" intersection test is to project onto a ray-related plane (e.g., given by the ray space basis vectors P and Q), and then accurately determine whether the polygon (including its border) covers the origin (e.g., by determining whether the origin is inside each edge or strictly on each edge). This is not a "non-redundant strict" intersection test, because it causes all polygons to overlap, so that all shared edges are hit twice (or more times), and for each polygon in the closed sector, all shared vertices of the closed sector are hit once. The example outlined below is configured to remove this redundancy.
[0209] In some examples described herein, a planar vertex ordering scheme is used to ensure that intersection tests are "non-redundantly tight". A "planar vertex ordering scheme" may be abbreviated as "vertex ordering scheme" herein. The planar vertex ordering scheme defines a general ordering of 2D projected vertices that is independent of the winding order of the vertices (i.e., inherited from an ordered set of vertices defining a convex polygon). The ordering of the projected vertices according to the planar vertex ordering scheme is a completely strict ordering. This means that for two different projected vertices a and b, we have a b. Note that there is no "natural" total strict ordering of the plane like that for the line (i.e., consistent with the arithmetic operations of complex numbers) (i.e., consistent with the arithmetic operations of real numbers). The ordering of the projected vertices according to the planar vertex ordering scheme defines the direction of each edge, independent of the direction inherited from the winding order of the polygon containing the edge. The winding order defines a cyclic ordering of the vertices, i.e., a binary relation in and only in the following cases: v i < v (i+1(modn)) , for n = 0,..., n - 1. Note that this is not a proper ordering as it does not satisfy all the axioms of a partial ordering, such as transitivity, and thus is not a total ordering like a projection-related ordering scheme either, but is defined on the edges of a polygon and used to determine their direction. Additionally, as a cyclic ordering, its binary relation is preserved by rotation of the convex polygon and reversed by reflection of the convex polygon. In the examples described herein, and during intersection determination, when the direction of an edge given by the planar vertex ordering scheme is consistent with the direction of the edge given by the winding order of the polygon, the edges of the convex polygon can be precisely considered as part of the boundary of the polygon.
[0210] In an example planar vertex ordering scheme, the general direction of a projected edge is from the vertex with the smallest p-component to the vertex with the largest p-component, unless the projected vertices of the edge have equal p-components, in which case the direction of the projected edge is from the vertex with the smallest q-component to the vertex with the largest q-component. To state this more formally in mathematical terms, a 2D edge has two vertices (v i (with components p i and q i ) and v j (with components p j and q j ), and under the planar vertex ordering scheme, the edge points from min(v i , v j ) to max(v i , v j ), where the vertices are ordered such that if p i < p j , or if (p i = p j and q ij ), then v i <v j , otherwise v i >v j In other words, along the corresponding axis of a pair of axes (P and Q) has a component p i and q i The first projection vertex v i Along the corresponding axis of a pair of axes, the i and q j The second projection vertex v j Before, the condition was p i <p j Or the condition is (p i =p j and q i j ), and the corresponding axis along a pair of axes has a component p i and q i The first projection vertex v i Along the corresponding axis of a pair of axes, the i and q j The second projection vertex v j After that, the condition is p i >p j Or the condition is (p i =p j and q i >q i ). Note that any nondegenerate projected convex polygon (i.e., with nonzero projected area) will have at least three edges with non-equal endpoints. Therefore, according to the planar vertex ordering scheme, we have v for all such edges i <v i or v i <v i , and hence have well-defined directions for all such edges. In the specific example of a non-degenerate projected triangle polygon, we will have all three edges with non-equal endpoints, and hence all three edges with well-defined directions, according to the planar vertex ordering scheme.
[0211] When two projected vertices have the same p and q components, then this means that the edge is degenerate (i.e., equal components along the axis parallel to the ray direction), or that the edge is non-degenerate (i.e., has different components along the axis parallel to the ray direction vector), and the ray is viewed along the edge of a convex polygon, i.e., its direction is perpendicular to the (planar) polygon's normal (to the accuracy of the projection). For non-degenerate convex polygons (in non-projected space, and therefore also in projected space), the former case must not occur for three or more edges of a convex polygon. The latter case means that the polygon appears as a line with zero projected area with respect to the ray, and therefore a convex polygon with such an edge is always degenerate (in projected space). Such degenerate (projected) polygons may be freely omitted by rays. It is acceptable for the rules of the "strict" or "non-redundant strict" intersection testers not to apply to such degenerate polygons, as long as they do apply when these polygons are omitted.
[0212] The planar vertex ordering scheme has eight alternative features, giving eight alternative tie-breaking behavior pairs (for clockwise and counterclockwise orientations). For convex polygons with clockwise orientation, the examples described herein exhibit the "upper left rule", while for convex polygons with counterclockwise orientation, the examples described herein exhibit the "lower right rule". Other embodiments show different tie-breaking behavior pairs. For convex polygons with clockwise / counterclockwise orientations, the eight alternative tie-breaking behavior pairs presented are:
[0213] (i)v i <v j , the condition is p i <p j Or the condition is (p i =p j And q i i )(as described in the main example here) → "Top Left / Bottom Right Rule"
[0214] (ii)v i <v i , the condition is p i <p j Or the condition is (p i =p j And q i >q j ) → "Upper right / lower left rule"
[0215] (iii)v i <v j , the condition is p i >p i Or the condition is (p i =p j And q i <qj ) → "Lower left / upper right rule"
[0216] (iv)v i <v j , the condition is p i >p i Or the condition is (p i =p j And q i >q j ) → "Bottom right / top left rule"
[0217] (v)v i <v j , the condition is q i j Or the condition is (q i =q j And p i <p j ) → "Top Left / Bottom Right Rule"
[0218] (vi)v i <v j , the condition is q i >q j Or the condition is (q i =q j And p i <p j ) → "Top right / bottom left rule"
[0219] (vii)v i <v j , the condition is q i j Or the condition is (q i =q j And p i >p j ) → "Lower left / upper right rule"
[0220] (viii)v i <v j , the condition is q i >q j Or the condition is (q i =q j And p i >p j ) → "Bottom right / top left rule"
[0221] The above terms indicate which edges are considered part of the boundary of the convex polygon in the intersection determination. The first / second tie-breaking behaviors correspond to when the convex polygon has an apparent clockwise / counterclockwise orientation when viewed in the projected 2D space. Since the edge tie-breaking behavior depends on the winding / orientation of the convex polygon, we refer to it as a "winding / orientation-dependent" strictness scheme. Note that for polygons with opposite orientations, such as the "upper-left rule" and the "lower-right rule", the tie-breaking behavior is reversed. For example, the term "upper-left rule" means that all edges that enclose the convex polygon from above or that enclose the convex polygon from the left but exactly vertically are considered part of the polygon's boundary and therefore intersect. Since projection is ray-dependent, these edge tie-breaking behaviors only apply to a single ray and can change between rays, for example, when there is a change in perceived orientation and / or major axes.
[0222] The way edge testing is performed in the examples described herein means that "non-redundant strictness" can be considered equivalent to anti-commutativity of the result of a 2D cross product, where the problem case is (signed) zero, corresponding to a polygon boundary intersection. In other words, strictness problems can occur when the ray falls on an edge or vertex (where f = ±0). In this case, we want to return only one hit. Figure 7a and Figure 7b A ray is shown intersecting a point 708 on an edge 706 shared between two polygons 702 and 704 . Figure 7a The orientation of the two polygons is indicated from the perspective of the light: polygons 702 and 704 both appear clockwise as viewed, which is inherited from their winding order. Figure 7a The directions of the edges of polygon 702 according to the ordering of the vertices in the ordered set of vertices defining polygon 702 are indicated by closed solid arrows. Figure 7a The directions of the edges of polygon 704 according to the ordering of the vertices in the ordered set of vertices defining polygon 704 are indicated by hollow arrows. Figure 7b Indicates the directions of the edges of the two polygons according to the above planar vertex ordering scheme, some of which are related to Figure 7aThe directions of the edges given by the winding order in are different. In this example, polygons that share edges have consistent edge winding, i.e., two convex polygons 702 and 704 share edge 706 with endpoints {v1, v2}, which are ordered (v1, v2) in one polygon (e.g., polygon 702), but are oppositely ordered (v2, v1) in the adjacent polygon (e.g., polygon 704), inherited from the corresponding (consistent) winding order of the vertices in the ordered vertex set defining the polygons. The examples described herein target manifold edges, i.e., situations where two and only two polygons meet at a shared edge, thereby allowing consistent winding of the edges. Note that for closed manifold meshes (i.e., all edges are shared and are manifold), consistent edge winding is only achievable on orientable surfaces. For shared contour edges, and assuming consistent edge winding, the perceived orientation of the polygons changes across the contour edge (not the winding of the polygons) such that one of the polygons is forward-facing and the other of the polygons is backward-facing. Implicit edges formed by two polygons intersecting in their interiors, i.e., at shared edges or shared vertices that are not on the polygon boundaries (i.e., self-intersecting "non-simple" meshes) are excluded from application of "non-redundant strictness" and need not return a single hit solely for the purpose of implementing "non-redundant strictness".
[0223] exist Figure 7a and Figure 7b In the example shown, where a ray is determined to intersect a point on an edge of a polygon, a w parameter is determined based on whether an ordering of projected vertices defining the edge, as defined by a vertex ordering scheme (i.e., a "plane vertex ordering scheme"), matches an ordering of vertices in an ordered set of vertices defining a convex polygon (e.g., inherited from a winding order of the convex polygon). In particular, if a ray is determined to intersect a point on an edge of a polygon, a sign of the w parameter for the edge of the polygon is determined based on whether an edge direction inherited from a plane ordering of projected vertices defining the edge matches an edge direction inherited from a winding order of vertices in an ordered set of vertices defining the convex polygon, where the plane ordering of the projected vertices is defined by the plane vertex ordering scheme. As described above, a ray is determined to intersect a point on an edge if a 2D cross product of the projected positions of two vertices defining the edge has a magnitude of (±) zero. If a ray intersects an edge (e.g., edge 706 shared by polygons 702 and 704), a planar direction of the edge is determined according to the planar vertex ordering scheme, and that direction may be referred to as a "common planar direction of the edge" (e.g., as Figure 7b ). It then determines if the edge has a matching winding direction inherited from the polygon's winding order. If the polygon has a consistent winding order (e.g., Figure 7aAs shown, where both polygons 702 and 704 have an obvious clockwise orientation as shown, the edges will have different winding directions for each of the two polygons: one of the two polygons sharing the edge will have a winding direction that matches the general plane direction of the edge, while the other polygon will have a winding direction that does not match the general plane direction of the edge. The polygon intersection test unit 114 determines that the ray intersects the polygon whose edges have a matching winding direction with the ray, and determines that the ray does not intersect the polygon whose edges do not have a matching winding direction with the ray.
[0224] For example, as Figure 7b shown, according to the planar vertex sorting scheme, since p1 < p2, vertex v1 is before vertex v2, so the direction of edge 706 according to the vertex sorting scheme is from v1 to v2. The winding direction of the edge in polygon 702 (as seen, it appears as a clockwise orientation) is inherited from the winding sorting of vertices v1 and v2 in the ordered vertex set (v0, v1, v2) that defines polygon 702, and this winding direction matches the planar sorting of the projected vertices v1 and v2 according to the planar vertex sorting scheme. Thus, in Figure 7a and Figure 7b the example shown, it is determined that the ray intersects polygon 702. In contrast, the winding direction of the edge in polygon 704 (as seen, it also appears as a clockwise orientation), inherited from the winding order of vertices v2 and v1 in the ordered vertex set (v1, v3, v2) that defines polygon 704, does not match the planar sorting of the projected vertices v1 and v2 according to the planar vertex sorting scheme. Thus, in Figure 7a and Figure 7b the example shown, it is determined that the ray does not intersect polygon 704. In summary, when the ray intersects the shared edge 706, it is determined to intersect one and only one of polygon 702, and thus "non-redundant tightness" is ensured in this example.
[0225] Figure 4 and Figure 5 show two examples for performing step S312 of determining w to indicate on which side of the e-th edge of the k-th polygon the ray passes. In the first example shown in Figure 4 (which can be called the "edge direction on-edge check" method), step S312 includes step S402, where the polygon intersection test unit 114 of the intersection test module 108 determines the 2D cross product f(v i and v j ) for the e-th edge defined by the projected vertices v i ,v j )=p i q j -q ip j , the projected vertices are given in their order in the ordered set of vertices defining the kth polygon.
[0226] In step S404, the polygon intersection test unit 114 determines whether f(v i ,v j )=±0. If we determine f(v i ,v j )≠±0, which means that the ray does not intersect the point on the e-th edge. Then, in step S406, the parameter w is set to be equal to the 2D cross product, that is, w=f(v i ,v j ). Thus, if it is determined that the ray does not intersect a point on the edge, then the sign of the w parameter of the e-th edge is determined to be the same as f(v i ,v j Then, the method proceeds to step S314.
[0227] However, if it is determined in step S404 that f(v i ,v j )=±0, this indicates that the ray does intersect a point on the first edge, and then in step S408, the parameter w is set based on the plane ordering of the projected vertices defining the edge according to the plane vertex ordering scheme. In particular, the parameter is determined as In other words, the magnitude of the w parameter is set to zero, and the sign of the w parameter is determined to be The symbol of , where if the vertex v is projected according to the plane vertex sorting scheme i At the projected vertex v j Before, v i <v j = 1, and if the vertex v is projected according to the plane vertex sorting scheme j At the projected vertex v i Before, v i <v i = 0 (Note that since no strictness criteria need to be applied, any sign can be assigned to the degenerate projective polygon, where v i =v i ). Another equivalent expression for w is given by and Given, it exhibits the opposite behavior. Then, the method proceeds to step S314.
[0228] In order to Figure 4 The example method shown in is reliable, for example, to ensure at least "tight" behavior of shared edges and shared vertices of closed sectors, when f(vi ,v j )≠±0, a particular implementation of the 2D cross product function f must be sign accurate. In particular, the 2D cross product function f is anticommutative, so sgn(f(v i ,v j ))=! sgn(f(v j ,v i )), for all f(v i ,v j )≠±0 and any sign-accurate implementation must share this derived property. Furthermore, this property dictates that the sign of an implementation of f can be computed only once for one polygon that shares an edge, and then the negated result can be used for the other polygon that shares an edge (assuming uniform winding). It is reasonable to expect an implementation of f to be sign-accurate for f≠±0, since it is equivalent to correctly determining that for all p i q j ≠q i p j Yes i q j i p j (negative) or p j q j >q i p j (positive). Furthermore, for the "edge-wise edge-checking" approach, the kernel of the implementation of the 2D cross product f must match the kernel of the 2D cross product f, i.e., the set of input values (restricted to representable floating points) mapped to ±0 by each function must match. This can be achieved by using an implementation of f with fully extended intermediate values and an instance of RAZ (round away from zero) rounding on the result, or by using extended range outputs. The magnitude of w is constant except at zero for Figure 4 The exemplary method shown does not work in terms of guaranteeing "strictness" or "non-redundant strictness". However, if the realizations of f share the complete anti-commutative law of f, that is, f(v i ,v j )=-f(v j ,v i ), for all f*v i ,v j )≠±0, then the result (sign and magnitude) of the realization of f can be computed only once for one polygon that shares an edge, and then the negated result can be used for the other polygon that shares an edge (assuming uniform winding).
[0229] Note that the IEEE single-precision floating-point format assigns encodings for both positive and negative zero (all zeros starting with zero or one, respectively). The implementation of the 2D cross-product function f can generate -0 instead of +0, but this would be implementation-specific. In hardware, the precision of intermediate values can be extended (implicitly or explicitly) to accommodate a larger value range. Clearly, given four 32-bit floating-points as input, p i q j -q i p j can generate values outside the range of an 8-bit exponent and 23-bit mantissa. Given this, if a 32-bit output result is desired, some rounding is performed. If one of the two representable values closest to a non-zero result w is 0, then w can always be rounded to +0 (commonly considered to represent the traditional unsigned 0) or sometimes (or always) rounded to -0. In other instances, the sign of w can be used to determine rounding: if one of the two closest representative values to a non-zero w is 0 and w is positive, then w can generally be rounded to +0 and to -0 at other times. If one of the two closest representable values to a non-zero w is 0 and w is negative, then w can generally be rounded to -0 and to +0 at other times. If in all these cases the sign of the non-zero w matches the sign of the 0 to which it is rounded, this is called "sign-exact rounding". Alternatively, in the case where a non-zero w would round to +0, it can instead be rounded to the smallest representable positive floating-point value (e.g., when rounding away from zero), and in the case where a non-zero w would round to -0, it can instead be rounded to the largest representable negative floating-point value (e.g., when rounding away from zero). If w happens to be 0, it is generally expected to be encoded as +0, but sometimes (or always) it can be encoded as -0. Refer to Figure 4 the method described, i.e., "check on the edge direction on the edge", which does not require the 2D cross-product function f to be consistent in the sign of an exactly zero result, but instead covers the sign in step S408.
[0230] In Figure 7a and Figure 7b the example shown, according to the planar vertex sorting scheme v1 < v2. In polygon 702, edge 706 is defined by the ordered vertices v1 and v2, i.e., v i = v1 and v j = v2, so w is given a negative sign for edge 706 in polygon 702. This is because in this case, However, in polygon 704, edge 706 is defined by the ordered vertices v2 and v1, i.e., v i = v2 and v j = v1, so w is given a positive sign for edge 706 in polygon 704. This is because in this case,
[0231] exist Figure 5 In the second example shown (which may be referred to as a “fulledge sorting” method), step S312 includes step S502, in which the polygon intersection test unit 114 of the intersection test module 108 determines the sorted input vertex f(max(v i ,v j ),min(v i ,v j )) is implemented by defining the projected vertex v of the kth polygon i and v j Definition. Define the two projected vertices v of the edge i and v j are provided to the implementation of the 2D cross product function f in the order defined by the plane vertex ordering scheme. In particular, if the vertices v are projected according to the plane vertex ordering scheme i At the projected vertex v j Before (that is, if v i <v j ), then max(v i ,v j )=v j And min(v i ,v j )=v i ; If we project vertex v according to the plane vertex sorting scheme i At the projected vertex v j After that (i.e., if v i >v j ), then max(v i ,v j )=v i And min(v i ,v j )=v j By sorting the input vertices via a flat sorting scheme, the 2D cross product f is defined over only half of the 4D domain, potentially providing area savings for any implementation that exploits this property. Furthermore, by sorting the input vertices, it is clear that the result of this expression can only be computed once for each shared edge and can then be repeated over all polygons that share the edge.
[0232] In step S504, the w parameter is determined as More generally, the sign of the signed parameter w of an edge is determined to be the same as The sign of is the same as that of , since the magnitude of w plays no role in the determination of “strictness” or “non-redundant strictness”. Gives an alternative expression for w that reverses the sign on the kernel of f but fixes the sign of the kernel of f. Gives an alternative expression for w that reverses the sign above or outside the kernel of f. Gives an alternative expression for w that fixes the sign on the kernel of f and reverses the sign outside the kernel of f. Then, the method proceeds to step S314.
[0233] If reversing the order of the vertices reverses the sign of f, then the binary function f is anti-commutative. Figure 5 The "full edge sorting" method shown lifts the restriction that the implementation of the 2D cross product function f is anti-commutative while still ensuring that the w parameter is anti-commutative. Thus, for a polygon with a shared edge, the result of this expression can be computed only once, and then the negated result can be used for the other polygon sharing the edge (assuming consistent winding). Moreover, the implementation of f only needs to be sign-accurate on the domain v i >v j and further, there is no need to match the kernel of f, thus lifting an additional restriction on the "Edge check on-edge method". Although the implementation of f does not need to match the kernel of f, for the values to which f maps to zero, it must be consistent in sign, i.e., all positive or all negative.
[0234] In Figure 7a and Figure 7b the example shown, according to the planar vertex sorting scheme v1 < v2, such that max(v1, v2) = v2 and min(v1, v2) = v1. Thus, f(max(v1, v2), min(v1, v2)) = f(v2, v1). In polygon 702, edge 706 is defined by the ordered vertices v1 and v2, i.e., v i = v1 and v j = v2, so for edge 706 in polygon 702 w = (-1) 1 ·f(v2, v1) = -f(v2, v1). However, in polygon 704, edge 706 is defined by the ordered vertices v2 and v1, i.e., v i = v2 and v j = v1, so for edge 706 in polygon 702 w = (-1) 0 ·f(v2, v1) = +f(v2, v1). Thus, it can be seen that for polygons 702 and 704, the signs of the w parameter for edge 706 are different, such that it will be determined that the ray intersects one (and only one) of polygons 702 and 704, i.e., intersects 702, thus ensuring "non-redundant tightness" when the ray intersects the shared edge 706.
[0235] Ensuring "non-redundant strictness" is a particular problem when at least one vertex is a shared vertex used to define two or more convex polygons, such as in a closed sector. The method described herein ensures "non-redundant strictness" in the intersection test, for two or more (e.g., exactly two) convex polygons, when determining that a ray intersects a point on an edge of one of these convex polygons: Figure 7a and Figure 7b In the example shown, the ray intersects a point somewhere along the interior of an edge shared by two polygons. Figure 8a and Figure 8b In the example shown, the ray intersects a point at the end of an edge, in which case the vertex is shared by multiple (e.g., five) polygons that form a closed fan. In particular, Figure 8a and Figure 8b A ray is shown intersecting vertex v2 that is shared among five polygons 802 , 804 , 806 , 808 , and 810 . Figure 8a Indicates the winding order of the five polygons, as shown by their observed clockwise orientation. Figure 8a The directions of the edges of polygon 802 according to the ordering of the vertices in the ordered set of vertices defining polygon 802 are indicated by closed solid arrows. Figure 8a The directions of the edges of polygon 804 according to the ordering of the vertices in the ordered set of vertices defining polygon 804 are indicated by open arrows. Figure 8a The directions of the edges of polygon 806 according to the ordering of the vertices in the ordered set of vertices defining polygon 806 are indicated by closed hollow arrows. Figure 8a The directions of the edges of polygon 808 according to the ordering of the vertices in the ordered set of vertices defining polygon 808 are indicated by closed solid arrows. Figure 8a The directions of the edges of polygon 810 according to the ordering of the vertices in the ordered set of vertices defining polygon 810 are indicated by open arrows. Figure 8bIndicates the directions of the edges of the five polygons according to the above-mentioned plane vertex ordering scheme. When determining which convex polygon is hit by a ray that exactly intersects the shared vertex of the closed fan, the polygon intersection test unit (one or more) 114 of the intersection test module 108 determines which polygon has two edges, both of which have the shared vertex as endpoints, whose plane directions (according to the plane vertex ordering scheme) both match their winding directions (according to the winding order given by the ordered set of vertices defining the polygon). There will be one (and only one) such polygon, as long as these polygons have consistent winding, form a (simple, manifold) closed fan, and are not part of the outline. In fact, the vertices shared by such a closed fan of (non-overlapping) convex polygons are defined (in the plane) by the endpoints of the edges that intersect at the shared vertex. Therefore, assuming that the polygons have consistent winding, there will be one and only one polygon of the closed fan, which has three ordered vertices according to its winding order, including the shared vertex as the middle vertex, and its ordering matches the ordering of the plane ordering scheme. According to the plane ordering that presents top-left / bottom-right tie-breaking pairs, polygons (e.g., 810) that are directly below the shared vertex (or below and to the right in the case of an exact vertical edge) intersect in a clockwise manner, and polygons (e.g., 804) that are directly above the shared vertex (or above and to the left in the case of an exact vertical edge) intersect in a counterclockwise manner. Figure 8a and Figure 8b , polygon 810 has matching directions for two of its edges that involve shared vertex v2. This is not the case for any of polygons 802, 804, 806, and 808. Therefore, it is determined that the ray intersects polygon 810, but not any of polygons 802, 804, 806, or 808.
[0236] For example, in the above reference Figure 4 In the example "edge direction edge check" method described, for polygon 810, in step S408, the w parameter of the edge defined by the projected vertices v0 and v2 will be determined as w = (-1) 1 (+0), which has a negative sign; and in step S408, the w parameter of the edge defined by the projected vertices v2 and v3 will be determined to be w=(-1) 1 (+0), which has a negative sign. In step S406, the w parameter of the edge defined by the projected vertices v3 and v0 will be determined as w = f (v3, v0) = p3q0-q3p0, which will be a negative value (as in Figure 8a, which results in a clockwise loop relative to the origin by considering the winding direction of edges v3 and v0). According to the vertex ordering scheme, since we have identified a pair of intersecting edges (zero magnitude w) that both have negative signs (i.e., such that the plane order matches the winding order), the ray is determined to intersect polygon 810, and since the remaining non-zero w parameter is negative, polygon 810 has a clockwise orientation as shown. In other examples, contrary to the vertex ordering scheme, it can be alternatively determined that since the w parameters of all edges of polygon 810 are negative, the ray is determined to intersect polygon 810, and therefore it is also determined to have a clockwise orientation as viewed.
[0237] Note that none of the other polygons 802 to 808 will have a w parameter that is determined such that a pair of intersecting edges both have a negative sign (and zero magnitude), or as a direct corollary, all edges have the same sign. For example, for polygon 802, in step S408, the w parameter of the edge defined by projected vertices v1 and v2 will be determined to be w=(-1). 1 (+0), which has a negative sign; and in step S408, the w parameter of the edge defined by the projected vertices v2 and v0 will be determined as w=(-1) 0 (+0), which has a positive sign that is neither negative nor has the same sign as the w parameter of the edge defined by projected vertices v1 and v2. For brevity, we will not describe all of the calculations for polygons 804 through 808 here, as it should now be clear that they will not determine w parameters with two negative signs for each intersecting edge or with all of their edges having the same sign. Therefore, it will not be determined that the ray intersects any of polygons 802, 804, 806, or 808.
[0238] Note that the vertex ordering scheme and the alternative check for sign consistency on all edges produce equivalent results for polygons with the clockwise orientation shown. That is, intersecting clockwise polygons generate negative w parameters, so positive intersection results are negative on the intersecting edges as well as all remaining edges. However, counterclockwise polygons generate positive w parameters, so that in the case of the vertex ordering scheme, positive intersection results retain negative signs on the intersecting edges but retain positive signs on the remaining edges, while the signed equality test requires that both the intersecting edges and the remaining edges have positive signs. Figure 8a and Figure 8b If all triangles are specified in the reverse winding order so that they have a counterclockwise orientation as shown, the sign of each w parameter is reversed. This means that in polygon 804, the w parameter of the edge defined by projected vertices v1 and v2 will be determined as w=(-1) in step S408. 1(+0), which has a negative sign, and the w parameter of the edge defined by the projected vertices v2 and v4 will also be determined to be w=(-1) 1 ·(+0). In step S406, the w parameter of the edge defined by the projected vertices v4 and v1 will be determined to be w=p4q1-q4p1, which will be a positive value (because winding is counterclockwise). If the vertex ordering scheme is used, polygon 804 will be determined to be the (only) intersecting polygon (because all intersecting edges have negative signs), while if signed equality is used, polygon 804 will be determined not to be intersected. When all w parameter signs are reversed, polygon 810 will instead be determined to intersect again (because the reversal does not affect equality), regardless of orientation. Therefore, we refer to the sign equality test (without further definition) as the winding-independent scheme, and the vertex ordering scheme as the winding-dependent scheme.
[0239] In the above reference Figure 5 In the second example "full edge sorting" method described, for polygon 802, in step S504, the w parameter of the edge defined by projected vertices v1 and v2 will be determined as And in step S504, the w parameter of the edge defined by the projected vertices v2 and v0 will be determined as w = +f(v2, v0) = ±a 20 , and in step S504, the w parameter of the edge defined by the projected vertices v0 and v1 is determined as w = -f(v1, v0) = -(+a 10 )=-a 10 Similarly, for polygon 804, in step S504, the w parameter of the edge defined by the projected vertices v2 and v1 will be determined as w = +f(v2, v1) = ±a 21 , and in step S504, the w parameter of the edge defined by the projected vertices v4 and v2 will be determined as w = +f(v4, v2) = ±a 42 , and in step S504, the w parameter of the edge defined by the projected vertices v1 and v4 is determined as w = -f(v4, v1) = -(+a 41 )=-a 41 For polygon 806, in step S504, the w parameter of the edge defined by projected vertices v2 and v4 will be determined as And in step S504, the w parameter of the edge defined by the projected vertices v5 and v2 will be determined as w = +f(v5, v2) = ±a 52 , and in step S504, the w parameter of the edge defined by the projected vertices v4 and v5 is determined as w = -f(v5, v4) = -(+a 54 )=-a 54= -(+a54) = -a54. ). For polygon 808, in step S504, the w parameter of the edge defined by projected vertices v2 and v5 will be determined as And in step S504, the w parameter of the edge defined by the projected vertices v3 and v2 will be determined as w = +f(v3, v2) = ±a 32 , and in step S504, the w parameter of the edge defined by the projected vertices v5 and v3 is determined as w=+f(v5,v3)=+(-a 53 )=-a 53 For polygon 810, in step S504, the w parameter of the edge defined by projected vertices v2 and v3 will be determined as And in step S504, the w parameter of the edge defined by the projected vertices v0 and v2 will be determined as And in step S504, the w parameter of the edge defined by the projected vertices v3 and v0 is determined as w=+f(v3,v0)=+(-a 30 )=-a 30 In the above example, a 21 ,a 20 ,a 10 ,a 42 ,a 41 ,a 52 ,a 54 ,a 32 ,a 53 and a 30 are all non-negative values, and since all pairs of inputs that implement the 2D cross product are in the f-kernel, the sign indicators ± and are consistent, i.e., they return the signs + and -, respectively, in all instances or they return the signs - and +, respectively, in all instances. Thus, polygon 810 is the one (and only one) polygon determined to be intersected by rays for the corresponding signs + and -, or polygon 804 is the one (and only one) polygon determined to be intersected by rays for the corresponding signs - and +, in either case resulting in three negative values of w (also indicating a clockwise orientation as viewed).
[0240] refer to Fig. 9 The flowchart shown describes another example method (which may be referred to as an “endpoint sign / zero edge check” method) for determining the w parameter of the e-th edge of the k-th polygon in step S312. Fig. 9 Steps S902, S904 and S906 shown in FIG. Figure 4 Steps S402, S404 and S406 shown in are the same. For the "endpoint sign / zero edge check", the polygon submitted to the intersection test unit 114 is assumed to be a strictly convex polygon.
[0241] Therefore, in step S902, the polygon intersection test unit 114 of the intersection test module 108 determines the polygon intersection test unit 114 of the projection vertex v i and v j The 2D cross product f(v i ,v j )=p i q j -q i p j In an embodiment, the projected vertices are sorted according to the winding order of the vertices in the ordered vertex set defining the kth polygon. In step S904, the polygon intersection test unit 114 determines whether f(v i ,v j )=±0. If we determine f(v i ,v j )≠±0, which means that the ray should not intersect the point on the e-th edge. Then, in step S906, the parameter w is set to be equal to the 2D cross product, that is, w=f(v i ,v j ). Thus, if it is determined that the ray should not intersect a point on the edge, then the sign of the w parameter of the e-th edge is determined to be the same as f(v i ,v j ) have the same sign. Then, the method proceeds to step S314. Fig. 9 The scheme described, we make new assumptions about the implementation of the "2D cross product" f: (i) we assume that it is exactly the sign of the kernel of f, e.g., if it shares the anti-commutative law of the "2D cross product" f, and (ii) we assume that we have one of two types of implementations: any implementation where the kernel of the implementation of the "2D cross product" is equal to any approximation of the kernel of f (e.g., by rounding away from zero or using extended range output), denoted as a "round-from-zero" (RAZ) type, or any implementation where the kernel of the implementation of the "2D cross product" is any approximation of the kernel of f that is a strict superset of the kernel of f (e.g., where there is some instance of rounding underflow to zero), denoted as a "round-towards-zero" (RTZ) type. In particular, it is assumed that if f outputs zero, then any implementation that approximates it will also output zero, which is not a difficult requirement.
[0242] However, if it is determined in step S904 that f(v i ,v j)=±0, then this indicates that the ray may intersect with a point on the e-th edge, and then a module including a lookup table (LUT) and / or a logic array is used in steps S908 to S912 to determine the sign of the parameter w. In the example described herein, the module including the lookup table and / or logic array is implemented as a pre-configured logic block in fixed-function hardware on the intersection test module 108 (e.g., as part of the polygon test unit 114). It can be considered that the functionality of the lookup table and / or logic array described herein is generally applicable to a "module" including a lookup table and / or logic array. The lookup table and / or logic array is configured to convert p i ,q i ,p j and q j Each of the coordinates is classified as negative, (±) zero, or positive (eg, as a "ternary digit") three-way indication as its input, and for p i ,q i ,p j and q j The valid combination of coordinate classifications outputs an indication of the sign of the signed parameter w (eg, as a bit). The lookup table or logic array may also be configured to take as two other input bits an indication of the sign of f and a Boolean state of an "underflow flag".
[0243] The lookup table and / or logic array uses the input ternary digit p i ,q i ,p j and q j (and possibly the input bit sgn(f) and the Boolean state of the underflow flag) to model a function that provides an output bit indicating the sign of w. 81 (or 2 324) such functions. This can be implemented in a first way by a lookup table, for example by explicitly listing the 81 (or 324) bit values and using the input as a lookup index / reference value. This will use at least 10 (or 40) bytes of raw storage in the data store (e.g., hard-coded in software or registers in hardware). Note that the lookup table is reduced to one-quarter of its size without adding two more inputs. Alternatively, this can be implemented in a second way by a "logic array", such as a configuration of logic operations in software or logic gates in hardware, performing the desired mapping. The symmetry of the problem, together with the small number of "don't care" outputs, allows the number of logic gates to be reduced. Some hybrid of these two implementations (lookup table and logic array implementation) is also possible, for example, a reduced-size LUT using some pre-processing or post-processing logic to exploit the symmetry of the problem. Either implementation can provide power or area gains over the other, depending on the specific architecture, where the first approach (LUT implementation) can generally be more suitable for software, while the second approach (logic array implementation) can generally be more suitable for hardware.
[0244] In step S908, the polygon testing unit 114 defines the vertex v of the e-th edge. i and v j p i ,q i ,p j and q j Each of the coordinates is classified as: (i) negative, (ii) (±) zero, or (iii) positive. Note that in order to be classified as negative or positive, the coordinate is non-zero. In other words, for the purposes of this classification of coordinates, (±) zero is considered non-negative and non-positive. In the case where the coordinates are in floating point format, and if subnormal numbers have been excluded or flushed, the exponent of the coordinate can be checked (e.g., all zeros) to determine whether the coordinate is zero (regardless of the sign bit), and if the coordinate is not zero, the sign bit of the coordinate can be checked to determine whether it is negative or positive. These are very simple tests that are performed, for example, in fixed-function hardware. If subnormal numbers are supported, the significand (e.g., all zeros) as well as the exponent can be checked to determine whether the coordinate is zero.
[0245] In step S910, the indication of the coordinate classification is input into a lookup table or a logic array. For example, the indication of the classification can be considered as an index or reference value to find a piece of data (ie, the sign of w) from a lookup table or determine the sign of w using a logic array.
[0246] In step S912, the polygon test unit(s) 114 receives an output from the lookup table or logic array indicating the sign of the w parameter for the edge. The method then passes to step S314 and continues as described above.
[0247] The use of a lookup table or a logic array enables the determination of the sign of the w parameter to be achieved very quickly, so steps S908 to S912 can be performed with very low latency and very low power consumption. A small amount of pre-configured logic can be used to implement the lookup table or logic array, so a small amount of silicon area can be used to implement the lookup table or logic array in hardware, but the area will be very small because the operations performed by the lookup table or logic array are simple to implement in hardware.
[0248] In addition, the lookup table or logic array is configured so that if the order of the two projected vertices defining the edge is reversed, then the indication of the sign of the signed parameter output from the lookup table or logic array is reversed. This ensures that the intersection test is "non-redundantly strict" for non-contour shared edges of polygons with consistent winding order. In the examples described herein, this functionality is hard-coded into the lookup table or logic array.
[0249] As mentioned above, if the 2D cross product f(v i ,v j )=p i q j -q i p j has a magnitude of zero, then the ray is determined to intersect a point on the edge.
[0250] For Endpoint Sign / Zero on Edge Check, when f(v i ,v j )=p i q j -q i p j = ±0, and in order to determine the tie-breaking behavior of "non-redundant strictness", the method considers if the positions of the two projected vertices defining the edge are ε = (ε p ,ε q ) perturbation, what will the 2D cross product be, such as Fig.10 This perturbation shows that the first projection vertex v that defines the edge i The position will have coordinates (p) along the corresponding axes (P and Q) of a pair of axes of the light coordinate system. i +ε p ) and (q i +ε q ), and define the second projection vertex v of the edge j The position will have coordinates (p) along the corresponding axes (P and Q) of a pair of axes of the light coordinate system. j +ε p ) and (q j +ε q). The perturbation under consideration will be tiny, but it will be large enough (i.e., considered non-zero) and not share representable edges at such steep angles to move the vertices of the edge that passes through the origin so that the edge will no longer pass through the origin (so that the ray will no longer intersect the edge). Moreover, the perturbation under consideration will be small enough (i.e., by being considered smaller than any representable vector) to not move the vertices of the edge that does not pass through the origin so that the edge will then pass through the origin (so that the ray will intersect the edge). Therefore, taking this into account, it is impossible for the ray to exactly intersect the edge (including its endpoints). Therefore, tie-breaking behavior is established for two shared edges, where the interior of one (and only one) of the two polygons sharing the edge will overlap the origin, and for shared vertices, where a closed sector is assumed, the interior of one (and only one) of the multiple polygons sharing the vertex will overlap the origin. For the above assumptions to hold, assume that the value ε q will be considered greater than zero but less than any positive real value, and the value ε is assumed to be p will be considered greater than zero but less than any real number including ε q A regular rational expression for .
[0251] The "endpoint sgn zero check" method has eight alternative features that give eight alternative side tie-breaking behaviors. The example described here shows the "upper right rule". Other embodiments show different tie-breaking behavior pairs. The eight alternative tie-breaking behavior pairs shown are:
[0252] (i)0<ε p <<ε q (as described in detail in the main example here) → "Top Right Rule"
[0253] (ii)ε p <0<|ε p |<<ε q → "Top Left Rule"
[0254] (iii)ε q <0<ε p <<|ε q |→ "Bottom-right rule"
[0255] (iv)ε q <<ε p <0→"lower left rule"
[0256] (v)0<ε q <<ε p → "Top right rule"
[0257] (vi)ε q <0<|ε q |<<ε p → "Top Left Rule"
[0258] (vii)ε p <0<ε q <<|ε p |→ "Down-right rule"
[0259] (viii)ε p <<ε q <0→"Down Left Rule"
[0260] The above terms indicate which edges are considered part of the boundary of a convex polygon in the intersection determination, regardless of the apparent orientation of the convex polygon observed in the projected 2D space. Since the edge tie-breaking behavior does not depend on the winding / orientation of the convex polygon, we refer to this as the "winding / orientation independence" strictness scheme. For example, the term "upper-left rule" means that all edges that enclose a convex polygon from above or that enclose a convex polygon from the left but exactly vertically are considered part of the polygon's boundary and therefore intersect. Since projection is ray-dependent, these edge tie-breaking behaviors only apply to a single ray and can change between rays, for example, when there is a change in the perceived orientation and / or major axes.
[0261] With this perturbation, the 2D cross product function becomes:
[0262] f(v i ,v j )=(p i +ε p )(q j +ε q )-(q i +ε q )(p j +ε p )=p i q j -q i p j +p i ε q +
[0263] ε p q j -q i ε p -ε q p j (1)
[0264] For p i ,q i ,p j and q j The lookup table is configured to output a combination of all valid combinations and classifications of the signed parameter w. In some examples, for example, for a RAZ implementation type, the lookup table or logic array is configured to output: (i) for pi ,q i ,p j and q j Some valid combinations of coordinate classifications, with the sign of the signed parameter w as p i ,q i ,p j or q j is of the same sign or opposite to that sign, and (ii) for p i ,q i ,p j and q j Some valid combinations of classification of coordinates, the sign of the signed parameter w as any value. In some other examples, for example, for RTZ implementation type, the lookup table or logic array is configured to further output: (iii) for p i ,q i ,p j and q j Some valid combinations of coordinate classifications, with the sign of the signed parameter w as p i ,q i ,p j or q j The sign of the product of the two is or is opposite to the sign, and (iv) for p i ,q i ,p j and q j One or more other valid combinations of classification of coordinates, the sign of the implementation of the signed parameter w as a 2D cross product f. In addition, in some other examples, for example, for the RTZ implementation type, an "underflow flag" is used to determine which of (i), (ii), (iii), or (iv) is configured as the output.
[0265] For example, when determining a 2D cross product function for determining the w parameter, polygon intersection test unit 114 may operate according to a "round away from zero" (RAZ) implementation type to ensure that the kernel of the 2D cross product implementation matches the kernel of f. When using the RAZ implementation type, the lookup table may be configured to provide for p where f may be determined to be zero. i ,q i ,p j and q j For all valid combinations of the classification of the coordinates, an indication of the sign of the signed parameter w is output. In particular, when the RAZ rounding mode is used, then in step S904, f(v i ,v j )=p i q j -q i p j= ±0 if and only if the value of the 2D cross product is truly zero, and not because a non-zero value of the 2D cross product has been approximated to zero by the implementation. Therefore, in this case, equation (1) becomes:
[0266] f(v i ,v j )=p i ε q +ε p q j -q i ε p -ε q p j (2)
[0267] Figures 11a to 11l Possible situations where a ray intersects an edge of a strictly convex polygon in the RAZ type are shown, and also a lookup table or logic array is configured to output the sign of the w parameter for different situations, as derived from the form of equation (2).
[0268] Figures 11a to 11l The positions of the P and Q axes and the (undisturbed) edges that intersect the origin of the P and Q axes are shown. Each edge is connected by the vertices v that define the edge. i to v j The line is shown with the arrow pointing from v i to v j The direction of the line is inherited from the winding order of the strictly convex polygon including the edge. The actual vertex v i and v j exist Figures 11a to 11l Not marked in. Figures 11a to 11l It is also shown that if the edge is ε = (ε p ,ε q ) perturbation, the exaggerated position of the origin 1102 relative to the edge, that is, the origin is perturbed in the opposite direction -ε = (-ε p ,-ε q ) moves, and it can be seen that if a perturbation is applied, the edge will no longer intersect the origin 1102.
[0269] exist Fig.11a The first vertex v i The coordinates of p are not zero, that is, i ≠0 and q i ≠0, and the second projection vertex v j Located at the origin, that is, p j =q j =0. Fig.11a Four types of edges are shown, which fall into p i and q i In this example, equation (2) becomes f(v i ,vj )=p i ε q -q i ε p , so since 0<ε p <<ε q , so the sign of f will be p i Thus, in this example, the sign of the w parameter is set equal to p i symbol. Fig.11i Shown with Fig.11a The opposite of the case shown is the dual case, i.e. the opposite case, where the sign of the w parameter is set to be the same as p j The dual case demonstrates the anti-commutative behavior of tie-breaking when the order of the input projection vertices is switched, for example by exchanging every instance of i with j in the subscripts of p and q, negating the sign of the result.
[0270] exist Fig.11b The first vertex v i On the Q axis, but not at the origin, that is, p i =0 and q i ≠0, the second projection vertex v j At the origin, that is, p j =q j =0. Fig.11b Two types of edges that fall into this category are shown for q i In this example, equation (2) becomes f(v i ,v j )=-q i ε p , so the sign of f will be the same as q i Thus, in this example, the sign of the w parameter is set to be the same as that of q. i The signs of are opposite. Fig.11f Shown with Fig.11b The situation shown is the opposite of the dual case, i.e. the opposite case, where the sign of the w parameter is set to q j symbol.
[0271] exist Fig.11c In the figure, vertex v i and v j are all on the Q axis, not at the origin, i.e. p i =0,q i ≠0,p j =0 and q j ≠0. Since for strictly convex polygons, valid intersection can only occur when the (unperturbed) edge passes through the origin (i.e., for Figure 11kThe edges shown in , cannot intersect with strictly convex polygons), then the edge must intersect P, so in this example q i and q j Must have opposite signs. Fig.11c It shows that for q i and q j There are two valid combinations of symbols, two types of edges that fall into this category. In this example, equation (2) becomes f(v i ,v j )=ε p q j -q i ε p =ε p (q j -q i ). Due to q i and q j The sign of (q j -q i ) and q j has the same sign as q i The sign of f will be opposite to that of q. i The opposite sign of q j Thus, in this example, the sign of the w parameter is set to q j The symbol or q i The opposite sign of the sign of . Fig.11c The situation shown is its own double, its own opposite, because q j The sign is equal to q i The opposite sign of
[0272] exist Fig.11d The first vertex v i On the P axis, but not at the origin, that is, p i ≠0 and q i = 0, the second projection vertex v j At the origin, that is, p j =q j =0. Fig.11d Two types of edges that fall into this category are shown for p i In this example, equation (2) becomes f(v i ,v j )=p i ε q , so the sign of f will be p i Thus, in this example, the sign of the w parameter is set to p i symbol. Fig.11h Shown with Fig.11dThe opposite of the situation shown is the dual case, i.e. the reverse case, where the sign of the w parameter is set to be the same as p j The signs of are opposite.
[0273] exist Fig.11e The first vertex v i The coordinates of p are not zero, that is, i ≠0 and q i ≠0, and the second vertex v j The coordinates of p are not zero, that is, j ≠0 and q j ≠0. Since for strictly convex polygons, valid intersection can only occur when the (unperturbed) edge passes through the origin (i.e., for Fig.11j The edges shown in , cannot intersect with strictly convex polygons), then the edge must intersect P, so in this example q i and q j must have opposite signs, and the edge must intersect the Q axis, so in this example p i and p j Must also have opposite signs. Fig.11e Four types of edges are shown, which fall into p i ,q i ,p j and q j In this example, equation (2) becomes f(v i ,v j )=p i ε q +ε p q j -q i ε p -ε q p j , so since 0<ε p <<ε q , so the sign of f will be (p i -p j ) sign. Since p i and p j The signs of (p i -p j ) and p i has the same sign as p j The sign of f will be opposite to that of p. j p with opposite sign i Thus, in this example, the sign of the w parameter is set to p i The symbol or p j The opposite sign of the sign of . Fig.11eThe situation shown is its own double, its own opposite, because p i The sign is equal to p j The opposite sign of the sign of .
[0274] exist Fig.11f The first vertex v i At the origin, that is, p i =q i = 0, the second projection vertex v j On the Q axis but not at the origin, that is, p j =0 and q j ≠0. Fig.11f Two types of edges that fall into this category are shown for q j In this example, equation (2) becomes f(v i ,v j )=ε p q j , so the sign of f will be q j Thus, in this example, the sign of the w parameter is set to q j symbol. Fig.11b Shown with Fig.11f The opposite of the situation shown is the dual case, i.e. the reverse case, where the sign of the w parameter is set to be the same as q i The signs of are opposite.
[0275] exist Figure 11g In the figure, vertex v i and v j are all on the P axis, not at the origin, that is, p i ≠0,q i =0,p j ≠0 and q j = 0. Since for strictly convex polygons, valid intersection can only occur when the (undisturbed) edge passes through the origin (i.e., for Figure 11l The edges shown in , cannot intersect with strictly convex polygons), then the edge must intersect Q, so in this example p i and p j Must have opposite signs. Figure 11g It is shown that for p i and p j There are two valid combinations of symbols, two types of edges that fall into this category. In this example, equation (2) becomes f(v i ,v j )=p i ε q -ε q p j =ε q (p i -pj ). Due to p i and p j The signs of (p i -p j ) and p i has the same sign as p j The sign of f will be opposite to that of p. j p with opposite sign i Thus, in this example, the sign of the w parameter is set to p i The symbol or p j The opposite sign of the sign of . Figure 11g The situation shown is its own double, its own opposite, because p i The sign and p j The opposite sign of the sign of .
[0276] exist Fig.11h The first vertex v i At the origin, that is, p i =q i = 0, the second projection vertex v j On the P axis but not at the origin, that is, p j ≠0 and q j =0. Fig.11h Two types of edges that fall into this category are shown for p j In this example, equation (2) becomes f(v i ,v j )=-ε q p j , so the sign of f will be the same as p j Thus, in this example, the sign of the w parameter is set to be the same as that of p. j The signs of are opposite. Fig.11d Shown with Fig.11h The situation shown is the opposite of the dual case, i.e. the opposite case, where the sign of the w parameter is set to p i symbol.
[0277] exist Fig.11i In the figure, the first projection vertex v i Located at the origin, that is, p i =q i = 0, but the second vertex v j The coordinates of p are not zero, that is, j ≠0 and q j ≠0. Fig.11i Four types of edges are shown, which fall into p j and q j In this example, equation (2) becomes f(vi ,v j )=v p q j -ε q p j , so since 0<ε p <<ε q , the sign of f will be the same as p j Thus, in this example, the sign of the w parameter is set to be the same as that of p. j The signs of are opposite. Fig.11a Shown with Fig.11i The situation shown is the opposite of the dual case, i.e. the opposite case, where the sign of the w parameter is set to p i symbol.
[0278] Fig.11j The situation shown in is potentially problematic because we cannot base our i ,q i ,p j and q j The sign of is used to ensure anti-commutativity of the parameter w, but as explained here, it is not actually a problem. This outlines how anti-commutativity of the parameter w cannot be guaranteed: Fig.11e The situation shown is similar, the first vertex v i The coordinates of p are not zero, that is, i ≠0 and q i ≠0, and the second vertex v j The coordinates of p are not zero, that is, j ≠0 and q j ≠ 0. However, in Fig.11j In the case shown, although the edge (if extended) would pass through the origin (making p i q j -q i p j = 0), but the edge actually stops before it reaches the origin. This situation can be identified by observing that the p-coordinates (and / or q-coordinates) of the two vertices have the same sign, i.e., if p i and p j All positive or all negative (in Fig.11j The symbol ± p Instruction), and if q i and q j All positive or all negative (in Fig.11j The symbol ± q ), then we may be in Fig.11j A potential problem with this case is that the edge winding can be reversed without changing the sign of any input, for example by rotating the edges by, say, 180 degrees. Thus, for this case the winding cannot be purely p i,q i ,p j and q j function of the input sign of the coordinates. However, this is not actually a problem because, for this case, it does not matter what sign we choose for w for these edges. This is because, in the case where the polygon including the edges is a strictly convex polygon, no matter what sign we choose for the edges (for example, when two of its edges return opposite signs for their w parameters in the sign inequality intersection criterion), the polygon is degenerate or the ray does not intersect the strictly convex polygon. Thus, we can set the sign of the w parameter to any sign in this example, and it will not introduce any error. However, as described below, this situation is different from Fig.12j The other case shown is indistinguishable (based entirely on p i ,q i ,p j and q j ), which can happen when an RTZ-type implementation is used to compute f (and in this case rounds underflow results towards zero). Since we have assumed that the implementation of the 2D cross product is sign-exact for the kernel of f (e.g., by using “sign-exact rounding”), then Fig.12j In the case shown, the sign of f is correct. Thus, in both alternative cases 11j and 12j, the sign of the w parameter may be set equal to the sign of f (when an RTZ type implementation is used to calculate f, otherwise any value for w may be used). A lookup table or logic array may receive the sign of f as input and set the sign of the w parameter equal to the sign of f. Fig.11j The situation shown is its own double, its own opposite.
[0279] Figure 11k The situation shown is also potentially problematic, because we cannot base our i ,q i ,p j and q j to ensure anti-commutativity of the parameter w, but as explained here, it is not actually a problem. outlines how anti-commutativity of the parameter w cannot be guaranteed; Fig.11c The situation shown is similar, vertex v i and v j are all on the Q axis, not at the origin, i.e. p i =0,q i ≠0,p j =0 and q j ≠ 0. However, in Figure 11k In the case shown, although the edge (if extended) would pass through the origin (making p i q j -q ip j = 0), but the edge actually stops before it reaches the origin. This can be identified by observing that the q coordinates of the two vertices have the same sign, i.e., if q i and q j are all positive or all negative, then we are in Figure 11k The potential problem with this case is that the edge winding can be reversed without changing the sign of any input, for example by rotating the edges by, say, 180 degrees. Thus, for this case the winding cannot be purely p i ,q i ,p j and q j function of the input sign of the coordinates. However, this is not actually a problem because for this case, the sign of w for these edges does not matter. This is because, in the case where the polygon including the edges is a strictly convex polygon, no matter what sign we choose for the edges (for example, when two of its edges return opposite signs for their w parameters in the sign inequality intersection criterion), the polygon is degenerate or the ray does not intersect the strictly convex polygon. Thus, we can set the sign of the w parameter to any sign in this example, and it will not introduce any error (given by Figure 11k (indicated by an X in the middle). Figure 11k The situation shown is its own double, its own opposite.
[0280] Figure 11l The situation shown is also potentially problematic, because we cannot base our i ,q i ,p j and q j to ensure anti-commutativity of the parameter w, but as explained here, it is not actually a problem. outlines how anti-commutativity of the parameter w cannot be guaranteed; Figure 11g The situation shown is similar, vertex v i and v j are all on the P axis, not at the origin, that is, p i ≠0,q i =0,p j ≠0 and q j = 0. However, Figure 11l In the case shown, although the edge (if extended) would pass through the origin (making p i q j -q i p j = 0), but the edge actually stops before it reaches the origin. This situation can be identified by observing that the p coordinates of the two vertices have the same sign, that is, if p i and p j are all positive or all negative, then we are in Figure 11l The potential problem with this case is that the edge winding can be reversed without changing the sign of any input, for example by rotating the edges by, say, 180 degrees. Thus, for this case the winding cannot be purely p i ,q i ,p j and q j function of the input sign of the coordinates. However, this is not actually a problem because for this case, the sign of w for these edges does not matter. This is because, in the case where the polygon including the edges is a strictly convex polygon, no matter what sign we choose for the edges (for example, when two of its edges return opposite signs for their w parameters in the sign inequality intersection criterion), the polygon is degenerate or the ray does not intersect the strictly convex polygon. Thus, we can set the sign of the w parameter to any sign in this example, and it will not introduce any error (given by Figure 11l (indicated by an X in the middle). Figure 11l The situation shown is its own double, its own opposite.
[0281] Figures 11a to 11l All cases of combinations of inputs to the lookup table or logic array are shown for the case where the (extendable) edge can intersect exactly at the origin of the P and Q axes. Thus, when using a RAZ type implementation, Figures 11a to 11l All situations where a lookup table or logic array is used are shown, and the output of the lookup table or logic array for different combinations of inputs is indicated.
[0282] In some other examples, the polygon intersection test unit 114 can operate according to an implementation of a 2D cross product that is not a RAZ type for determining the w parameter. For example, the implementation of the 2D cross product can use a rounding mode of rounding to nearest, rounding to zero, rounding to positive infinity, or rounding to negative infinity. When a non-RAZ implementation type is used, the value of f can be determined to be (±) zero, even if the exact value of f is not zero. For example, a value of f that is very close to zero can be rounded to (±) zero. This loss of precision in calculations involving floating point numbers is called "underflow". Therefore, when a non-RAZ but still sign-accurate implementation type (expressed as RTZ) is used to calculate a 2D cross product, a lookup table or logic array needs to take into account the situation where the edge does not exactly intersect with the origin (except for the situation where the edge exactly intersects with the origin). One way to achieve this is to provide an indication that an underflow has occurred, and in that case proceed to step S906 as if a non-zero value had been calculated, or equivalently, to provide both the indication of underflow and the sign of f as additional inputs to the lookup table in step S910 so that the sign is used as the output. However, there are alternative methods to utilize steps S908 and S910, which are now described. Figures 12a to 12jThe positions of the P and Q axes are shown, as well as edges that do not intersect the origins of the P and Q axes exactly, but since the kernel of its implementation is a strict superset of its own kernel (e.g., due to underflow in the calculation), f can be determined to be zero. Figures 11a to 11l , each edge in Figures 12a to 12j The vertices v that are connected to define the edges i to v j The line shows that the arrow points from v i to v j The actual vertex v i and v j exist Figures 12a to 12j Not marked in. Figures 12a to 12j Also shown is the location of the origin 1202, which does not appear to be perturbed because p is similar to that in these underflow cases. i ,q i ,p j and q j Compared with the non-zero value of p and ε q is negligible.
[0283] exist Fig.12a In the figure, the first projection vertex v i On the Q axis but not at the origin, that is, p i =0 and q i ≠0, and the second projected vertex v j On the P axis but not at the origin, that is, p j ≠0 and q j =0. Fig.12a Four types of edges are shown, which fall into q i and p j In this example, the 2D cross product is f(v i ,v j )=-q i p j , so the sign of f will be the same as q i and p j Thus, in this example, the sign of the w parameter is set to be the same as that of q. i and v j The product of the signs is opposite. Figure 12b It is shown in Fig.12a The opposite of the case shown in FIG. 1 is the opposite case, for which the sign of the w parameter is set equal to p. i and q j The product of the signs of .
[0284] When the sign is represented as + or - to represent +1 or -1, we take the product of the signs to combine them, and we negate to get the opposite result. When the sign is represented as 0 or 1, we XOR the signs, or equivalently, sum the signs modulo 2, to combine them, and then NOT, equivalently, complement, to get the opposite result. Figures 12a to 12i The symbols in can indicate any of these corresponding operations according to the specific representation.
[0285] exist Figure 12b In the figure, the first projection vertex v i On the P axis but not at the origin, that is, p i ≠0 and q i = 0, and the second projected vertex v j On the Q axis but not at the origin, that is, p j =0 and q j ≠0. Figure 12b Four types of edges are shown, which fall into p i and q j In this example, the 2D cross product is f(v i ,v i )=p i q j , so the sign of f will be the same as p i and q j Thus, in this example, the sign of the w parameter is set to be the same as that of p. i and q j The product of the signs is the same. Fig.12a Shown with Figure 12b The opposite of the case shown is the double case, i.e. the opposite case, for which the sign of the w parameter is set to be the same as that of q i and p j The product of the signs is opposite.
[0286] exist Fig.12c In the figure, the first projection vertex v i On the Q axis but not at the origin, that is, p i =0 and q i ≠0, and the second vertex v j The coordinates of p are not zero, that is, j ≠0 and q j ≠0. Fig.12c Eight types of edges are shown, which fall into q i ,p j and q j In this example, the 2D cross product is f(v i ,v j ) = -q i pj , so the sign of f will be the same as q i and p j Thus, in this example, the sign of the w parameter is set to be the same as that of q. i and p j The product of the signs is opposite. Fig.12e It is shown in Fig.12c The opposite of the case shown in FIG. 1 is the opposite case, for which the sign of the w parameter is set equal to p. i and q j The product of the signs of .
[0287] exist Fig.12d In the figure, the first projection vertex v i On the P axis but not at the origin, that is, p i ≠0 and q i = 0, and the second vertex v j The coordinates of p are not zero, that is, j ≠0 and q j ≠0. Fig.12d Eight types of edges are shown, which fall into p i ,p j and q j In this example, the 2D cross product is f(v i ,v j )=p i q j , so the sign of f will be the same as p i and q j Thus, in this example, the sign of the w parameter is set to be the same as that of p. i and q j The product of the signs is the same. Fig.12f Shown with Fig.12d The opposite of the case shown is the double case, i.e. the opposite case, for which the sign of the w parameter is set to be the same as that of q i and p j The product of the signs is opposite.
[0288] exist Fig.12e The first vertex v i The coordinates of p are not zero, that is, i ≠0 and q i ≠0, and the second projected vertex v j On the Q axis but not at the origin, that is, p j =0 and q j ≠0. Fig.12e Eight types of edges are shown, which fall into p i ,q i and q jIn this example, the 2D cross product is f(v i ,v j )=p i q j , so the sign of f will be the same as p i and q j Thus, in this example, the sign of the w parameter is set to be the same as that of p. i and q j The product of the signs is the same. Fig.12c Shown with Fig.12e The opposite of the case shown is the double case, i.e. the opposite case, for which the sign of the w parameter is set to be the same as that of q i and p j The product of the signs is opposite.
[0289] exist Fig.12f The first vertex v i The coordinates of p are not zero, that is, i ≠0 and q i ≠0, and the second projected vertex v j On the P axis but not at the origin, that is, p j ≠0 and q j =0. Fig.12f Eight types of edges are shown, which fall into p i ,q i and p j In this example, the 2D cross product is f*v i ,v j )=-q i p j , so the sign of f will be the same as q i and p j Thus, in this example, the sign of the w parameter is set to be the same as that of q. i and p j The product of the signs is opposite. Fig.12d It is shown in Fig.12f The opposite of the case shown in FIG. 1 is the opposite case, for which the sign of the w parameter is set equal to p. i and q j The product of the signs of .
[0290] and Figure 12g The situation shown in is potentially problematic because we cannot base our i ,q i ,p j and q jto ensure anti-commutativity of the parameter w, but this problem can be overcome as explained here. Outlines how anti-commutativity of the parameter w cannot be guaranteed; Fig.11e The situation shown is similar, the first vertex v i The coordinates of p are not zero, that is, i ≠0 and q i ≠0, and the second vertex v j The coordinates of p are not zero, that is, j ≠0 and q j ≠ 0. In this case, p i and q i The symbol (in Figure 12g The symbol ± p and ± q instructions) match each other, but with p j and q j The symbol (in Figure 12g Symbols and However, in Figure 12g In the case shown, the edge does not pass through the origin exactly, but rather f is determined to be equal to (±) zero only if the kernel it implements is a strict superset of its own kernel (e.g., due to underflow in the computation). A potential problem with this case is that the edge winding can be reversed without changing the sign of any input, for example by passing the edge through the origin. Therefore, for this case, the winding cannot be purely p i ,q i ,p j and q j is a function of the sign of the input coordinates. In particular, p i ,q i ,p j and q j The sign of the underflow condition cannot be distinguished ( Figure 12g ) and the true f=0 case ( Fig.11e ), so even with "sign-accurate rounding", Figure 12g The situation shown in cannot be handled correctly either, as it will be Fig.11e To overcome this potential problem, the implementation of the 2D cross product can flag the underflow case to detect this alternative case 12g. The underflow flag can be passed as an additional input bit to a lookup table or logic array to detect the underflow case when the flag is not set. Fig.11e The sign of the case in which this flag is set determines the Figure 12g As an alternative, when the 2D cross product identifies f=0, an unused encoding of the floating point format is utilized; the input p i ,qi ,p j and q j The coordinate symbols are Fig.11e and 12g As shown; and underflow will occur (indicates Figure 12g ); then, instead of rounding to (±) zero, the non-round result of the 2D cross product can be encoded as a special flag -ε or +ε. Therefore, in this alternative, and assuming that the f=0 edge case is avoided, the sign of the 2D cross product (i.e., the sign of -ε or +ε) will be used as the sign of the w parameter, the same as for all f≠0 cases. Figure 12g The situation shown is its own double, its own opposite, Fig.11e The same situation in .
[0291] Figure 12h The situation shown is similar to Fig.11e The situation shown is similar, because the first vertex v i The coordinates of p are not zero, that is, i ≠0 and q i ≠0, and the second vertex v j The coordinates of p are not zero, that is, j ≠0 and q j ≠ 0. However, it is Fig.11e The situation shown is different because p i and p j The signs of q are opposite to each other, and i and q j The signs of and match each other. In this example, the 2D cross product is f(v i ,v j )=p i q j -q i p j , and since we know that p i and p j The signs of q are opposite to each other, and i and q j The signs of the two match each other, so the sign of f will be equal to p i and q j The product of the signs of i and p j Thus, in this example, the sign of the w parameter is set equal to p. i and q j The product of the signs of i and p j The product of the signs is opposite. Figure 12h The situation shown is its own double, its own opposite, because p i The sign and pj The signs of q are opposite, and i The sign and q j The symbol matches.
[0292] Fig.12i The situation shown is similar to Fig.11e The situation shown is similar, because the first vertex v i The coordinates of p are not zero, that is, i ≠0 and q i ≠0, and the second vertex v j The coordinates of p are not zero, that is, j ≠0 and q j ≠ 0. However, it is Fig.11e The situation shown is different because p i and p j The signs of q match each other, and i and q j The signs of are opposite to each other. In this example, the 2D cross product is f(v i ,v j )=p i q j -q i p j , and since we know that p i and p j The signs of q match each other, and i and q j The signs of f and q are opposite to each other, so the sign of f will be the same as that of q. i and p j The product of the opposite signs is p i and q j Thus, in this example, the sign of the w parameter is set to be the same as that of q. i and p j The product of the signs of i and q j The product of the signs is opposite. Fig.12i The situation shown is its own double, its own opposite, because q i The sign and q j The signs of p are opposite, and p i The sign and p j The symbol matches.
[0293] and Fig.12j The situation shown in is potentially problematic because we cannot base our i ,q i ,p j and q jThe sign of is used to ensure anti-commutativity of the parameter w, but this problem can be overcome as explained here. This outlines how anti-commutativity of the parameter w cannot be guaranteed: Fig.11e The situation shown is similar, the first vertex v i The coordinates of p are not zero, that is, i ≠0 and q i ≠0, and the second vertex v j The coordinates of p are not zero, that is, j ≠0 and q j ≠ 0. In this case, p i and p i The signs of q match each other, and (independently) i and q j The signs of match each other. However, in Figure 12g In the case shown, the edge does not pass through the origin exactly, but rather the realization of the 2D cross product f is determined to be equal to (±) zero simply because the kernel of its realization is a strict superset of its own kernel (e.g., due to underflow in the computation). Fig.11j As in the case shown, a potential problem with this case is that the edge winding can be reversed without changing the sign of any input, for example by rotating the edges by, for example, 180 degrees. Thus, for this case, the winding cannot be purely p i ,q i ,p j and q j However, we can verify this by checking the realization of the 2D cross product f = 0 and by checking the input p i ,q i ,p j and q j The coordinates have the appropriate sign to detect Fig.12j and Fig.11j We have assumed that the implementation of the 2D cross product function has “sign-accurate rounding” of the kernel of f, which means that even in the case of underflow, e.g. Fig.12j In the case shown in , the sign of the realization of the 2D cross product also matches the sign of f. Thus, the sign of the w parameter can be set equal to the sign of f. The lookup table or logic array can receive the sign of f as input and set the sign of the w parameter equal to the sign of f. Fig.11j and Fig.12j The case shown is indistinguishable to a lookup table or logic array (i.e., the same input ternary digits are received for both cases), so Fig.11j In the case shown (when an RTZ type implementation is used to compute f, otherwise any value for w can be used), the sign of the w parameter is also set equal to the sign of f, which is good because, as mentioned above, the sign of w is Fig.11jThis does not matter in the case shown, since strictly convex polygons containing such edges cannot intersect. Fig.12j The situation shown is its own double, its own opposite.
[0294] For each of the four input coordinates, there is a rule of three (negative, (±) zero, positive). When the convex polygon is a triangle, p i =q i =p j =q j = 0 need not be included in the lookup table or logic array, since in general any projected edge makes p i =p j and q i =q j The edges that represent degenerate projections, i.e. they appear as points, and the triangular polygons that include such edges can be discarded, since they must be degenerate, and the ray does not need to be determined to intersect the degenerate polygons. Therefore, there are 3 4 –1 = 80 examples (excluding degenerate lines), and Figures 11a to 12j It is shown what sign of w is output from the lookup table or logic array for each of these classifications.
[0295] For a general convex polygon with n edges, at least n-2 projected edges must be degenerate in order for the projected polygon to be degenerate, i.e., have zero projected area, and therefore be culled freely. If there are fewer than n-2 degenerate projected edges, then the sign of the degenerate edge test may be ignored when testing all edges for equality of sign (i.e., p i =p j and q i =q i ), so p i =q i =p j =q j = 0 also does not need to be included in the lookup table of the logical array for general convex polygons. Such edges can be detected simply by checking whether the two projected endpoints are equal. Geometrically, high-order polygons with such degenerate edges are collapsed into low-order polygons (similar to non-strictly convex polygons). This anomaly can be avoided by ensuring that the two vertices of a strictly convex polygon are not equal. When the normal of a (planar) convex polygon is perpendicular to the light direction, it will also have zero area because it behaves as a line, and therefore will also be a degenerate projected polygon, even if it has no degenerate (i.e., point) projected edges.
[0296] In one example, two bits can be used as inputs of coordinates to indicate negative, zero, or positive. For example, the first bit can indicate that the input coordinate is zero or non-zero, and the second bit can indicate that the input coordinate is negative or positive. In this example, in the case where the first bit indicates that the input coordinate is zero, it does not matter what the second bit is; and if the first bit indicates that the input coordinate is non-zero, the second bit is used to indicate that the input coordinate is negative or positive. In another example, for each of the four input coordinates, three values of the ternary digits (i.e., 0, 1, and 2) can be assigned to encode the trichotomy -, ±0, or + in any order. Then, the four ternary digits (possibly plus an additional bit for the sign of the 2D cross product, possibly plus another additional bit for underflow detection, both for RTZ implementation types) can be merged into a value between 0 and 80 (e.g., representing a case ID between 1 and 81 as shown in the following table) (or between 0 and 161, or between 0 and 323), so that the value can be encoded with 7 (or 8, or 9) bits of binary.
[0297] The lookup table or logic array may be hard-coded in fixed function circuitry in the polygon intersection test unit 114 of the intersection test module 108. Table 2 below shows an example of the input and output of an implementation of the lookup table or logic array, with some explanatory comments. Input coordinate p i ,q i ,p i or q j A value of 0 indicates a value of + or - zero. Similarly, a result of 0 for a realization of the 2D cross product f indicates a value of ± zero. For any input to the output, a "don't care" value is represented by the symbol "X":
[0298]
[0299]
[0300]
[0301] Table 2: Example input, output, and description data for a lookup table or logic array
[0302] It can be seen that Table 2 is symmetric about its median value (i.e., case 41), such that when proceeding from case c to case 82-c, the underflow case maintains its output sign (because rotating the edge 180 degrees should fix the cycle of internal intersections), while the f=0 case reverses its sign (because rotating the edge 180 degrees should reverse the cycle of intersections on the edge). Table 2 also has symmetry in its duality: swapping the first two ternary digits with the second two ternary digits, switching between one case and its dual, reverses the output sign as required by the inverse property of the signed area calculation. Both of these properties can be exploited to reduce the size of the LUT implementing Table 2, or to reduce the complexity of the logic array implementing Table 1, by using a certain amount of pre-processing or post-processing logic.
[0303] In the table above, the "Dual Case ID" column gives the case ID for the case where the order of the vertices defining the edge has been swapped. As can be seen, the dual case gives opposite outputs for the sign of the w parameter. This ensures that when a ray intersects a shared edge, it is determined to intersect one (and only one) of the polygons that include the shared edge. In the last column, "f=0" indicates that this occurred because the 2D cross product is exactly zero, i.e., no underflow occurred (e.g., as in Figures 11a to 11l In the last column, “Underflow” indicates that this occurs due to underflow in the implementation of the 2D cross product, even if the exact value of f is nonzero (e.g., as Figures 12a to 12j 108). When the RAZ implementation type is used, the lookup table or logic array need not include rows that occur only due to underflow, and need not include an underflow flag or the sign of f as an input column. Therefore, if the rounding mode is known to be the RAZ implementation type, the lookup table or logic array can be made smaller, thereby reducing the amount of silicon required to hard code the lookup table or logic array into the intersection test module 108. In other words, in the RAZ implementation type, the situation indicated as "underflow" in the above table is not a p-value of the lookup table or logic array. i ,q i ,p j and q j 0, they cannot effectively occur because f and its implementation have matching kernels. However, when the RTZ implementation type is used (and step S904 has not been modified so that step S906 is performed if underflow occurs), then the lookup table or logic array does include rows that can occur only due to underflow (as well as all other rows), and these cases do represent p of the lookup table or logic array. i ,q i ,p j and q j"Valid" combinations of classifications of coordinates, i.e., they can effectively occur when f = ±0 because the kernel of the realization of f is a strict superset of its own kernel. As described in the above example, if it is determined that the 2D cross product is not exactly equal to zero, but is rounded to zero, the underflow flag is set during the determination of the 2D cross product. If the magnitude of w is zero and the underflow flag is not set, the entry in the lookup table of the RTZ example can be avoided by only calling the strict behavior. In other words, in some examples, it can be determined that the ray intersects a point on the edge if: (i) the 2D cross product of the positions of the two projected vertices defining the edge has a magnitude of zero, and (ii) the underflow flag is not set during the determination of the 2D cross product. In these examples, if it is determined that the 2D cross product of the positions of the two projected vertices defining the edge has a magnitude of zero, but the underflow flag has been set during the determination of the 2D cross product, it is determined that the ray does not intersect the point on the edge, and the sign of w of the edge can be set equal to the sign of the 2D cross product (which is +0 or -0).
[0304] For some rows of the lookup table or logic array, the output value is represented by an "X" indicating a "don't care" result. In these examples, the sign of w does not matter because a strictly convex polygon with such edges cannot be intersected by the ray, for example because the ray does not pass inside one of the other edges of the polygon. i =q i =p j =q j = 0: The triangular polygon including this edge is degenerate and can be discarded, or this edge of a higher order polygon can be identified to exclude its sign from the intersection determination. In either case, it does not need to be included in the lookup table or logic array.
[0305] In step S912, an output indicating the sign of the w parameter from the lookup table or logic array is received at the polygon intersection test unit 114 of the intersection test module 108. The method then moves to step S314 described above, and the method continues.
[0306] The approach of determining intersection only when the common plane orientation matches the winding orientation of the shared edges ensures "non-redundant strictness" where the polygons forming the mesh have a consistent winding order even on silhouette edges, and is thus denoted as a "winding / orientation-dependent" scheme, as described previously. Figure 4 , 59, when used in conjunction with a signed equality test in step S318, ensures "non-redundant strictness" even when the polygons forming the mesh do not have a consistent winding order, but are not on silhouette edges (where zero or double hits may occur), and is therefore denoted as a "winding / orientation independence" scheme. In some implementations, it is safe to assume that the geometry (i.e., polygons) will be submitted to the ray tracing system 100 in a consistent winding order (e.g., orientable surfaces). However, it is possible that the polygons may be submitted to the ray tracing system 100 in an inconsistent winding order, e.g., non-orientable surfaces. In either case, as described by considering Figures 13a to 13d As shown, "non-redundant strictness" cannot be ensured universally (i.e., with arbitrary winding and open and closed silhouette edges) using any method. However, by alternating between "winding / orientation-dependent" and "winding / orientation-independent" schemes, we can choose where zero and double hits occur, such as on or outside the silhouette edges of a polygon mesh.
[0307] For example, in Fig.13a and Fig.13b The distinction between “winding / orientation-dependent” and “winding / orientation-independent” schemes is clearly shown in the function, which shows three polygon pairs (color-coded black / grey) projected onto the PQ plane for both scheme types: Fig.13a corresponds to the “winding / orientation-dependent” scheme; Fig.13b corresponds to the "winding / orientation independence" scheme. Fig.13a and Fig.13b In the perceptual orientation of polygons and cycles of directed edges, zero indicates a clockwise orientation and one indicates a counterclockwise orientation. In each corresponding polygon pair, a directed edge passing through the origin is considered clockwise when pointing right or just above, and is considered counterclockwise when pointing left or just below. This exhibits a "left-up rule" behavior for polygons with a clockwise orientation.
[0308] Fig.13a and Fig.13b The first (i.e., upper left) corresponding polygon pair in represents the default configuration: for two polygons oriented clockwise, the ray intersects a consistent shared edge (i.e., the edges have opposite winding directions in the two polygons that share the edge). In this case, the consistent shared edge is considered to be part of the lower right polygon (gray) because all three edges match that polygon.
[0309] Fig.13a and Fig.13bThe second (i.e., top-right) corresponding polygon pair in represents a configuration rotated 180 degrees, where the ray still intersects the same consistent shared edge. When the rotation has been applied, the two polygons still have a clockwise orientation, and in either mode, the consistent shared edge is still considered part of the bottom-right polygon (now the black polygon) because all three edge Booleans still match that polygon.
[0310] Fig.13a and Fig.13b The third (i.e., lower left) corresponding polygon pair in represents a configuration that is reflected along a consistent shared edge (e.g., when the edge is folded so that it falls behind the contour), where the ray still intersects that same consistent shared edge. When reflection is applied, the two polygons now have a counterclockwise orientation. In the strict scheme of "with winding / orientation independence" ( Fig.13b ), the consistent edge is still considered part of the lower right polygon (now the black polygon) because all three edges tilted back still match that polygon (albeit with opposite values), and thus still exhibit the "upper left rule" behavior. In the strictness scheme of "winding / orientation dependence" ( Fig.13a ), the consistent shared edges are now considered to be part of the top-left polygon (now the grey polygon), because all three edges now match that polygon, so the dual behavior, i.e. the "bottom-right rule", is now exhibited.
[0311] Two types of solutions ( Fig.13a and Fig.13b ) only takes effect in the case of reflection, because the polygon's orientation has changed. You can get one behavior from the other by XORing (involution) the edge-on-edge Boolean value by the polygon's orientation Boolean value (described below).
[0312] Fig.13c A mesh of polygons 1302 to 1320 is shown forming a circular band (i.e., a ring), indicated by appropriate shading, whose edges are considered part of each polygon in a "winding / orientation-dependent" scheme (e.g., as described above with reference to a method in which intersection is determined only if the common plane direction matches the winding direction of the shared edges). Fig.13cis a view of the (unprojected) polygons from a viewpoint slightly above the camera origin, for a camera that fires primary rays away from its origin. From the camera origin, only primitives 1302 to 1310, represented as front polygons, may be visible, while primitives 1312 to 1320, represented as back polygons, may be occluded by primitives in front of them. From the viewpoint shown, the outline boundary of the polygon mesh is given by the boundaries between the front and back polygons, i.e., the shared edges between polygons 1302 and 1320 and the shared edges between polygons 1310 and 1312. The clockwise orientation of the front polygons wraps consistently with the counterclockwise orientation of the back polygons, and the counterclockwise orientation of the front polygons (e.g., polygon 1306) wraps consistently with the counterclockwise orientation of the back polygons ( Fig.13c This can be understood by imagining a rotating polygon strip and considering how the orientation of each polygon changes as it transitions from a front polygon (i.e., in front of the outline) to a back polygon (i.e., behind the outline) and vice versa. The winding order of each polygon can be obtained from Fig.13c , and it can be seen that, except for polygon 1306, all polygons have a consistent winding order (i.e., in two polygons that share an edge, each edge has an opposite winding direction). The polygons are color-coded alternately gray or black for visual clarity only: the color of the polygon is in Fig.13c , as seen by the color of the winding symbol inside the polygon. When only a single hit occurs, the shared edge has a solid black or gray line to indicate that the black polygon or gray polygon in the shared edge will be hit by a ray that exactly intersects the shared edge. Note that the shared silhouette edge between polygons 1302 and 1320 and the shared silhouette edge between polygons 1310 and 1312 only return a single hit. When no hit occurs, the light gray dashed edge indicates that no hit occurs. Fig.13c The polygons shown in will be hit by a ray that exactly intersects the edge. When a double hit occurs, the shared edge has black and gray dashed lines to indicate that the black polygon and the gray polygon that share the edge will be hit by a ray that exactly intersects the shared edge. For example, due to the inconsistent winding order of polygon 1306 relative to other polygons, for an inconsistent shared edge between polygons 1304 and 1306, both polygons will be determined to be hit by a ray that exactly intersects the shared edge. Similarly, for an inconsistent shared edge between polygons 1306 and 1308, both polygons will be determined to be hit by a ray that exactly intersects the shared edge. In Fig.13c In other examples not shown in , zero hits may occur on shared edges that are interior to a polygon mesh (i.e., not on a silhouette boundary) due to inconsistent winding. For the "winding / orientation-dependent" scheme, double / zero hits may cause rendering redundancy / artifacts at locations on such shared edges, respectively.
[0313] Occurrences of such rendering redundancies / artifacts described in the aforementioned examples (which may occur due to inconsistent winding order of the polygons forming the mesh) cannot be universally removed, but they can be relocated so that they only appear at the silhouette edges of the polygonal mesh. Visual artifacts at the silhouette edges of geometry in the rendered image are less noticeable to an observer of the rendered image than visual artifacts in the middle of objects, which, for example in the case of zero hits, can give the appearance of an object with holes in it such that background color or occluded geometry can be seen through the object. Despite the improvement in visual artifacts, rendering redundancies in the form of double hits still occur. Therefore, in general, it is preferred to move possible drawing artifacts to the silhouette edges. This can be achieved in winding / orientation independence schemes (e.g., see Figure 4 , 5 and 9 described method) is implemented, the scheme refers to Fig.13d describe.
[0314] Fig.13d Shown with Fig.13cA polygon mesh identical to the polygons shown in , which forms a circular band (i.e., a ring) with appropriate shading, whose edges are considered to be part of each polygon in the "winding / orientation-independent" scheme. To modify the "winding / orientation-dependent" scheme to a "winding / orientation-independent" scheme, the same method can be used for intersection testing, but when the ray intersects a point on an edge of a polygon (i.e., when f = ±0), a post-processing XOR operation is performed on the sign of the w parameter plus the sign of the w parameter of the other edge of the convex polygon. For example, if it is determined that the ray intersects a point on the edge of a convex polygon, then between steps S314 and S318, there is an additional step of performing an XOR operation using: (i) the sign of the signed parameter w for the edge, such that f = ±0, and (ii) the sign of the signed parameter w for the edge, such that f≠±0, indicating the perceived orientation of the convex polygon. Note that for any non-degenerate convex polygon (i.e., having a non-zero projected area), there exists at least one edge such that f is not equal to zero (otherwise the projected area of the convex polygon would be zero, being a sum of zeros). A sign of 0 for the signed parameter w can be used to indicate a clockwise orientation of the convex polygon, while a sign of 1 for the signed parameter w can be used to indicate a counterclockwise orientation of the convex polygon (or vice versa). The result of the XOR operation can be used as the sign bit of the w parameter, which can then be used to determine whether the ray intersects the convex polygon (e.g., by checking that the signs of all edges of the convex polygon are equal). By moving double / zero hits to the silhouette boundary of the polygon mesh, this ensures "non-redundant strictness" within the polygon mesh, even if the winding order of the polygons is inconsistent. However, this may result in a lack of "non-redundant strictness", e.g., double / zero hits, on the silhouette edges of the polygon mesh, regardless of the winding order of the two polygons sharing the silhouette edge. For example, in Fig.13d , there are no rendering artifacts in the interior of the polygon mesh (i.e., not on the silhouette boundaries) (e.g., there are no rendering artifacts on the edge of polygon 1306, even though it has an inconsistent winding order relative to other polygons). However, on the left silhouette shared edge (i.e., the edge shared by polygons 1302 and 1320), both polygons 1302 and 1320 will be determined to be hit by a ray that exactly intersects the shared edge, as shown by the black and gray shading of the dashed lines. On the right silhouette shared edge (i.e., the edge shared by polygons 1310 and 1312), neither polygon 1310 nor 1312 will be determined to be hit by a ray that exactly intersects the shared edge, as shown by the light gray shading of the dashed lines. Both of these behaviors occur even if polygons 1302, 1310, 1312, and 1320 have a consistent winding order. However, in some applications, it is actually desirable for a pair of intersections to occur through any convex object (e.g., in refraction) in order to define entry and exit points. In this case, the winding-independent scheme guarantees the desired behavior, while the winding-dependent scheme does not.
[0315] As a post-processing XOR operation on the involution, it can be used to transform a "winding / orientation-dependent" scheme into a "winding / orientation-independent" scheme, and it can be used to transform a "winding / orientation-independent" scheme into a "winding / orientation-dependent" scheme. Thus, this technique can be used to convert a method where intersection only occurs when the common plane direction matches the winding direction of the shared edge into a "winding / orientation-independent" scheme, and also to convert the above referenced Figure 4 , 5 and 9 into a “winding / orientation-dependent scheme”.
[0316] In some examples of "winding / orientation independence" schemes (e.g., see above for reference Figure 4 , 5 and 9), a ray is determined to intersect a convex polygon if and only if the signs of the w parameters for all edges of the convex polygon are equal. For example, for a triangular polygon, we will intersect it if and only if for the signed parameters w0, w1 and w2 (corresponding to the three edges of the triangle) sgn(w0) = sgn(w1) = sgn(w2). After modifying the scheme to "winding correlation", if w0 is a signed parameter for the on-edge case (i.e., f = ±0) and w1 is a signed parameter for the off-edge case (i.e., f≠±0), then through a post-processing XOR operation, the intersection determination becomes sgn(w0)⊕sgn(w1) = sgn(w1) = sgn(w2). This is only satisfied when sgn(w0) = 0. In other words, for intersection to occur, the sign of the signed parameter w0 used for the on-edge case must be 0, regardless of the sign of the signed parameter of any other edge. In this case, the intersection logic can be reformulated as (sgn(w0)=0)∧(sgn(w1)=sgn(w2)). Otherwise, for intersection to occur, the sign of the signed parameter w0 must be 1, and the "winding dependency" scheme exhibits inverted tie-breaking behavior for edge cases. Note that this is consistent with the previously described intersection criteria that treat edge intersections as special cases rather than simple signed equality tests. Here, we describe a method to reconcile these two approaches using a flexible overarching scheme.
[0317] By augmenting the edge signs with the signs of the polygons (indicating their perceived orientation) in a "winding / orientation-dependent" scheme, the tie-breaking behavior is reversed between polygons with sign 0 and polygons with sign 1. The eight representations of tie-breaking behavior are divided into four pairs: "upper-left rule" and "lower-right rule", "upper-right rule" and "lower-left rule", "upper-left rule" and "lower-right rule", "upper-right rule" and "lower-left rule". One member of each of these tie-breaking behavior pairs corresponds to a polygon with sign 0, and the other member corresponds to a polygon with sign 1. This is in Fig.13c , where the "lower-right rule" applies to polygon 1306, while the "upper-left rule" applies to all other polygons.
[0318] In summary, if it is desired (or even guaranteed) to provide a consistent polygon winding order, such as an orientable surface such as a torus, then a "winding / orientation-dependent" scheme may be preferred, whereas if it is desired (or even impossible to avoid) to provide an inconsistent polygon winding order, such as a non-orientable surface such as a Möbius strip, then a "winding / orientation-independent" scheme may be preferred.
[0319] Fig.14 A computer system in which the ray tracing system described herein may be implemented is shown. The computer system includes a CPU 1402, a GPU 1404, a memory 1406, and other devices 1414, such as a display 1416, a speaker 1418, and a camera 1422. A ray tracing unit 1410 (corresponding to the ray tracing unit 102) is implemented on the GPU 1404 and a neural network accelerator (NNA) 1411. In other examples, the ray tracing unit 1410 may be implemented on the CPU 1402 or within the NNA 1411, or as a separate processing unit in the computer system. The components of the computer system may communicate with each other via a communication bus 1420. A storage device 1412 (corresponding to the memory 104) is implemented as part of the memory 1406.
[0320] Figure 1 The ray tracing system is shown as comprising several functional blocks. This is merely illustrative and is not intended to define a strict division between different logical elements of such an entity. Each functional block may be provided in any suitable manner. It should be understood that the intermediate values described herein as being formed by the ray tracing system need not be physically generated by the ray tracing system at any point in time, and may simply represent logical values that are convenient for describing the processing performed by the ray tracing system between its input and output.
[0321] The ray tracing unit, and specifically the intersection test module described herein, can be embodied in hardware on an integrated circuit. The intersection test module described herein can be configured to perform any of the methods 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" may be used herein to generally represent software, firmware, hardware or any combination thereof. In the case of a 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 disk, 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.
[0322] 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 written in languages such as C, Executable code can be, for example, any kind of software, firmware, script, module or library that, when properly executed, processed, interpreted, compiled, or run in a virtual machine or other software environment, enables the processor of a computer system supporting the executable code to perform the tasks specified by the code.
[0323] 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.
[0324] The present invention is also intended to cover software that defines the configuration of hardware as described herein, such as HDL (Hardware Description Language) software, for designing integrated circuits or for configuring programmable chips to perform desired functions. That is, a computer-readable storage medium may be provided having encoded thereon computer-readable program code in the form of an integrated circuit definition data set that, when processed (i.e., run) in an integrated circuit manufacturing system, configures the system to manufacture an intersection test module configured to perform any of the methods described herein, or to manufacture an intersection test module that includes any of the devices described herein. The integrated circuit definition data set may be, for example, an integrated circuit description.
[0325] Thus, a method of manufacturing an intersection test module as described herein at an integrated circuit manufacturing system may be provided. Furthermore, an integrated circuit definition data set may be provided which, when processed in an integrated circuit manufacturing system, enables the method of manufacturing an intersection test module to be performed.
[0326] 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.
[0327] Now about Fig.15 An example of processing an integrated circuit definition data set at an integrated circuit manufacturing system to configure the system to manufacture an intersection test module is described.
[0328] Fig.15An example of an integrated circuit (IC) manufacturing system 1502 is shown, which is configured to manufacture an intersection test module as described in any of the examples herein. In particular, the IC manufacturing system 1502 includes a layout processing system 1504 and an integrated circuit generation system 1506. The IC manufacturing system 1502 is configured to receive an IC definition data set (e.g., defining an intersection test module as described in any of the examples herein), process the IC definition data set, and generate an IC (e.g., which embodies an intersection test module as described in any of the examples herein) based on the IC definition data set. The processing of the IC definition data set configures the IC manufacturing system 1502 to manufacture an integrated circuit that embodies an intersection test module as described in any of the examples herein.
[0329] The layout processing system 1504 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, such as 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 1504 has determined the circuit layout, it may output the circuit layout definition to the IC generation system 1506. The circuit layout definition may be, for example, a circuit layout description.
[0330] As is known in the art, IC generation system 1506 generates an IC according to a circuit layout definition. For example, IC generation system 1506 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 may 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 1506 may be in the form of a computer readable code that IC generation system 1506 may use to form a suitable mask for generating an IC.
[0331] The different processes performed by IC manufacturing system 1502 may all be performed at one location, such as by one party. Alternatively, IC manufacturing system 1502 may be a distributed system such that some processes may be performed at different locations and may be performed 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.
[0332] In other examples, processing the integrated circuit definition data set at the integrated circuit manufacturing system may configure the system to manufacture the intersection test module without processing the IC definition data set to determine the circuit layout. For example, the integrated circuit definition data set may define the configuration of a reconfigurable processor such as an FPGA, and processing the data set may configure the IC manufacturing system to generate (e.g., by loading the configuration data into the FPGA) the reconfigurable processor having the defined configuration.
[0333] In some embodiments, when processed in an integrated circuit manufacturing system, the integrated circuit manufacturing definition data set may enable the integrated circuit manufacturing system to generate an apparatus as described herein. Fig.15 An integrated circuit manufacturing system configured in the manner described may manufacture the apparatus as described herein.
[0334] 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.15 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.
[0335] Compared with 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 improve performance. Performance improvements can include one or more of improved computing performance, reduced latency, increased throughput and / or reduced power consumption. During the manufacture of such devices, devices, 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, devices, modules and / or systems. In contrast, the concepts of improvements (such as reduced silicon area) that cause physical implementations of devices, devices, modules and systems set forth in this application can be compromised for performance improvements. For example, this can be accomplished by manufacturing multiple examples of modules within a predefined area budget.
[0336] 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 method of performing intersection testing of a ray with respect to a plurality of convex polygons in a ray tracing system, wherein each of the convex polygons is defined by an ordered set of vertices representing a cyclic order, and wherein at least one vertex in the ordered set of vertices is a shared vertex for defining two or more of the convex polygons, the method comprising: projecting the vertices of the convex polygon onto a pair of axes orthogonal to the direction of the light ray to obtain projected vertices, wherein an origin of the pair of axes corresponds to an origin of the light ray, and wherein a planar vertex ordering scheme defines an ordering of the projected vertices, the planar vertex ordering scheme defining a direction of each edge of the convex polygon, wherein the direction of each edge defined by the planar vertex ordering scheme is independent of an inherited direction of the each edge inherited from the cyclic ordering of vertices in the ordered set of vertices defining the convex polygon; and For each of the convex polygons: for each edge of the convex polygon defined by two of the projected vertices, determining a parameter indicating which side of the edge the ray passes, wherein if it is determined that the ray intersects a point on the edge, the parameter is determined based on whether an edge direction defined by the planar vertex ordering scheme matches an edge direction inherited from the cyclic ordering of the vertices in the ordered set of vertices defining the convex polygon; and Whether the ray intersects the convex polygon is determined based on the parameters determined for the edge of the convex polygon. 2 . The method of claim 1 , wherein for each of two or more of the convex polygons, the ray is determined to intersect a point on an edge of the convex polygon.
3. The method of claim 1 or 2, wherein the determining the parameter indicating which side of the edge the ray passes comprises determining a signed parameter using a function that defines the positions of the two projected vertices of the edge; and Wherein the determining whether the ray intersects the convex polygon is based on the sign of the signed parameter determined for the edge of the convex polygon.
4. The method of claim 3, wherein the determining whether the ray intersects the convex polygon comprises: If the signed parameters determined for the edges of the convex polygon all have the same sign, determining that the ray intersects the convex polygon; and The ray is determined not to intersect the convex polygon if not: the signed parameters determined for the edges of the convex polygon all have the same sign.
5. The method of claim 3, wherein the determining whether the ray intersects the convex polygon comprises: determining that a signed parameter of any edge of the convex polygon having a zero magnitude has a particular sign; and Signed parameters determining the sides of the convex polygon having non-zero magnitudes have signs that are consistent with each other.
6. The method according to claim 3, wherein the function is the two projected vertices v defining the edge i and v j The 2D cross product of the position f(v i ,v j ), which is defined as f(v i ,v j )=p i q j -q i p j , where p i and q i is the projected vertex v i components along the corresponding axis of the pair of axes, and where p j and q j is the projected vertex v j The component along the corresponding axis of the pair of axes. 7 . The method of claim 6 , wherein the ray is determined to intersect a point on an edge if the 2D cross product of the positions of the two projected vertices defining the edge has a magnitude of zero.
8. The method according to claim 6 or 7, wherein the two projected vertices v defining the edge are arranged in an order defined by the ordering of the vertices in the ordered set of vertices defining the convex polygon. i and v j Provided to the 2D cross product f(v i ,v j ), and wherein the sign of the signed parameter of the edge is determined as: If it is determined that the ray does not intersect a point on the edge, the sign is the same as f(v i ,v j ) have the same sign, and If the ray is determined to intersect a point on the edge, the sign is The symbol, where according to the plane vertex sorting scheme, if the projected vertex v i At the projected vertex v j Before, v i <v j =1, and according to the plane vertex sorting scheme, if the projected vertex v j At the projected vertex v i Before, v i <v j =0.
9. The method according to claim 6 or 7, wherein the two projected vertices v defining the edge i and v j provided to the 2D cross product in an order defined by the plane vertex ordering scheme such that the 2D cross product is determined as f(max(v i ,v j ),min(v i ,v j )), where the sign of the signed parameter of the edge is determined to be the same as The signs are the same, According to the plane vertex sorting scheme, if the projection vertex v i At the projected vertex v j Before, v i <v j =1,max(v i ,v j )=v j And min(v i ,v j )=v i ,and According to the plane vertex sorting scheme, if the projection vertex v j At the projected vertex v i Before, v i <v j =0, max(v i ,v j )=v i and 10. A method according to claim 3, wherein if it is determined that the ray intersects a point on an edge of a convex polygon, the method further comprises performing an XOR operation using: (i) the sign of the signed parameter of the edge, and (ii) an indication of the perceived orientation of the convex polygon, wherein the determination of whether the ray intersects the convex polygon is based on the result of the XOR operation.
11. The method of claim 1 or 2, wherein the ordering of the vertices according to the planar vertex ordering scheme depends on a projection used to project the vertices of the convex polygon onto the pair of axes.
12. The method according to claim 1 or 2, wherein the plane vertex sorting scheme sorts the projected vertices such that: The corresponding axis of the pair of axes has a component p i and q i The first projection vertex v i The corresponding axis along the pair of axes has a component p j and q j The second projection vertex v j Before, the condition was p i <p j Or the condition is (p i =p j And q i j );and The corresponding axis of the pair of axes has a component p i and q i The first projection vertex v i The corresponding axis along the pair of axes has a component p j and q j The second projection vertex v j After that, the condition is p i >p j Or the condition is (p i =p j And q i >q j ).
13. The method according to claim 1 or 2, wherein the determining whether the light ray intersects the convex polygon comprises using the parameters determined for the edges of the convex polygon to determine whether the light ray passes inside the edges of the convex polygon, wherein if it is determined that the light ray passes inside all edges of the convex polygon, then it is determined that the light ray intersects the convex polygon, and wherein if it is determined that the light ray passes outside one or more of the edges of the convex polygon, then it is determined that the light ray does not intersect the convex polygon.
14. A method according to claim 1 or 2, wherein the light ray and the convex polygon are defined in 3D space using a spatial coordinate system, and wherein projecting the vertices of the convex polygon onto a pair of axes orthogonal to the light ray direction includes transforming the vertices of the convex polygon into a light ray coordinate system, wherein the light ray coordinate system has an origin at the origin of the light ray, and wherein the light ray coordinate system has three basis vectors, wherein a first basis vector of the basis vectors is aligned with the light ray direction; and wherein a second basis vector and a third basis vector of the basis vectors are respectively aligned with the pair of axes orthogonal to the light ray direction, wherein the second basis vector and the third basis vector: (i) are not parallel to each other, and (ii) have zero as a component when expressed in the spatial coordinate system. 15 . The method of claim 14 , wherein the second basis vector and the third basis vector of the light ray coordinate system have a value of ±1 as a component when expressed in the space coordinate system.
16. The method according to claim 14, wherein the component D in the spatial coordinate system is used x , D y and D z to define the light direction vector, and wherein the method further comprises, before transforming the vertices of the convex polygon into the light coordinate system, selectively permuting and / or inverting the x, y and z components of the light and the vertices defining the convex polygon, such that D z ≥D x ≥0 and D z ≥D y ≥0.
17. The method of claim 1 or 2, wherein the convex polygon is a triangle.
18. The method of claim 1 or 2, further comprising outputting an indication of a result of the determination of whether the ray intersects the convex polygon, wherein the output indication is used in the ray tracing system to render an image of a 3D scene.
19. The method according to claim 1 or 2 further includes, if it is determined that the ray intersects the convex polygon, determining an intersection distance and a barycentric coordinate of the intersection, wherein the intersection distance and the barycentric coordinate are used in the ray tracing system to render an image of a 3D scene.
20. An intersection test module for use in a ray tracing system, configured to perform intersection tests of rays relative to a plurality of convex polygons, wherein each of the convex polygons is defined by an ordered set of vertices representing a circular order, and wherein at least one vertex in the ordered set of vertices is a shared vertex for defining two or more of the convex polygons, the intersection test module comprising a box intersection test unit, a polygon intersection test unit, a ray rescaling unit, and an example transformation unit, wherein, The polygon intersection test unit is configured to perform the following operations: projecting the vertices of the convex polygon onto a pair of axes orthogonal to the direction of the light ray to obtain projected vertices, wherein an origin of the pair of axes corresponds to an origin of the light ray, and wherein an ordering of the projected vertices is defined by a planar vertex ordering scheme, the planar vertex ordering scheme defining a direction of each edge of the convex polygon, wherein the direction of each edge defined by the planar vertex ordering scheme is independent of the ordering of the vertices from the ordered set of vertices defining the convex polygon; For each of the convex polygons, do the following: for each edge of the convex polygon defined by two of the projected vertices, determining a parameter indicating which side of the edge the ray passes, wherein the intersection test module is configured to, if it is determined that the ray intersects a point on the edge, determine the parameter based on whether an edge direction defined by the planar vertex ordering scheme matches an edge direction inherited from the ordering of the vertices in the ordered set of vertices defining the convex polygon; and Whether the ray intersects the convex polygon is determined based on the parameters determined for the edge of the convex polygon.
21. A computer-readable storage medium having computer-readable code stored thereon, the computer-readable code being configured to cause the method according to any one of claims 1 to 19 to be executed when the code is run.
22. A computer-readable storage medium having an integrated circuit definition data set stored thereon, wherein the integrated circuit definition data set, when processed in an integrated circuit manufacturing system, configures the integrated circuit manufacturing system to manufacture the intersection test module of claim 20.
Citation Information
Patent Citations
Systems and methods for primitive intersection in ray tracing
CN102947865A
Watertight ray triangle intersection
CN110827389A