Realtime Fractal Renderer Documentation
sphere_box.cl
Go to the documentation of this file.
1#define CAMERA_POSITIONS_LENGTH 1
2#define CAMERA_POSITIONS_ARRAY { (float4)(10, -10, -10, 0) }
3
4#define CAMERA_FACING_DIRECTIONS_LENGTH 1
5#define CAMERA_FACING_DIRECTIONS_ARRAY { (float4)(normalise((float3)(-10, -10, -10)), 0.0f) }
6
7#define SCENE_BACKGROUND_COLOUR (float3)(0.78f, 0.78f, 0.73f)
8
9#define SURFACE_INTERSECTION_EPSILON 0.00001f
10#define MAXIMUM_MARCH_STEPS 200
11#define MAXIMUM_MARCH_DISTANCE 50.0f
12
13//#define DO_SOFT_SHADOWS true
14#define DO_HARD_SHADOWS true
15
16#include "types.cl"
17#include "sdf.cl"
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)(25, -25, 25);
26
27 return light;
28}
29
30Material getMaterial(float3 position, float time)
31{
32 // Material
33 Material material;
34 material.ambient = (float3)(0.92f, 0.30f, 0.16f);
35 material.diffuse = material.ambient;
36 material.specular = (float3)(0.5f, 0.5f, 0.5f);
37 material.shininess = 25.0f;
38
39 return material;
40}
41
42float DE(float3 position, float time)
43{
44 float offset = -sin(time * 0.5f) * 1.0f;
45
46 float distance = opSmoothUnion(
47 sphereSDF(position, (float3)(0.0f, offset, 0.0f), 3.5f),
48 boxSDF(position, (float3)(0.0f, offset, 0.0f), (float3)(4.0f, 0.5f, 4.0f)),
49 (-sin(time * 0.5f) + 1.0f) * 1.5f
50 );
51
52 return distance;
53}
54
55#include "main.cl"
const uint const uint const float time
Definition: main.cl:368
Light getLight(float time)
Definition: sphere_box.cl:19
Material getMaterial(float3 position, float time)
Definition: sphere_box.cl:30
float DE(float3 position, float time)
Definition: sphere_box.cl:42
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