@@ -346,7 +346,7 @@ static void RE_RenderCubeProbeFace( const refdef_t* originalRefdef ) {
346346 Log::Warn ( " Cube probe face out of range! (%i/%i)" , probeID, tr.cubeProbes .size () );
347347 return ;
348348 }
349-
349+
350350 refdef_t refdef{};
351351 const int faceID = globalID % 6 ;
352352
@@ -467,6 +467,61 @@ static void RE_RenderCubeProbeFace( const refdef_t* originalRefdef ) {
467467
468468}
469469
470+ // Debug spot light (projected) injection
471+ static Cvar::Cvar<bool > r_debugProjLight ( " r_debugProjLight" , " inject a directional sun light each frame" , Cvar::NONE, false );
472+ static Cvar::Range<Cvar::Cvar<float >> r_debugProjLightYaw ( " r_debugProjLightYaw" , " debug projected yaw in degrees" , Cvar::NONE, 45 .0f , -360 .0f , 360 .0f );
473+ static Cvar::Range<Cvar::Cvar<float >> r_debugProjLightPitch ( " r_debugProjLightPitch" , " debug projected pitch in degrees" , Cvar::NONE, -60 .0f , -89 .0f , 89 .0f );
474+ static Cvar::Cvar<float > r_debugProjLightIntensity ( " r_debugProjLightIntensity" , " debug projected intensity (scale)" , Cvar::NONE, 1 .0f );
475+ static Cvar::Cvar<float > r_debugProjLightRadius ( " r_debugProjLightRadius" , " debug projected radius (size)" , Cvar::NONE, 100 .0f );
476+ static Cvar::Range<Cvar::Cvar<float >> r_debugProjLightR ( " r_debugProjLightR" , " debug projected color R" , Cvar::NONE, 1 .0f , 0 .0f , 1 .0f );
477+ static Cvar::Range<Cvar::Cvar<float >> r_debugProjLightG ( " r_debugProjLightG" , " debug projected color G" , Cvar::NONE, 1 .0f , 0 .0f , 1 .0f );
478+ static Cvar::Range<Cvar::Cvar<float >> r_debugProjLightB ( " r_debugProjLightB" , " debug projected color B" , Cvar::NONE, 1 .0f , 0 .0f , 1 .0f );
479+ static Cvar::Cvar<float > r_debugProjLightOriginX ( " r_debugProjLightOriginX" , " debug projected origin X" , Cvar::NONE, 0 .0f );
480+ static Cvar::Cvar<float > r_debugProjLightOriginY ( " r_debugProjLightOriginY" , " debug projected origin Y" , Cvar::NONE, 0 .0f );
481+ static Cvar::Cvar<float > r_debugProjLightOriginZ ( " r_debugProjLightOriginZ" , " debug projected origin Z" , Cvar::NONE, 0 .0f );
482+ static Cvar::Cvar<float > r_debugProjLightAngle ( " r_debugProjLightAngle" , " debug projected angle" ,
483+ Cvar::NONE, 60 .0f );
484+
485+ static void AddDebugProjectedLight ()
486+ {
487+ if ( r_numLights + 1 >= MAX_REF_LIGHTS )
488+ {
489+ return ;
490+ }
491+ refLight_t *light = &backEndData[ tr.smpFrame ]->lights [ r_numLights++ ];
492+ *light = {};
493+ light->rlType = refLightType_t::RL_PROJ;
494+ // Compute direction from yaw/pitch cvars (in degrees)
495+ float yaw = DEG2RAD ( r_debugProjLightYaw.Get () );
496+ float pitch = DEG2RAD ( r_debugProjLightPitch.Get () );
497+ // Right-handed: X forward, Y left, Z up. Direction vector components:
498+ light->projTarget [ 0 ] = cosf ( pitch ) * cosf ( yaw );
499+ light->projTarget [ 1 ] = cosf ( pitch ) * sinf ( yaw );
500+ light->projTarget [ 2 ] = sinf ( pitch );
501+
502+ vec3_t dir;
503+ VectorCopy ( light->projTarget , dir );
504+ VectorNormalize ( dir );
505+
506+ PerpendicularVector ( light->projUp , dir );
507+
508+ float upLen = VectorLength ( light->projUp );
509+ float tgtLen = VectorLength ( light->projTarget );
510+
511+ VectorScale ( light->projUp , tanf ( DEG2RAD ( r_debugProjLightAngle.Get () ) ) / upLen / tgtLen,
512+ light->projUp );
513+
514+ // Color and intensity
515+ light->color [ 0 ] = r_debugProjLightR.Get ();
516+ light->color [ 1 ] = r_debugProjLightG.Get ();
517+ light->color [ 2 ] = r_debugProjLightB.Get ();
518+ light->scale = r_debugProjLightIntensity.Get ();
519+ light->radius = r_debugProjLightRadius.Get ();
520+ light->origin [ 0 ] = r_debugProjLightOriginX.Get ();
521+ light->origin [ 1 ] = r_debugProjLightOriginY.Get ();
522+ light->origin [ 2 ] = r_debugProjLightOriginZ.Get ();
523+ }
524+
470525/*
471526@@@@@@@@@@@@@@@@@@@@@
472527RE_RenderScene
@@ -542,6 +597,11 @@ void RE_RenderScene( const refdef_t *fd )
542597 }
543598 }
544599
600+ if ( r_debugProjLight.Get () )
601+ {
602+ AddDebugProjectedLight ();
603+ }
604+
545605 // derived info
546606 if ( r_forceRendererTime.Get () >= 0 ) {
547607 tr.refdef .floatTime = float ( double ( r_forceRendererTime.Get () ) * 0.001 );
0 commit comments