LCOV - code coverage report
Current view: top level - engine/render - radiancehints.h (source / functions) Hit Total Coverage
Test: Libprimis Test Coverage Lines: 6 6 100.0 %
Date: 2024-11-22 05:07:59 Functions: 3 3 100.0 %

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

Generated by: LCOV version 1.14