# Patent

## Title
Five-dimensional rasterization with conservative bounds

## Abstract

A per-tile test in the 5D rasterizer outputs intervals for both lens parameters, (u,v), and for time, t, as well as for depth z. These intervals are conservative bounds for the current tile for 1) the visible lens region, 2) the time the triangle overlaps the tile, and 3) the depth range for the triangle inside the tile.

## Background
BACKGROUND
This relates to graphics processing and particularly to the graphical depiction of motion blur.
Motion blur is an important visual effect that reduces temporal aliasing and makes moving content appear smoother. However, efficient rendering of motion blur in real-time three-dimensional graphics is nontrivial. In stochastic rasterization of motion blur, moving geometric primitives are sampled in both space and time, using a large set of samples to obtain high-quality motion-blurred images with low noise levels. For each of the sample positions, an inside test is executed to determine whether the moving primitive covers the sample. This overlap test in x, y and t space is generally more expensive than an inside test in traditional rasterizers.
A stochastic rasterizer that supports simultaneous motion blur and depth of field executes visibility tests for each triangle in a five dimensional (5D) domain (x,y,u,v,t). This domain consists of spatial positions (x,y), lens coordinates (u,v) and time t. These visibility tests are computationally much more expensive than a single visibility test in standard 2D rasterization. Additionally, for each triangle, many (e.g. 16-64) such tests are executed per pixel to obtain images with low noise levels.
Five-dimensional (5D) rasterization is expected to become part of DirectX and OpenGL at some point in the future. This will enable us to render images with accurate and correct depth of field and motion blur.



BRIEF DESCRIPTION OF THE DRAWINGS
Some embodiments are described with respect to the following figures:
FIG. 1 is a screen shot from an interactive visualizer according to one embodiment;
FIG. 2 is a depiction of the construction of a moving axis-aligned bounding box according to one embodiment;
FIG. 3 is a flow chart for one embodiment; and
FIG. 4 is a schematic depiction for one embodiment.



DETAILED DESCRIPTION
A per-tile test in the 5D rasterizer outputs intervals for both lens parameters, (u,v), and for time, t, as well as for depth z. These intervals are conservative bounds for the current tile for 1) the visible lens region, 2) the time the triangle overlaps the tile, and 3) the depth range for the triangle inside the tile.
This output can be sent (when needed) further down the graphics pipeline to the pixel shader, and used for various things by the application developer. The interesting thing is that this results in a conservative 5D rasterizer. Previously, we have only had access to conservative 2D rasterization. This invention extends this to a whole new domain and, as a starting point, we have discovered that conservative 5D rasterization with such outputs can be used for dynamic collision detection and caustics rendering on the graphics processor. Dynamic collision detection on the graphics processor has not been done before, as far as we know, and the caustics rendering solution that we have thought of will be more efficient than previous methods.
In addition, we present a new way to compute a conservative depth interval over a moving triangle. This makes occlusion culling more efficient, and saves both computer resources, as well as memory bandwidth usage in some embodiments.
We present a method for computing conservative depth over a motion blurred triangle over a tile of pixels. This is useful for occlusion culling (zmin/zmax-culling) and conservative rasterization, as well as a number of other techniques, such as dynamic collision detection on the graphics processor, and caustics rendering.
Usually, a moving vertex is described by pi=(1−t)qi+tri, t ε [0,1], and a moving triangle is described by p0p1p2. Hence, we have a triangle q0q1q2 at t=0 and r0r1r2 at t=1.
We assume that points, e.g., p, are two-dimensional homogeneous coordinates, i.e., p=(px,py,pw). We derive conservative depth in terms of the w-coordinate. Later, we show how the desired normalized depth, z/w, can be computed only from knowing the value of w, when standard projection matrices of OpenGL and DirectX are used.
We will present two ways to compute conservative depth over a tile (e.g., a block of pixels). The power of these two methods may be combined, resulting in a tighter conservative depth in some embodiments.
A plane equation is computed through the triangle at time t=0 (t=1). That plane is moved with constant speed as a function of time, such that it always has the moving triangle on one side of the plane. In the following, we will describe how we compute a moving plane equation which has larger depth than the moving triangle. Hence, this is useful for computing maximum depth (wmaxtri). Similar techniques can be used to compute minimum depth (wmintri).
First, we compute the static plane equation of the triangle at t=0. The plane normal is given by:

