#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 Lighting {
	static constexpr int max_lights = 128;
	static constexpr int max_shadows = 16;
	static constexpr int shadow_res = 2048;
	Staged_Buffer lights;
	Staged_Buffer casters;
	Texture_Id shadows;
	Texture_Id shadow_slices[max_shadows];
	Sampler_Id shadow_sampler;
	Camera_Id cameras[max_shadows];
	int sun_range[2];
	int point_range[2];
	int light_count, caster_count;
	void init(Device* dev);
	void destroy(Device* dev, 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;
};

struct Point_Light : Light {
	float range;
};

#endif