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) |
uint2 InverseMortonZOrder | ( | uint | index, |
uint2 | dimension | ||
) |
Maps Morton Z-order indices to 2D coordinates.
[in] | index | The Morton Z-order index. |
[in] | dimension | Dimensions of the region to which the coordinates belong. |
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.
uint MortonZOrder | ( | uint2 | coordinate, |
uint2 | dimension | ||
) |
Maps 2D coordinates to Morton Z-order indices.
[in] | coordinate | The 2D coordinates. |
[in] | dimension | Dimensions of the region to which the coordinates belong. |
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:
float Project | ( | __private float3 * | pProjected, |
float3 const | ray | ||
) |
Projects a ray onto the unit cube.
[in,out] | pProjected | Origin of the ray on input, intersection with unit cube on output. |
[in] | ray | Direction in which the ray propagates. |
If the ray never intersects with the unit cube , 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.