n0=(q2−q0)×(q1−q0).  (1)

To make sure we move the plane in the right direction, we negate n0 if n0w<0. The plane equation is then: πo: n0·o+d0, where d0=n0·q0, and o is an arbitrary point on the plane. Next, we compute the velocity v0.




  
    
      
        
          
            v
            0
          
          =
          
            -
            
              
                max
                i
              
              ⁢
              
                (
                
                  
                    
                      n
                      0
                    
                    ·
                    
                      r
                      i
                    
                  
                  +
                  
                    d
                    0
                  
                
                )
              
            
          
        
        ,
        
          

        
        ⁢
        
          i
          ∈
          
            {
            
              0
              ,
              1
              ,
              2
            
            }
          
        
        ,
      
    
    
      
        (
        2
        )
      
    
  




which is the maximum signed distance from the plane, π0, over the vertices of the moving triangle at t=1. At this point, we have created a moving plane equation, which moves in the direction of the plane normal:

Π0(t):n0·o+d0+v0t=0.  (3)

As can be seen, we have added the term v0t, which ensures (by construction) that the triangle is “below” the moving plane equation, Π0(t). If Π0(t) does not sweep through the camera origin, e.g.

d0+v0t≠0•tε[0,1],  (4)

then Π0(t) has greater depth than the moving triangle at all times, t ε [0,1]. Any ray from the camera that intersects the triangle will intersect the triangle before intersecting the plane.

Sometimes, the plane equation of the triangle at t=1 provides a better plane equation to work with. In fact, in most cases, the triangle plane at t=0 is better in the beginning, and towards the end of the time interval, the triangle plane at t=1 is better. Hence, we want to derive a way of using the plane equation at t=1 as well.
The plane normal at t=1 is:

n1=(r2−r0)×(r1−r0).  (5)

Again, we negate n1 if n1w<0. To make sure that the triangle at t=0 is on the right side of the new plane equation (with n1 as normal), we need to compute the dot products between the normal, n1, and the vertices of the triangle at t=0 in order to compute d1:





  
    
      
        
          
            d
            1
          
          =
          
            
              min
              i
            
            ⁢
            
              (
              
                
                  -
                  
                    n
                    1
                  
                
                ·
                
                  q
                  i
                
              
              )
            
          
        
        ,
        
          

        
        ⁢
        
          i
          ∈
          
            
              {
              
                0
                ,
                1
                ,
                2
              
              }
            
            .
          
        
      
    
    
      
        (
        6
        )
      
    
  




The plane equation is then: π1:n1·o+d1. The velocity, v1, of the moving plane is computed in the same way as above:




  
    
      
        
          
            v
            1
          
          =
          
            -
            
              
                max
                i
              
              ⁢
              
                (
                
                  
                    
                      n
                      1
                    
                    ·
                    
                      r
                      i
                    
                  
                  +
                  
                    d
                    1
                  
                
                )
              
            
          
        
        ,
        
          

        
        ⁢
        
          i
          ∈
          
            
              {
              
                0
                ,
                1
                ,
                2
              
              }
            
            .
          
        
      
    
    
      
        (
        7
        )
      
    
  




The moving plane equation becomes:

Π1(t):n1·o+d1+v1t=0.  (8)

Again, we also test for overlap between Π1(t) and the camera origin d1+v1t≠0 ∀t ε [0,1] to ensure that the plane is a conservative approximation of wmaxtri.
At this point, we have two plane equations, Π0 and Π1, which move at constant velocities, and the next step is to evaluate the depth of these moving plane equations over a tile. The depth at a tile corner, (x, y), is computed as:




  
    
      
        
          
            w
            i
          
          ⁡
          
            (
            
              x
              ,
              y
              ,
              t
            
            )
          
        
        =
        
          -
          
            
              
                
                  d
                  i
                
                +
                
                  
                    v
                    i
                  
                  ⁢
                  t
                
              
              
                
                  n
                  i
                
                ·
                
                  (
                  
                    x
                    ,
                    y
                    ,
                    1
                  
                  )
                
              
            
            .
          
        
      
    
    
      
        (
        9
        )
      
    
  




