#ifndef lighting_hpp #define lighting_hpp #include "camera.hpp" #include "maths.hpp" #include "video.hpp" struct Arena; struct Model_Resources; struct Model_Scene; struct Renderer; struct World; struct Caster { Camera_Id reality; Camera_Id jittered; }; struct Lighting { static constexpr int max_lights = 128; static constexpr int max_shadows = 16; static constexpr int shadowmap_count = max_shadows * 2; static constexpr int shadow_res = 2048; Staged_Buffer gpu_lights; Staged_Buffer gpu_casters; Texture_Id shadows; Texture_Id shadow_slices[shadowmap_count]; Texture_Id ss_shadows[2]; Texture_Id ss_shadow_slices[2][shadowmap_count]; Texture_Id occlusion[2]; Sampler_Id shadow_sampler; Caster casters[max_shadows]; Camera_Id cameras[shadowmap_count]; int light_count, caster_count, cam_count; void init(Device* dev, int w, int h); void destroy_ss(Device* dev); void recreate(Device* dev, int w, int h); void destroy(Device* dev, Renderer& r); Camera_Id gm_cam(Renderer& r); void update( Device* dev, Context& ctx, World& w, Renderer& r, Model_Scene& s ); void write_bufs( void* lptr, void* cptr, World& w, Renderer& r, Model_Scene& s ); }; struct Light { v3f colour; float brightness; bool caster; }; struct Sun_Light : Light { v3f dir; }; #endif