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 : //defines the size, position & projection info for a reflective shadow map
17 : // the reflective shadow map is then used to calculate global illumination
18 : class reflectiveshadowmap final
19 : {
20 : public:
21 : std::array<plane, 4> cull;
22 : matrix4 model, proj;
23 : vec lightview;
24 : vec scale, offset;
25 : void setup();
26 : private:
27 : vec center, bounds;
28 : void getmodelmatrix();
29 : void getprojmatrix();
30 : void gencullplanes();
31 : };
32 :
33 : extern reflectiveshadowmap rsm;
34 :
35 : class radiancehints final
36 : {
37 : public:
38 1 : radiancehints() : dynmin(1e16f, 1e16f, 1e16f), dynmax(-1e16f, -1e16f, -1e16f), prevdynmin(1e16f, 1e16f, 1e16f), prevdynmax(-1e16f, -1e16f, -1e16f) {}
39 :
40 : vec dynmin, dynmax;
41 : void setup();
42 : void renderslices();
43 : void bindparams() const;
44 : void clearcache();
45 : bool allcached() const;
46 : //copies dynmin/max to prevdynmin/max
47 : void rotatedynlimits();
48 : //checks if prevmin's z value is less than prevmax
49 : bool checkprevbounds();
50 : private:
51 : vec prevdynmin, prevdynmax;
52 : //splits are used to LOD global illumination (more detail near camera)
53 : struct SplitInfo final
54 : {
55 : float nearplane, farplane;
56 : vec offset, scale;
57 : vec center; float bounds;
58 : vec cached; bool copied;
59 :
60 4 : SplitInfo() : center(-1e16f, -1e16f, -1e16f), bounds(-1e16f), cached(-1e16f, -1e16f, -1e16f), copied(false)
61 : {
62 4 : }
63 :
64 4 : void clearcache()
65 : {
66 4 : bounds = -1e16f;
67 4 : }
68 : };
69 : std::array<SplitInfo, rhmaxsplits> splits;
70 :
71 : void updatesplitdist();
72 : };
73 :
74 : extern radiancehints rh;
75 :
76 : extern void clearradiancehintscache();
77 : extern bool useradiancehints();
78 : extern void setupradiancehints();
79 : extern void cleanupradiancehints();
80 :
81 : extern void viewrh();
82 : extern void viewrsm();
83 :
84 : #endif
|