Move scene to raytracer

This commit is contained in:
2024-07-09 19:44:19 +01:00
parent 4430ea872c
commit c3e1aac779
6 changed files with 110 additions and 129 deletions

View File

@@ -2,7 +2,6 @@
#define RAYTRACER_H
#include "aliases.h"
#include "scene/scene.h"
#include "vector/vec.h"
#include "window/window.h"
@@ -11,13 +10,46 @@ typedef struct {
f32 t2;
} solutions_t;
typedef struct {
f32 radius;
vec3f_t centre;
colour_t colour;
f32 specular;
f32 reflective;
} sphere_t;
typedef struct {
f32 closest_t;
const sphere_t *closest_sphere;
} intersection_t;
typedef enum {
LIGHT_TYPE_POINT,
LIGHT_TYPE_DIRECTIONAL,
LIGHT_TYPE_AMBIENT,
COUNT_LIGHT_TYPE,
} light_type_t;
typedef struct {
light_type_t type;
f32 intensity;
union {
vec3f_t position;
vec3f_t direction;
};
} light_t;
typedef struct {
const sphere_t *spheres;
const light_t *lights;
u32 spheres_count;
u32 lights_count;
} raytracer_scene_t;
const raytracer_scene_t *build_test_scene(void);
colour_t trace_ray(vec3f_t origin, vec3f_t direction, f32 t_min, f32 t_max,
const scene_t *scene, colour_t default_colour,
const raytracer_scene_t *scene, colour_t default_colour,
u32 recursion_depth);
#endif // !RAYTRACER_H

View File

@@ -1,42 +0,0 @@
#ifndef SCENE_H
#define SCENE_H
#include "aliases.h"
#include "vector/vec.h"
#include "window/window.h"
typedef struct {
f32 radius;
vec3f_t centre;
colour_t colour;
f32 specular;
f32 reflective;
} sphere_t;
typedef enum {
LIGHT_TYPE_POINT,
LIGHT_TYPE_DIRECTIONAL,
LIGHT_TYPE_AMBIENT,
COUNT_LIGHT_TYPE,
} light_type_t;
typedef struct {
light_type_t type;
f32 intensity;
union {
vec3f_t position;
vec3f_t direction;
};
} light_t;
typedef struct {
const sphere_t *spheres;
const light_t *lights;
u32 spheres_count;
u32 lights_count;
} scene_t;
const scene_t *build_test_scene(void);
#endif // !SCENE_H