5#define CAMERA_POSITIONS_LENGTH 1
6#define CAMERA_POSITIONS_ARRAY { (float4)(5, 0, 0, 0) }
8#define CAMERA_FACING_DIRECTIONS_LENGTH 1
9#define CAMERA_FACING_DIRECTIONS_ARRAY { (float4)(normalise((float3)(-1, 0, 0)), 0) }
11#define CAMERA_SPEED 2.5f
13#define SCENE_BACKGROUND_COLOUR (float3)(0.3f, 0.3f, 0.3f)
14#define DO_SOFT_SHADOWS true
16#define MAXIMUM_MARCH_STEPS 256
17#define MAXIMUM_MARCH_DISTANCE 15.0f
18#define SURFACE_INTERSECTION_EPSILON 0.0001f
20#define DO_RENDER_SURFACE_NORMALS false
21#define DO_RENDER_MARCHING_ITERATIONS false
22#define DISPLAY_BOUNDING_VOLUME false
27 light.
ambient = (float3)(0.1f, 0.1f, 0.1f);
28 light.
diffuse = (float3)(0.6f, 0.6f, 0.6f);
29 light.
specular = (float3)(1.0f, 1.0f, 1.0f);
30 light.
position = (float3)(5.0f, -5.0f, 5.0f);
35float len(
const float2 vec)
37 return sqrt(vec.x * vec.x + vec.y * vec.y);
53 float3 q = p + (float3)(1.0f - cos((1.0f - p.y) / 3.0f * PI), 0.0f, 0.0f);
54 float y = pow(sin((1. - p.y) / 3. * PI / 2.), 2.);
56 float tube_hollow = max(max(f_abs(
len((float2)(q.x, q.z)) - 0.5f + 0.25f * y) - t, q.y - 1.0f), -q.y - 2.0f);
57 float tube_solid = max(max(
len((float2)(q.x, q.z)) - 0.5f + 0.25f * y, q.y - 1.0f), -q.y - 2.0f);
60 q = p - (float3)(0.0f, 1.0f, 0.0f);
61 d = min(d, max(f_abs(
len((float2)(
len((float2)(q.x, q.z)) - 1.0f, q.y)) - 0.5f) - t, -q.y));
65 d = min(d, max(max(max(f_abs(
len((float2)(q.x, q.z)) - 1.5f + 1.25f * y), q.y - 1.0f), -q.y - 2.0f) - t, -tube_solid));
68 d = min(d, tube_hollow);
71 q = p + (float3)(1.0f, 2.0f, 0.0f);
72 d = min(d, max(f_abs(
len((float2)(
len((float2)(q.x, q.y)) - 1.0f, q.z)) - 0.25f) - t, q.y));
79 float time_scaled =
time * 0.5f;
80 material.
ambient = ((float3)(sin(time_scaled), sin(time_scaled + 0.666f), sin(time_scaled + 1.333f)) + 1) / 2.0f;
82 material.
specular = (float3)(0.5f, 0.5f, 0.5f);
91 return SDF(position,
time, &distance);
Light getLight(float time)
Material SDF(const float3 position, const float time, float *distance)
Material getMaterial(float3 position, float time)
float DE(float3 position, float time)
float len(const float2 vec)
const uint const uint const float time
A struct representing a light, for use with the phong illumination model.
A struct representing a geometry material, for use with the Phong reflection model.