summaryrefslogtreecommitdiff
path: root/lighting.hpp
blob: 0d331d73e07b07c2d84c35acf6287c6fd9812f82 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#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];
	Texture_Id ss_shadows[2];
	Texture_Id ss_shadow_slices[2][max_shadows];
	Sampler_Id shadow_sampler;
	Camera_Id cameras[max_shadows];
	int light_count, caster_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);
	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