Voxel
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Macros Pages
Classes | Functions
trace.cl File Reference

Contains OpenCL code for raytracing a scene. More...

Go to the source code of this file.

Classes

struct  Node

Functions

uint MortonZOrder (uint2 coordinate, uint2 dimension)
 Maps 2D coordinates to Morton Z-order indices.
uint2 InverseMortonZOrder (uint index, uint2 dimension)
 Maps Morton Z-order indices to 2D coordinates.
float Project (__private float3 *pProjected, float3 const ray)
 Projects a ray onto the unit cube.
int TraceTexture (__private uint *const pColor, __private float *const pLambda, __read_only image3d_t image, uint index, __private float3 *const pRemaining, __private float3 *const pRemainingMaximum, int const origin)
void Trace (__global uint *const colorDestination, __global float *const depthDestination, float const spread, __global void const *const heap, __read_only image3d_t image, uint const root, float3 const pp, float3 const ray)
__kernel void TraceScreen (__global uint *const colors, __global float *const depths, uint2 const dimension, uint const colorsPitch, uint const depthsPitch, float2 const fieldOfView, float const spread, __global void const *const heap, __read_only image3d_t image, uint const root, float3 const xx, float3 const yy, float3 const zz, float3 const pp)

Detailed Description

Contains OpenCL code for raytracing a scene.

Definition in file trace.cl.

Function Documentation

uint2 InverseMortonZOrder ( uint  index,
uint2  dimension 
)

Maps Morton Z-order indices to 2D coordinates.

Parameters
[in]indexThe Morton Z-order index.
[in]dimensionDimensions of the region to which the coordinates belong.
Returns
The 2D coordinates.

This function will return the coordinates which should be considered by the "index"th thread, if it wants to work in Morton Z-order, over a buffer of the given size. In other words, this is an inverse Z-order mapping (and this function is the inverse of MortonZOrder). The dimension argument does not need to be a power of two.

See Also
MortonZOrder

Definition at line 103 of file trace.cl.

uint MortonZOrder ( uint2  coordinate,
uint2  dimension 
)

Maps 2D coordinates to Morton Z-order indices.

Parameters
[in]coordinateThe 2D coordinates.
[in]dimensionDimensions of the region to which the coordinates belong.
Returns
The Morton Z-order index.

Suppose that the coordinates represent positions in a buffer of the given dimensions. This function will return the (row-major) Morton Z-order index corresponding to these coordinates. The InverseMortonZOrder function will perform the reverse operation (i.e. it is the inverse of this function). The dimension argument does not need to be a power of two.

For example, if dimension.{x,y}={9,6}, then coordinates will map to indices as follows:

\[ \begin{array}{ccccccccc} 0 & 1 & 4 & 5 & 16 & 17 & 20 & 21 & 48 \\ 2 & 3 & 6 & 7 & 18 & 19 & 22 & 23 & 49 \\ 8 & 9 & 12 & 13 & 24 & 25 & 28 & 29 & 50 \\ 10 & 11 & 14 & 15 & 26 & 27 & 30 & 31 & 51 \\ 32 & 33 & 36 & 37 & 40 & 41 & 44 & 45 & 52 \\ 34 & 35 & 38 & 39 & 42 & 43 & 46 & 47 & 53 \end{array} \]

See Also
InverseMortonZOrder

Definition at line 57 of file trace.cl.

float Project ( __private float3 *  pProjected,
float3 const  ray 
)

Projects a ray onto the unit cube.

Parameters
[in,out]pProjectedOrigin of the ray on input, intersection with unit cube on output.
[in]rayDirection in which the ray propagates.
Returns
True if the ray intersects the unit cube, false otherwise.

If the ray never intersects with the unit cube $[0,1]^3$, then this function will return false. Otherwise it will store the first intersection point in *pProjected, and return true. If the origin of the ray is inside the cube, then *pProjected will not be changed, but the function will return true.

Definition at line 160 of file trace.cl.