The lighting is done better where I set it up once in the shader and then only change the camera spotlight when the camera moves.

This commit is contained in:
Zed A. Shaw 2026-08-27 15:00:48 -04:00
parent 748528a31f
commit 032f10ef44
5 changed files with 22 additions and 3 deletions

View file

@ -154,9 +154,11 @@ void Shader::apply_lighting(const Lighting& lighting) {
}
}
void Shader::apply_dir_light(const Light& light, size_t index) {
dbc::check(index < MAX_LIGHTS, "too many directional lights");
// nasty, this needs to go
setVec3(std::format("dirLights[{}].direction", index), light.direction);
setVec3(std::format("dirLights[{}].ambient", index), light.ambient);
setVec3(std::format("dirLights[{}].diffuse", index), light.diffuse);
@ -180,6 +182,7 @@ void Shader::apply_point_light(const Light& light, size_t index) {
void Shader::apply_spot_light(const Light& light, size_t index) {
dbc::check(index < MAX_LIGHTS, "too many spot lights");
// find a way to not make strings all the time
setVec3(std::format("spotLights[{}].position", index), light.position);
setVec3(std::format("spotLights[{}].direction", index), light.direction);
setVec3(std::format("spotLights[{}].ambient", index), light.ambient);