Note that when the denominator becomes zero, the plane of the triangle goes through the view point, and we simply do not use such planes when computing conservative depth.

The correct way to compute conservative maximum depth over a tile with four corners is then to take the maximum depth of eight locations, (x, y, t), namely, each of the four tile corners, but also both at time t=0 and t=1. However, since the equation was designed to be efficient to evaluate, it suffices to evaluate the depth at one location. This is described next. If vi>0, we only need to evaluate depth at t=1, and vice versa. The sign of the x- and y-components of the normal is used to select one corner out of the remaining four. For example, if nx>0 and ny<0, we would pick the one of the left corners of the tile (since nx>0), and out of those two, we would select the topmost corner (since ny<0). This makes it all very efficient.
For each moving plane, Π0 and Π1, we generate one maximum depth-value, say, w0Π and w1Π, using the technique described above. The tightest wmaxtri depth over the tile is then selected as the minimum of these:

wmaxΠ=min(w0Π,w1Π).  (10)

and similar computations are done to calculate wminΠ.

Note that we can use a further optimization if we use a rasterizer that visits tiles and computes time intervals {circumflex over (t)}=[t,t], indicating that there is the possibility that the tile overlaps with the moving triangle. Instead of evaluating Π0 and Π1 at t=0 and t=1 as described above, we evaluate at t=t and t=t.
In FIG. 1, we have interpolated the triangle to t=0.5, which is located in the middle between t=0 and t=1. The grids A and B show the two planes, Π0 and Π1 at t=0.5. In this case, both lie above the interpolated triangle. The axis C is the w-axis.
As seen in FIG. 2, we construct a moving axis-aligned bounding box (AABB) for the triangle by interpolating its AABB's between times t=0 and t=1. For the closest and farthest quadrilateral faces of the AABB, we compute the intersection times {circumflex over (t)}i=[t,t] with the planes πi of the tile frustum. The tile frustum planes pass through the origin and are aligned to the sides of the tile.
Given a moving vertex of the farthest quadrilateral face, pn=(1−t)qn+trn, the times at which the AABB's intersect with the tile frustum planes ni·pn=0, are given by:




  
    
      
        t
        =
        
          
            
              
                n
                i
              
              ·
              
                q
                n
              
            
            
              
                n
                i
              
              ·
              
                (
                
                  
                    q
                    n
                  
                  -
                  
                    r
                    n
                  
                
                )
              
            
          
          .
        
      
    
    
      
        (
        11
        )
      
    
  




Of the four moving vertices of a quadrilateral face, we select the one that is farthest from πi in the negative direction.

Subsequently, wmax is calculated for [t,t] as (shown here for t):

wmax=(1−t)wmaxt=0+twmaxt=1  (12)

and similarly for wmax. Then, the final maximum value using this technique is computed as:

wmax=max(wmax,wmax).  (13)

Analogous computations would be done to compute the minimum depth, and then wmin=min(wmin,wmin). Note that this procedure has to be performed for both the x and y tile directions.
An alternative is to calculate the times {circumflex over (t)}i=[t,t] when the moving AABB intersects the tile frustum planes using the n-vertices, and use these times to calculate w{mim,max} for t and t. These bounds on depth would however be slightly more conservative than when using the closest and farthest quadrilateral faces.
Up until now, our formulae have computed depth in w, but for OpenGL and DirectX, we usually need the normalized depth: z/w. Given a point, p, in eye space, we can apply standard projection matrices from DirectX. The z and w after projection are expressed as:

z=apz+bpw=apz+b  (14)

w=pz,

where





  a
  =
  
    
      Z
      far
    
    
      
        Z
        far
      
      -
      
        Z
        near
      
    
  




