Realtime Fractal Renderer Documentation
sierpinski_collection.cl
Go to the documentation of this file.
1#ifndef BENCHMARK
2
3#define CAMERA_POSITIONS_LENGTH 1
4#define CAMERA_POSITIONS_ARRAY { (float4)(10, 0, 0, 0)}
5#define CAMERA_FACING_DIRECTIONS_LENGTH 1
6#define CAMERA_FACING_DIRECTIONS_ARRAY { (float4)(normalise((float3)(1, 0, 0)), 0) }
7#define FORCE_FREE_CAMERA true
8
9//#define DO_BOUNDING_VOLUME_OPTIMISATION true
10//#define DO_SOFT_SHADOWS true
11//#define DO_HARD_SHADOWS true
12
13//#define DO_GEOMETRY_GLOW true
14
15#endif
16
17#define MAXIMUM_MARCH_STEPS 300
18#define MAXIMUM_MARCH_DISTANCE 100.0f
19#define SURFACE_INTERSECTION_EPSILON 0.0001f
20#define CAMERA_SPEED 1.0f
21#define SCENE_BACKGROUND_COLOUR (float3)(1.0f, 0.5f, 0.3f)
22#define SCENE_GLOW_COLOUR (float3)(0.8f, 0.8f, 0.8f)
23#define SCENE_MAX_GLOW_DISTANCE 0.1f
24#define CAMERA_FOCUS_DISTANCE 0.1f
25#define SURFACE_SHADOW_FALLOFF 5.0f
26
27#include "types.cl"
28#include "sdf.cl"
29#include "sierpinski.cl"
30
32{
33 Light light;
34 light.ambient = (float3)(0.1f, 0.1f, 0.1f);
35 light.diffuse = (float3)(0.5f, 0.5f, 0.5f);
36 light.specular = (float3)(1.0f, 1.0f, 1.0f);
37 light.position = (float3)(5, -5, 5);
38
39 return light;
40}
41
42Material SDF(const float3 position, const float time, float* distance)
43{
44 float cubeDistance = 0.0f;
45 float tetrahedronDistance = 0.0f;
46
47 Material cube = sierpinskiCubeSDF((float3)(1, 1, 1) - position, 7, &cubeDistance);
48 Material tetrahedron = sierpinskiTetrahedronSDF((float3)(-5, 0, 0) - position, 12, 100000000, &tetrahedronDistance);
49
50 if (cubeDistance < tetrahedronDistance)
51 {
52 *distance = cubeDistance;
53 return cube;
54 }
55 else
56 {
57 *distance = tetrahedronDistance;
58 return tetrahedron;
59 }
60}
61
62Material getMaterial(float3 position, float time)
63{
64 float distance;
65 return SDF(position, time, &distance);
66}
67
68float boundingVolumeDE(float3 position, float time)
69{
70 return min(boxSDF(position, (float3)(0, 0, 0), 1.0f), sphereSDF(position, (float3)(-5, 0, 0), 1.75f));
71}
72
73float DE(float3 position, float time)
74{
75 float distance;
76 SDF(position, time, &distance);
77 return distance;
78}
79
80#include "main.cl"
const uint const uint const float time
Definition: main.cl:368
Light getLight(float time)
Material SDF(const float3 position, const float time, float *distance)
Material getMaterial(float3 position, float time)
float boundingVolumeDE(float3 position, float time)
float DE(float3 position, float time)
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