Skip to content

Commit

Permalink
client: render: added parent entities feature for dynamic lights
Browse files Browse the repository at this point in the history
Also, added flag for disabling shadows for entities that marked as parent for current dynamic light.
  • Loading branch information
SNMetamorph committed May 18, 2024
1 parent d6055eb commit b14f441
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
16 changes: 9 additions & 7 deletions client/render/cl_dlight.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ GNU General Public License for more details.
#define MAX_SHADOWMAPS (NUM_SHADOW_SPLITS + 1)

// dlight flags
#define DLF_NOSHADOWS BIT( 0 )
#define DLF_NOBUMP BIT( 1 )
#define DLF_LENSFLARE BIT( 2 )
#define DLF_CULLED BIT( 3 ) // light culled by scissor
#define DLF_ASPECT3X4 BIT( 4 )
#define DLF_ASPECT4X3 BIT( 5 )
#define DLF_FLIPTEXTURE BIT( 6 )
#define DLF_NOSHADOWS BIT( 0 )
#define DLF_NOBUMP BIT( 1 )
#define DLF_LENSFLARE BIT( 2 )
#define DLF_CULLED BIT( 3 ) // light culled by scissor
#define DLF_ASPECT3X4 BIT( 4 )
#define DLF_ASPECT4X3 BIT( 5 )
#define DLF_FLIPTEXTURE BIT( 6 )
#define DLF_PARENTENTITY_NOSHADOW BIT( 7 )

class CDynLight
{
Expand All @@ -46,6 +47,7 @@ class CDynLight
int type; // light type
int lightstyleIndex;
bool update; // light needs update
cl_entity_t *parentEntity;

matrix4x4 viewMatrix;
matrix4x4 projectionMatrix; // light projection matrix
Expand Down
9 changes: 8 additions & 1 deletion client/render/gl_shadows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ static void R_ShadowPassSetupViewCache( CDynLight *pl, int split = 0 )
RI->currentmodel = RI->currententity->model;

// skip entities with disabled shadow casting
if (RI->currententity->curstate.effects & EF_NOSHADOW)
if (FBitSet(RI->currententity->curstate.effects, EF_NOSHADOW))
continue;

// disable rendering shadows for local player
Expand All @@ -386,6 +386,13 @@ static void R_ShadowPassSetupViewCache( CDynLight *pl, int split = 0 )
continue;
}

// skip entities that marked as parent for dynlight and according flag set
if (FBitSet(pl->flags, DLF_PARENTENTITY_NOSHADOW) && pl->parentEntity)
{
if (RI->currententity->index == pl->parentEntity->index)
continue;
}

switch( RI->currentmodel->type )
{
case mod_studio:
Expand Down

0 comments on commit b14f441

Please sign in to comment.