Split scene definition to use it in both raytracer and rasteriser

This commit is contained in:
2024-06-22 16:46:55 +01:00
parent fbe4513a14
commit 8fc3a2577a
5 changed files with 117 additions and 98 deletions

69
src/scene/scene.c Normal file
View File

@@ -0,0 +1,69 @@
#include "scene/scene.h"
#include "c_cpp_aliases/aliases.h"
#define ARR_LEN(ARR) sizeof(ARR) / sizeof(ARR[0])
internal const sphere_t spheres[] = {
(sphere_t){
.radius = 1.0f,
.centre = (vec3f_t){.x = 0.0f, .y = -1.0f, .z = 3.0f},
.colour =
(colour_t){
.rgba.r = 245, .rgba.g = 238, .rgba.b = 158, .rgba.a = 255},
.specular = 500.0f,
.reflective = 0.3f,
},
(sphere_t){
.radius = 1.0f,
.centre = (vec3f_t){.x = -2.0f, .y = 0.0f, .z = 4.0f},
.colour =
(colour_t){
.rgba.r = 59, .rgba.g = 142, .rgba.b = 165, .rgba.a = 255},
.specular = 10.0f,
.reflective = 0.1f,
},
(sphere_t){
.radius = 1.0f,
.centre = (vec3f_t){.x = 2.0f, .y = 0.0f, .z = 4.0f},
.colour =
(colour_t){
.rgba.r = 171, .rgba.g = 52, .rgba.b = 40, .rgba.a = 255},
.specular = 500.0f,
.reflective = 0.4f,
},
(sphere_t){
.radius = 5000.0f,
.centre = (vec3f_t){.x = 0.0f, .y = -5001.0f, .z = 0.0f},
.colour =
(colour_t){
.rgba.r = 255, .rgba.g = 255, .rgba.b = 0, .rgba.a = 255},
.specular = 1000.0f,
.reflective = 0.5f,
},
};
internal const light_t lights[] = {
(light_t){
.type = LIGHT_TYPE_AMBIENT,
.intensity = 0.2f,
},
(light_t){
.type = LIGHT_TYPE_POINT,
.intensity = 0.6f,
.position = (vec3f_t){.x = 2.0f, .y = 1.0f, .z = 0.0f},
},
(light_t){
.type = LIGHT_TYPE_DIRECTIONAL,
.intensity = 0.2f,
.direction = (vec3f_t){.x = 1.0f, .y = 4.0f, .z = 4.0f},
},
};
internal scene_t scene = (scene_t){
.spheres = spheres,
.lights = lights,
.spheres_count = ARR_LEN(spheres),
.lights_count = ARR_LEN(lights),
};
const scene_t *build_test_scene(void) { return &scene; }