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; float bounds;
62 : vec cached; bool copied;
63 :
64 4 : SplitInfo() : center(-1e16f, -1e16f, -1e16f), bounds(-1e16f), cached(-1e16f, -1e16f, -1e16f), copied(false)
65 : {
66 4 : }
67 :
68 4 : void clearcache()
69 : {
70 4 : bounds = -1e16f;
71 4 : }
72 : };
73 : std::array<SplitInfo, rhmaxsplits> splits;
74 :
75 : void updatesplitdist();
76 : };
77 :
78 : extern RadianceHints rh;
79 :
80 : extern void clearradiancehintscache();
81 : extern bool useradiancehints();
82 : extern void setupradiancehints();
83 : extern void cleanupradiancehints();
84 :
85 : extern void viewrh();
86 : extern void viewrsm();
87 :
88 : #endif
|