Realtime Fractal Renderer Documentation
hello_world.cl
Go to the documentation of this file.
1#include "utils.cl"
2#include "types.cl"
3#include "sdf.cl"
4
5#define CAMERA_POSITIONS_LENGTH 1
6#define CAMERA_POSITIONS_ARRAY { (float4)(5, 0, 0, 0) }
7
8#define CAMERA_FACING_DIRECTIONS_LENGTH 1
9#define CAMERA_FACING_DIRECTIONS_ARRAY { (float4)(normalise((float3)(-1, 0, 0)), 0) }
10
11#define CAMERA_SPEED 2.5f
12
13#define SCENE_BACKGROUND_COLOUR (float3)(0.1f, 0.1f, 0.1f)
14#define DO_SOFT_SHADOWS true
15
16#define MAXIMUM_MARCH_STEPS 100
17#define MAXIMUM_MARCH_DISTANCE 50.0f
18
20{
21 Light light;
22 light.ambient = (float3)(0.2f, 0.2f, 0.2f);
23 light.diffuse = (float3)(0.5f, 0.5f, 0.5f);
24 light.specular = (float3)(1.0f, 1.0f, 1.0f);
25 light.position = (float3)(0.0, -4, -4);
26
27 return light;
28}
29
30Material SDF(const float3 position, const float time, float* distance)
31{
32 // Distance estimation
33 *distance = sphereSDF(position, (float3)(0, 0, 0), 1.0f);
34
35 // Material
36 Material material;
37 material.ambient = (float3)(0.75f, 0.25f, 0.5f);
38 material.diffuse = material.ambient;
39 material.specular = (float3)(0.5f, 0.5f, 0.5f);
40 material.shininess = 25.0f;
41
42 return material;
43}
44
45Material getMaterial(float3 position, float time)
46{
47 float distance;
48 return SDF(position, time, &distance);
49}
50
51float DE(float3 position, float time)
52{
53 float distance;
54 SDF(position, time, &distance);
55 return distance;
56}
57
58#include "main.cl"
Light getLight(float time)
Definition: hello_world.cl:19
Material SDF(const float3 position, const float time, float *distance)
Definition: hello_world.cl:30
Material getMaterial(float3 position, float time)
Definition: hello_world.cl:45
float DE(float3 position, float time)
Definition: hello_world.cl:51
const uint const uint const float time
Definition: main.cl:368
A struct representing a light, for use with the phong illumination model.
Definition: types.cl:32
float3 ambient
Definition: types.cl:34
float3 position
Definition: types.cl:33
float3 diffuse
Definition: types.cl:35
float3 specular
Definition: types.cl:36
A struct representing a geometry material, for use with the Phong reflection model.
Definition: types.cl:20
float3 ambient
Definition: types.cl:21
float3 diffuse
Definition: types.cl:22
float shininess
Definition: types.cl:24
float3 specular
Definition: types.cl:23