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-06-16 06:16:16 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              :         //copies dynmin/max to prevdynmin/max
      57              :         void rotatedynlimits();
      58              :         //checks if prevmin's z value is less than prevmax
      59              :         bool checkprevbounds() const;
      60              :     private:
      61              :         vec prevdynmin, prevdynmax;
      62              :         //splits are used to LOD global illumination (more detail near camera)
      63              :         struct SplitInfo final
      64              :         {
      65              :             float nearplane, farplane;
      66              :             vec offset, scale;
      67              :             vec center;
      68              :             float bounds;
      69              :             vec cached;
      70              :             bool copied;
      71              : 
      72            4 :             SplitInfo() : center(-1e16f, -1e16f, -1e16f), bounds(-1e16f), cached(-1e16f, -1e16f, -1e16f), copied(false)
      73              :             {
      74            4 :             }
      75              : 
      76            4 :             void clearcache()
      77              :             {
      78            4 :                 bounds = -1e16f;
      79            4 :             }
      80              :         };
      81              :         std::array<SplitInfo, rhmaxsplits> splits;
      82              : 
      83              :         void updatesplitdist();
      84              : };
      85              : 
      86              : extern RadianceHints rh;
      87              : 
      88              : extern void clearradiancehintscache();
      89              : extern bool useradiancehints();
      90              : extern void setupradiancehints();
      91              : extern void cleanupradiancehints();
      92              : 
      93              : extern void viewrh();
      94              : extern void viewrsm();
      95              : 
      96              : #endif
        

Generated by: LCOV version 2.0-1