Realtime Fractal Renderer Documentation
main.cl File Reference
#include "defines.cl"
#include "types.cl"
Include dependency graph for main.cl:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

__kernel void getSceneInformation (__global float3 *camera_up_axis, const uint array_capacity, __global uint *number_camera_positions, __global float4 *camera_positions_at_time, __global uint *number_camera_facing, __global float4 *camera_facing_at_time, __global bool *do_camera_loop, __global float *camera_speed, __global float2 *benchmark_start_stop_time)
 Kernel function used to pass scene information to the C++ interface. More...
 
float3 estimateSurfaceNormal (const float3 position, const float time)
 Calculates the surface normal for a any point in the scene. More...
 
float calculateSoftShadow (const float3 pointOnGeometry, const float time, const float3 lightPosition)
 Calculates soft shadows for a point on geometry in the scene. More...
 
float calculateHardShadow (const float3 pointOnGeometry, const float time, const float3 lightPosition)
 Calculates hard shadows for a point on geometry in the scene. More...
 
float3 reflect (float3 incident, float3 normal)
 
float3 trace (const Ray ray, const float time)
 Traces the path of a ray. More...
 
Ray getCameraRay (const float2 screen_coordinate, const float3 camera_position, const float3 camera_facing, const float aspect_ratio)
 Creates a ray for the specified position on the camera screen. More...
 
uchar3 convertColourTo8Bit (const float3 colour)
 Converts a colour range 0-1 to an integer colour with range 0-255. More...
 
 __attribute__ ((vec_type_hint(float3))) __kernel void calculatePixelColour(__global uchar *colours
 Main kernel function. Calculates the colour for a pixel with the specified coordinate position range 0-1. More...
 
 if (ID< width *height)
 

Variables

const uint width
 
const uint const uint height
 
const uint const uint const float time
 
const uint const uint const float const float3 camera_position
 
const uint const uint const float const float3 const float3 camera_facing
 

Function Documentation

◆ __attribute__()

__attribute__ ( (vec_type_hint(float3))  )

Main kernel function. Calculates the colour for a pixel with the specified coordinate position range 0-1.

Parameters
coloursOutput colour buffer RGBA ordering
widthImage width in pixels
heightImage height in pixels
timeScene time in seconds
camera_positionPosition of the camera in the scene
camera_facingFacing direction of the camera

◆ calculateHardShadow()

float calculateHardShadow ( const float3  pointOnGeometry,
const float  time,
const float3  lightPosition 
)

Calculates hard shadows for a point on geometry in the scene.

Parameters
pointOnGeometryPosition in world space
timeScene time in seconds
lightPositionPosition of the light in the scene
Returns
Shadow value between 0 and 1

Definition at line 124 of file main.cl.

◆ calculateSoftShadow()

float calculateSoftShadow ( const float3  pointOnGeometry,
const float  time,
const float3  lightPosition 
)

Calculates soft shadows for a point on geometry in the scene.

Parameters
pointOnGeometryPosition in world space
timeScene time in seconds
lightPositionPosition of the light in the scene
Returns
Shadow value between 0 and 1

Definition at line 82 of file main.cl.

◆ convertColourTo8Bit()

uchar3 convertColourTo8Bit ( const float3  colour)

Converts a colour range 0-1 to an integer colour with range 0-255.

Parameters
colourColour in range 0 to 1
Returns
An 8-bit colour value, range 0-255

Definition at line 352 of file main.cl.

◆ estimateSurfaceNormal()

float3 estimateSurfaceNormal ( const float3  position,
const float  time 
)

Calculates the surface normal for a any point in the scene.

Parameters
positionPosition in world space
timeScene time in seconds
Returns
Surface normal vector for the position on the geometry

Definition at line 62 of file main.cl.

◆ getCameraRay()

Ray getCameraRay ( const float2  screen_coordinate,
const float3  camera_position,
const float3  camera_facing,
const float  aspect_ratio 
)

Creates a ray for the specified position on the camera screen.

Parameters
screen_coordinatePosition on the screen, range 0-1 for x and y
camera_positionCamera position in world units
camera_facingCamera normalised facing direction
aspect_ratioAspect ratio of the camera
Returns
A Ray

Definition at line 324 of file main.cl.

◆ getSceneInformation()

__kernel void getSceneInformation ( __global float3 *  camera_up_axis,
const uint  array_capacity,
__global uint *  number_camera_positions,
__global float4 *  camera_positions_at_time,
__global uint *  number_camera_facing,
__global float4 *  camera_facing_at_time,
__global bool *  do_camera_loop,
__global float *  camera_speed,
__global float2 *  benchmark_start_stop_time 
)

Kernel function used to pass scene information to the C++ interface.

Parameters
camera_up_axisUp direction for the camera
array_capacityMax allowed array capacity
number_camera_positionsNumber of values in the camera positions array
camera_positions_at_timeCamera positions array
number_camera_facingNumber of values in the camera facing directions array
camera_facing_at_timeCamera facing directions array
do_camera_loopWhether the camera should loop back to the start of the camera path once it finishes
camera_speedSpeed of the camera when manually controlling the camera
benchmark_start_stop_timeStart and stop times when benchmarking

Definition at line 21 of file main.cl.

◆ if()

if ( )

Definition at line 374 of file main.cl.

◆ reflect()

float3 reflect ( float3  incident,
float3  normal 
)

Definition at line 150 of file main.cl.

◆ trace()

float3 trace ( const Ray  ray,
const float  time 
)

Traces the path of a ray.

Parameters
rayA ray
timeScene time in seconds
Returns
The colour that the pixel should be drawn as (range 0-1)

Definition at line 161 of file main.cl.

Variable Documentation

◆ camera_facing

const uint const uint const float const float3 const float3 camera_facing
Initial value:
{
const int ID = get_global_id(0)

Definition at line 368 of file main.cl.

◆ camera_position

const uint const uint const float const float3 camera_position

Definition at line 368 of file main.cl.

◆ height

const uint const uint height

Definition at line 368 of file main.cl.

◆ time

const uint const uint const float time

Definition at line 368 of file main.cl.

◆ width

const uint width

Definition at line 368 of file main.cl.