sdl_runtime_compiler git · main
SDL3 game for running and compiling code at runtime
C++ 72.3% C 26.2%git clone https://git.christianimmanuel.de/sdl-graphics/sdl_runtime_compiler.gitwget https://git.christianimmanuel.de/sdl-graphics/sdl_runtime_compiler/archive/sdl_runtime_compiler.tar.gzsrc/utils/light.hpp raw
#pragma once
#include "math.hpp"
namespace
Nimbin
{
struct Light {
Vec3 sun_direction { 0.3, -0.9, 0.2 };
Vec3 sun_color { 1.00, 0.95, 0.85 };
Vec3 flashlight_pos { 0.0, 0.0, 0.0 };
Vec3 flashlight_dir { 0.0, 0.0, -1.0 };
Vec3 flashlight_color { 1.00, 0.95, 0.80 };
Vec3 ambient { 0.25, 0.27, 0.30 };
float sun_intensity { 0.0f }; // off for now
float flashlight_range { 40.0f };
float flashlight_inner_cos { 0.85f }; // ≈ 32° full cone
float flashlight_outer_cos { 0.50f }; // ≈ 60° cutoff
float flashlight_intensity { 1.5f };
Light() { normalize(); }
void normalize() {
double len = SDL_sqrt(sun_direction.x*sun_direction.x +
sun_direction.y*sun_direction.y +
sun_direction.z*sun_direction.z);
if (len > 1e-6) sun_direction = sun_direction / len;
len = SDL_sqrt(flashlight_dir.x*flashlight_dir.x +
flashlight_dir.y*flashlight_dir.y +
flashlight_dir.z*flashlight_dir.z);
if (len > 1e-6) flashlight_dir = flashlight_dir / len;
}
};
} // namespace Nimbin