and b=−aZnear, a, b>0. In all our derivations, we have computed w (=pz), and as a consequence, we can compute z=aw+b. This in turns means that, given w, we can compute the desired normalized depth, z/w, as z/w=(aw+b)/w.

Note that w(t) and




  
    
      z
      ⁡
      
        (
        t
        )
      
    
    
      w
      ⁡
      
        (
        t
        )
      
    
  
  =
  
    a
    +
    
      b
      
        w
        ⁡
        
          (
          t
          )
        
      
    
  




have local minima at the same t only if w(t)≠0 ∀t ε [0,1], as





  a
  +
  
    b
    
      w
      ⁡
      
        (
        t
        )
      
    
  




with b>0 is strictly increasing as a function of w for w≠0.

If we compute a maximum normalized depth, ZmaxI=zmaxI/wmaxI, using one technique (e.g., using Equation (11)), and another maximum normalized depth, ZmaxII=zmaxII/wmaxII (e.g., using Equation (14)), then we can compute the combined “best” depth as the minimum of the two:

Zmaxbest=min(ZmaxI,ZmaxII),  (15)

and vice versa for Zminbest. This applies to any number of argument to the min-function as long as the parameters represent conservative depths.

This work may be extended to depth of field. Equation (9) can suddenly become zero for many more cases due to that we now have a lens with finite extents to handle. Detecting whether a triangle plane intersects with a convex polygonal lens can be done by computing signed distances from the lens vertices to the plane equation. If there is at least one with positive and one with negative distance, then the plane intersects the lens, and we simply disable the usage of that plane. We can also use a bounding box around the lens shape and use the vertices of the bounding box for the computations described just above.
If the plane does not intersect the lens, we need to compute the depth through the tile corners. However, instead of starting the computations from the origin (where the pinhole camera is assumed to be located), we need to do this for all four corners of the bounding box of the lens shape.
Also, we can also use information from the tile-visiting rasterizer, {circumflex over (t)}, and use that to tighten the conservative depth further.
In accordance with some embodiments, a sequence 10 shown in FIG. 3 may be implemented in software, firmware and/or hardware. In software and firmware embodiments it may be implemented by computer executed instructions stored in a non-transitory computer readable medium such as optical, magnetic or semiconductor storage.
In one embodiment, the sequence of FIG. 3 begins with a triangle set-up stage 12. The per-triangle constants needed for bounding are computed. Next a tile test 14 is performed. In the tile test, u, v, t and z intervals are computed for each tile. A tile is rejected if it is outside the valid range in any of the intervals. Then the u, v and t intervals are used to reject individual samples as shown in block 16. Finally, in the pixel shader, block 18, the u, v, t and z intervals are made available for the pixel shader. This allows for new algorithms in the pixel shader such as caustics rendering and dynamic collision detection.
The computer system 130, shown in FIG. 4, may include a hard drive 134 and a removable medium 136, coupled by a bus 104 to a chipset core logic 110. The computer system may be any computer system, including a smart mobile device, such as a smart phone, tablet, or a mobile Internet device. A keyboard and mouse 120, or other conventional components, may be coupled to the chipset core logic via bus 108. The core logic may couple to the graphics processor 112, via a bus 105, and the central processor 100 in one embodiment. The graphics processor 112 may also be coupled by a bus 106 to a frame buffer 114. The frame buffer 114 may be coupled by a bus 107 to a display screen 118. In one embodiment, a graphics processor 112 may be a multi-threaded, multi-core parallel processor using single instruction multiple data (SIMD) architecture.
In the case of a software implementation, the pertinent code may be stored in any suitable semiconductor, magnetic, or optical memory, including the main memory 132 (as indicated at 139) or any available memory within the graphics processor. Thus, in one embodiment, the code to perform the sequences of FIG. 5 or 6 may be stored in a non-transitory machine or computer readable medium, such as the memory 132, and/or the graphics processor 112, and/or the central processor 100 and may be executed by the processor 100 and/or the graphics processor 112 in one embodiment.
FIG. 3 is a flow chart. In some embodiments, the sequences depicted in these flow charts may be implemented in hardware, software, or firmware. In a software embodiment, a non-transitory computer readable medium, such as a semiconductor memory, a magnetic memory, or an optical memory may be used to store instructions and may be executed by a processor to implement the sequences shown in FIG. 3.
The graphics processing techniques described herein may be implemented in various hardware architectures. For example, graphics functionality may be integrated within a chipset. Alternatively, a discrete graphics processor may be used. As still another embodiment, the graphics functions may be implemented by a general purpose processor, including a multicore processor.
References throughout this specification to “one embodiment” or “an embodiment” mean that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one implementation encompassed within the present invention. Thus, appearances of the phrase “one embodiment” or “in an embodiment” are not necessarily referring to the same embodiment. Furthermore, the particular features, structures, or characteristics may be instituted in other suitable forms other than the particular embodiment illustrated and all such forms may be encompassed within the claims of the present application.
While the present invention has been described with respect to a limited number of embodiments, those skilled in the art will appreciate numerous modifications and variations therefrom. It is intended that the appended claims cover all such modifications and variations as fall within the true spirit and scope of this present invention.

