LCOV - code coverage report
Current view: top level - engine/render - radiancehints.h (source / functions) Coverage Total Hit
Test: Libprimis Test Coverage Lines: 100.0 % 6 6
Test Date: 2026-08-20 06:51:03 Functions: 100.0 % 3 3

            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              :         /**
      33              :          * @brief Sets the RSM matrix to sunlight direction
      34              :          *
      35              :          * Sets the reflectiveshadowmap's model to the global viewmatrix, then
      36              :          * points it to be oriented like the sun.
      37              :          */
      38              :         void getmodelmatrix();
      39              :         void getprojmatrix();
      40              :         void gencullplanes();
      41              : };
      42              : 
      43              : extern ReflectiveShadowMap rsm;
      44              : 
      45              : class RadianceHints final
      46              : {
      47              :     public:
      48            1 :         RadianceHints() : dynmin(1e16f, 1e16f, 1e16f), dynmax(-1e16f, -1e16f, -1e16f), prevdynmin(1e16f, 1e16f, 1e16f), prevdynmax(-1e16f, -1e16f, -1e16f) {}
      49              : 
      50              :         vec dynmin, dynmax;
      51              :         void setup();
      52              :         void renderslices();
      53              :         void bindparams() const;
      54              :         void clearcache();
      55              :         bool allcached() const;
      56              :         /**
      57              :          * @brief Rotates out dynmin/max to prevdynmin/max.
      58              :          *
      59              :          * The values of dynmin/max and prevdynmin/max are both equal to the previous
      60              :          * value of dynmin/max after this function is called. The previous value in
      61              :          * prevdynmin/max is deleted.
      62              :          */
      63              :         void rotatedynlimits();
      64              :         //checks if prevmin's z value is less than prevmax
      65              :         bool checkprevbounds() const;
      66              :     private:
      67              :         vec prevdynmin, prevdynmax;
      68              :         //splits are used to LOD global illumination (more detail near camera)
      69              :         struct SplitInfo final
      70              :         {
      71              :             float nearplane, farplane;
      72              :             vec offset, scale;
      73              :             vec center;
      74              :             float bounds;
      75              :             vec cached;
      76              :             bool copied;
      77              : 
      78            4 :             SplitInfo() : center(-1e16f, -1e16f, -1e16f), bounds(-1e16f), cached(-1e16f, -1e16f, -1e16f), copied(false)
      79              :             {
      80            4 :             }
      81              : 
      82            4 :             void clearcache()
      83              :             {
      84            4 :                 bounds = -1e16f;
      85            4 :             }
      86              :         };
      87              :         std::array<SplitInfo, rhmaxsplits> splits;
      88              : 
      89              :         void updatesplitdist();
      90              : };
      91              : 
      92              : extern RadianceHints rh;
      93              : 
      94              : extern void clearradiancehintscache();
      95              : extern bool useradiancehints();
      96              : extern void setupradiancehints();
      97              : extern void cleanupradiancehints();
      98              : 
      99              : extern void viewrh();
     100              : extern void viewrsm();
     101              : 
     102              : #endif
        

Generated by: LCOV version 2.0-1