@@ -522,6 +522,39 @@ static void AddDebugProjectedLight()
522522 light->origin [ 2 ] = r_debugProjLightOriginZ.Get ();
523523}
524524
525+ // Debug sun light (directional) injection
526+ Cvar::Cvar<bool > r_debugSun ( " r_debugSun" , " inject a directional sun light each frame" , Cvar::NONE, false );
527+ Cvar::Range<Cvar::Cvar<float >> r_debugSunYaw ( " r_debugSunYaw" , " debug sun yaw in degrees" , Cvar::NONE, 45 .0f , -360 .0f , 360 .0f );
528+ Cvar::Range<Cvar::Cvar<float >> r_debugSunPitch ( " r_debugSunPitch" , " debug sun pitch in degrees" , Cvar::NONE, -60 .0f , -89 .0f , 89 .0f );
529+ Cvar::Range<Cvar::Cvar<float >> r_debugSunIntensity ( " r_debugSunIntensity" , " debug sun intensity (scale)" , Cvar::NONE, 1 .0f , 0 .0f , 100 .0f );
530+ Cvar::Range<Cvar::Cvar<float >> r_debugSunR ( " r_debugSunR" , " debug sun color R" , Cvar::NONE, 1 .0f , 0 .0f , 10 .0f );
531+ Cvar::Range<Cvar::Cvar<float >> r_debugSunG ( " r_debugSunG" , " debug sun color G" , Cvar::NONE, 1 .0f , 0 .0f , 10 .0f );
532+ Cvar::Range<Cvar::Cvar<float >> r_debugSunB ( " r_debugSunB" , " debug sun color B" , Cvar::NONE, 1 .0f , 0 .0f , 10 .0f );
533+
534+ static void AddDebugSunLight ()
535+ {
536+ if ( r_numLights + 1 >= MAX_REF_LIGHTS )
537+ {
538+ return ;
539+ }
540+ refLight_t *sun = &backEndData[ tr.smpFrame ]->lights [ r_numLights++ ];
541+ *sun = {};
542+ sun->rlType = refLightType_t::RL_DIRECTIONAL;
543+ // Compute direction from yaw/pitch cvars (in degrees)
544+ float yaw = DEG2RAD ( r_debugSunYaw.Get () );
545+ float pitch = DEG2RAD ( r_debugSunPitch.Get () );
546+ // Right-handed: X forward, Y left, Z up. Direction vector components:
547+ sun->projTarget [ 0 ] = cosf ( pitch ) * cosf ( yaw );
548+ sun->projTarget [ 1 ] = cosf ( pitch ) * sinf ( yaw );
549+ sun->projTarget [ 2 ] = sinf ( pitch );
550+ VectorNormalize ( sun->projTarget );
551+ // Color and intensity
552+ sun->color [ 0 ] = r_debugSunR.Get ();
553+ sun->color [ 1 ] = r_debugSunG.Get ();
554+ sun->color [ 2 ] = r_debugSunB.Get ();
555+ sun->scale = r_debugSunIntensity.Get ();
556+ }
557+
525558/*
526559@@@@@@@@@@@@@@@@@@@@@
527560RE_RenderScene
@@ -601,6 +634,10 @@ void RE_RenderScene( const refdef_t *fd )
601634 {
602635 AddDebugProjectedLight ();
603636 }
637+ if ( r_debugSun.Get () )
638+ {
639+ AddDebugSunLight ();
640+ }
604641
605642 // derived info
606643 if ( r_forceRendererTime.Get () >= 0 ) {
0 commit comments