## Claims

1. A method comprising:
computing depth intervals, using a moving plane equation having a depth greater than that of a moving and defocused triangle, for a plurality of tiles for said moving and defocused triangle;
rejecting a tile if it is outside a valid range in a depth interval; and
rendering an image without said one or more rejected tiles determined from said computed depth intervals for a graphic processor to obtain high quality motion-blurred images.

2. The method of claim 1 including computing depth intervals valid for a time interval for said tiles.

3. The method of claim 1 including computing depth intervals valid within a region of lens coordinates for said tiles.

4. The method of claim 3 including rejecting a tile if it is outside said depth intervals.

5. The method of claim 4 including rejecting individual samples using said depth intervals.

6. The method of claim 5 including using said depth intervals for pixel shading.

7. The method of claim 1 including computing per triangle constants for bounding.

8. The method of claim 7 including using said constants for computing said depth intervals.

9. A non-transitory computer readable medium storing instructions to enable a processor to perform the steps of:
computing depth intervals, using a moving plane equation having a depth greater than that of a moving and defocused triangle, for a plurality of tiles for said moving and defocused triangle;
rejecting a tile if it is outside a valid range in a depth interval; and
rendering an image without said one or more rejected tiles determined from said computed depth intervals for a graphics processor to obtain high quality motion-blurred images.

10. The medium of claim 9 including computing depth intervals valid for a time interval for said tiles.

11. The medium of claim 9 including computing depth intervals valid within a region of lens coordinates for said tiles.

12. The medium of claim 11 including rejecting a tile if it is outside said depth intervals.

13. The medium of claim 12 including rejecting individual samples using said depth intervals.

14. The medium of claim 13 including using said depth intervals for pixel shading.

15. The medium of claim 9 including computing per triangle constants for bounding.

16. The medium of claim 15 including using said constants for computing said depth intervals.

17. An apparatus comprising:
a processor to compute depth intervals using a moving plane equation having a depth greater than that of a moving and defocused triangle for a plurality of tiles for said moving and defocused triangle, reject one or more tiles if the one or more tiles are outside a valid range in a depth interval and render an image without said one or more rejected tiles determined from said computed depth intervals for a graphics processor to obtain high quality motion-blurred images; and
a memory coupled to said processor.

18. The apparatus of claim 17, said processor to compute depth intervals valid for a time interval for said tiles.

19. The apparatus of claim 17, said processor to compute depth intervals valid within a region of lens coordinates for said tiles.

20. The apparatus of claim 19, said processor to reject a tile if it is outside said depth intervals.

21. The apparatus of claim 20, said processor to reject individual samples using said depth intervals.

22. The apparatus of claim 21, said processor to use said depth intervals for pixel shading.

23. The apparatus of claim 17, said processor to compute per triangle constants for bounding.

24. The apparatus of claim 23, said processor to use said constants for computing said depth intervals.

25. The apparatus of claim 17 wherein said processor is a graphics processing unit.