Realtime Fractal Renderer Documentation
infinite_spheres.cl
Go to the documentation of this file.
1
#ifndef BENCHMARK
2
3
#define CAMERA_POSITIONS_LENGTH 1
4
#define CAMERA_POSITIONS_ARRAY { (float4)(0, 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
#define CAMERA_SPEED 10.0f
9
10
#endif
11
12
#define MAXIMUM_MARCH_STEPS 200
13
#define MAXIMUM_MARCH_DISTANCE 1000.0f
14
#define SCENE_BACKGROUND_COLOUR (float3)(0.1f, 0.1f, 0.1f)
15
#define CAMERA_FOCUS_DISTANCE 0.1f
16
#define SCENE_GLOW_COLOUR (float3)(0.8f, 0.8f, 0.8f)
17
#define SCENE_MAX_GLOW_DISTANCE 1.05f
18
19
#define SCALE 0.05f
20
#define TIME_SCALE 0.33f
21
#define REPETITION (float3)(10.0f, 10.0f, 10.0f)
22
#define REPETITION_HALF REPETITION / 2
23
24
25
#include "
simplexnoise1234.cl
"
26
27
#include "
types.cl
"
28
#include "
sdf.cl
"
29
30
31
Light
getLight
(
float
time
)
32
{
33
Light
light;
34
light.
ambient
= (float3)(0.2f, 0.2f, 0.2f);
35
light.
diffuse
= (float3)(0.5f, 0.5f, 0.5f);
36
light.
specular
= (float3)(1.0f, 1.0f, 1.0f);
37
light.
position
= (float3)(500, 500, 500);
38
return
light;
39
}
40
41
Material
getMaterial
(float3 position,
float
time
)
42
{
43
// Calculate a point to sample the noise from, based on position and time
44
const
float3 samplePoint = position *
SCALE
+
time
*
TIME_SCALE
;
45
// Calculate colour, range -1 to 1 for x, y, and z
46
float3 colour = (float3)(
snoise1
(samplePoint.x) + 1,
snoise1
(samplePoint.y) + 1,
snoise1
(samplePoint.z) + 1);
47
48
// Material
49
Material
material;
50
// Divide colour by 2 so that it is in the range 0 to 1
51
material.
ambient
= colour / 2.0f;
52
material.
diffuse
= material.
ambient
;
53
material.
specular
= (float3)(0.5f, 0.5f, 0.5f);
54
material.
shininess
= 25.0f;
55
return
material;
56
}
57
58
float
DE
(float3 position,
float
time
)
59
{
60
// Transform the position in space
61
const
float3 transformed_position = fmod(position +
REPETITION_HALF
,
REPETITION
) -
REPETITION_HALF
;
62
// Calculate the distance to the transformed sphere
63
return
sphereSDF(transformed_position, (float3)(0, 0, 0), 1.0f);
64
}
65
66
#include "
main.cl
"
SCALE
#define SCALE
Definition:
infinite_spheres.cl:19
getLight
Light getLight(float time)
Definition:
infinite_spheres.cl:31
TIME_SCALE
#define TIME_SCALE
Definition:
infinite_spheres.cl:20
getMaterial
Material getMaterial(float3 position, float time)
Definition:
infinite_spheres.cl:41
DE
float DE(float3 position, float time)
Definition:
infinite_spheres.cl:58
REPETITION
#define REPETITION
Definition:
infinite_spheres.cl:21
REPETITION_HALF
#define REPETITION_HALF
Definition:
infinite_spheres.cl:22
main.cl
time
const uint const uint const float time
Definition:
main.cl:368
sdf.cl
simplexnoise1234.cl
snoise1
float snoise1(float x)
Definition:
simplexnoise1234.cl:141
Light
A struct representing a light, for use with the phong illumination model.
Definition:
types.cl:32
Light::ambient
float3 ambient
Definition:
types.cl:34
Light::position
float3 position
Definition:
types.cl:33
Light::diffuse
float3 diffuse
Definition:
types.cl:35
Light::specular
float3 specular
Definition:
types.cl:36
Material
A struct representing a geometry material, for use with the Phong reflection model.
Definition:
types.cl:20
Material::ambient
float3 ambient
Definition:
types.cl:21
Material::diffuse
float3 diffuse
Definition:
types.cl:22
Material::shininess
float shininess
Definition:
types.cl:24
Material::specular
float3 specular
Definition:
types.cl:23
types.cl
FractalGeometryRenderer
kernels
infinite_spheres.cl
Generated by
1.9.3