Line data Source code
1 : #ifndef RADIANCEHINTS_H_
2 : #define RADIANCEHINTS_H_
3 :
4 : //note that radiance hints is the term for the mechanism by which global illumination is done
5 : constexpr int rhmaxsplits = 4; //maximum number of times that radiance hints can split to increase resolution (note exponential increase in nodes)
6 :
7 : extern int rhsplits;
8 : extern int gi, gidist;
9 : extern float giscale, giaoscale;
10 : extern int debugrsm, debugrh;
11 : extern std::array<GLuint, 8> rhtex;
12 : extern Shader *rsmworldshader;
13 : extern int rsmcull;
14 : extern GLuint rhfbo;
15 :
16 : /**
17 : * @brief reflective shadow map object
18 : *
19 : * defines the size, position & projection info for a reflective shadow map
20 : * the reflective shadow map is then used to calculate global illumination
21 : */
22 : class ReflectiveShadowMap final
23 : {
24 : public:
25 : std::array<plane, 4> cull;
26 : matrix4 model, proj;
27 : vec lightview;
28 : vec scale, offset;
29 : void setup();
30 : private:
31 : vec center, bounds;
32 : void getmodelmatrix();
33 : void getprojmatrix();
34 : void gencullplanes();
35 : };
36 :
37 : extern ReflectiveShadowMap rsm;
38 :
39 : class RadianceHints final
40 : {
41 : public:
42 1 : RadianceHints() : dynmin(1e16f, 1e16f, 1e16f), dynmax(-1e16f, -1e16f, -1e16f), prevdynmin(1e16f, 1e16f, 1e16f), prevdynmax(-1e16f, -1e16f, -1e16f) {}
43 :
44 : vec dynmin, dynmax;
45 : void setup();
46 : void renderslices();
47 : void bindparams() const;
48 : void clearcache();
49 : bool allcached() const;
50 : //copies dynmin/max to prevdynmin/max
51 : void rotatedynlimits();
52 : //checks if prevmin's z value is less than prevmax
53 : bool checkprevbounds();
54 : private:
55 : vec prevdynmin, prevdynmax;
56 : //splits are used to LOD global illumination (more detail near camera)
57 : struct SplitInfo final
58 : {
59 : float nearplane, farplane;
60 : vec offset, scale;
61 : vec center;
62 : float bounds;
63 : vec cached;
64 : bool copied;
65 :
66 4 : SplitInfo() : center(-1e16f, -1e16f, -1e16f), bounds(-1e16f), cached(-1e16f, -1e16f, -1e16f), copied(false)
67 : {
68 4 : }
69 :
70 4 : void clearcache()
71 : {
72 4 : bounds = -1e16f;
73 4 : }
74 : };
75 : std::array<SplitInfo, rhmaxsplits> splits;
76 :
77 : void updatesplitdist();
78 : };
79 :
80 : extern RadianceHints rh;
81 :
82 : extern void clearradiancehintscache();
83 : extern bool useradiancehints();
84 : extern void setupradiancehints();
85 : extern void cleanupradiancehints();
86 :
87 : extern void viewrh();
88 : extern void viewrsm();
89 :
90 : #endif
|