Skip to content

Commit

Permalink
NUKE light intensity/scale
Browse files Browse the repository at this point in the history
This was only used to scale the light's colour, just multiply the colour with it earlier on instead.
  • Loading branch information
VReaperV committed Jan 26, 2025
1 parent a41adc2 commit d6d0194
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/engine/client/cg_msgdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ namespace Render {
using AddRefEntityToSceneMsg = IPC::Message<IPC::Id<VM::QVM, CG_R_ADDREFENTITYTOSCENE>, refEntity_t>;
using AddPolyToSceneMsg = IPC::Message<IPC::Id<VM::QVM, CG_R_ADDPOLYTOSCENE>, int, std::vector<polyVert_t>>;
using AddPolysToSceneMsg = IPC::Message<IPC::Id<VM::QVM, CG_R_ADDPOLYSTOSCENE>, int, std::vector<polyVert_t>, int, int>;
using AddLightToSceneMsg = IPC::Message<IPC::Id<VM::QVM, CG_R_ADDLIGHTTOSCENE>, std::array<float, 3>, float, float, float, float, float, int>;
using AddLightToSceneMsg = IPC::Message<IPC::Id<VM::QVM, CG_R_ADDLIGHTTOSCENE>, std::array<float, 3>, float, float, float, float, int>;
using SetColorMsg = IPC::Message<IPC::Id<VM::QVM, CG_R_SETCOLOR>, Color::Color>;
using SetClipRegionMsg = IPC::Message<IPC::Id<VM::QVM, CG_R_SETCLIPREGION>, std::array<float, 4>>;
using ResetClipRegionMsg = IPC::Message<IPC::Id<VM::QVM, CG_R_RESETCLIPREGION>>;
Expand Down
4 changes: 2 additions & 2 deletions src/engine/client/cl_cgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1626,8 +1626,8 @@ void CGameVM::CmdBuffer::HandleCommandBufferSyscall(int major, int minor, Util::
break;

case CG_R_ADDLIGHTTOSCENE:
HandleMsg<Render::AddLightToSceneMsg>(std::move(reader), [this] (const std::array<float, 3>& point, float radius, float intensity, float r, float g, float b, int flags) {
re.AddLightToScene(point.data(), radius, intensity, r, g, b, flags);
HandleMsg<Render::AddLightToSceneMsg>(std::move(reader), [this] (const std::array<float, 3>& point, float radius, float r, float g, float b, int flags) {
re.AddLightToScene(point.data(), radius, r, g, b, flags);
});
break;

Expand Down
2 changes: 1 addition & 1 deletion src/engine/null/null_renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ int R_LightForPoint( vec3_t, vec3_t, vec3_t, vec3_t )
}
void RE_AddPolyToScene( qhandle_t, int, const polyVert_t* ) { }
void RE_AddPolysToScene( qhandle_t, int, const polyVert_t*, int ) { }
void RE_AddLightToScene( const vec3_t, float, float, float, float, float, int ) { }
void RE_AddLightToScene( const vec3_t, float, float, float, float, int ) { }
void RE_RenderScene( const refdef_t* ) { }
void RE_SetColor( const Color::Color& ) { }
void RE_SetClipRegion( const float* ) { }
Expand Down
2 changes: 1 addition & 1 deletion src/engine/renderer/tr_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5334,7 +5334,7 @@ const RenderCommand *SetupLightsCommand::ExecuteSelf() const

VectorCopy( light->l.origin, buffer[i].center );
buffer[i].radius = light->l.radius;
VectorScale( light->l.color, light->l.scale, buffer[i].color );
VectorCopy( light->l.color, buffer[i].color );

buffer[i].type = Util::ordinal( light->l.rlType );
switch( light->l.rlType ) {
Expand Down
2 changes: 1 addition & 1 deletion src/engine/renderer/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -3690,7 +3690,7 @@ inline bool checkGLErrors()
void RE_AddPolyToSceneET( qhandle_t hShader, int numVerts, const polyVert_t *verts );
void RE_AddPolysToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts, int numPolys );

void RE_AddDynamicLightToScene( const vec3_t org, float radius, float intensity, float r, float g, float b, int flags );
void RE_AddDynamicLightToScene( const vec3_t org, float radius, float r, float g, float b, int flags );

void RE_RenderScene( const refdef_t *fd );

Expand Down
2 changes: 1 addition & 1 deletion src/engine/renderer/tr_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ struct refexport_t
void ( *AddPolyToScene )( qhandle_t hShader, int numVerts, const polyVert_t *verts );
void ( *AddPolysToScene )( qhandle_t hShader, int numVerts, const polyVert_t *verts, int numPolys );

void ( *AddLightToScene )( const vec3_t org, float radius, float intensity, float r, float g, float b, int flags );
void ( *AddLightToScene )( const vec3_t org, float radius, float r, float g, float b, int flags );

void ( *RenderScene )( const refdef_t *fd );

Expand Down
14 changes: 6 additions & 8 deletions src/engine/renderer/tr_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,8 @@ RE_AddDynamicLightToScene
ydnar: modified dlight system to support separate radius and intensity
=====================
*/
void RE_AddDynamicLightToScene( const vec3_t org, float radius, float intensity, float r, float g, float b, int flags )
void RE_AddDynamicLightToScene( const vec3_t org, float radius, float r, float g, float b, int flags )
{
trRefLight_t *light;

if ( !glConfig2.realtimeLighting || !r_drawDynamicLights.Get() )
{
return;
Expand All @@ -304,11 +302,12 @@ void RE_AddDynamicLightToScene( const vec3_t org, float radius, float intensity,
return;
}

if ( intensity <= 0 || radius <= 0 )
if ( radius <= 0 )
{
return;
}

trRefLight_t* light;
// set last lights restrictInteractionEnd if needed
if ( r_numLights > r_firstSceneLight ) {
light = &backEndData[ tr.smpFrame ]->lights[ r_numLights - 1 ];
Expand Down Expand Up @@ -347,10 +346,9 @@ void RE_AddDynamicLightToScene( const vec3_t org, float radius, float intensity,

light->additive = true;

if( light->l.inverseShadows )
light->l.scale = -intensity;
else
light->l.scale = intensity;
if ( light->l.inverseShadows ) {
VectorNegate( light->l.color, light->l.color );
}
}

static void RE_RenderCubeProbeFace( const refdef_t* originalRefdef ) {
Expand Down
6 changes: 3 additions & 3 deletions src/engine/renderer/tr_shade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,7 @@ static void Render_forwardLighting_DBS_omni( shaderStage_t *pStage,
gl_forwardLightingShader_omniXYZ->SetUniform_LightOrigin( lightOrigin );
gl_forwardLightingShader_omniXYZ->SetUniform_LightColor( lightColor.ToArray() );
gl_forwardLightingShader_omniXYZ->SetUniform_LightRadius( light->sphereRadius );
gl_forwardLightingShader_omniXYZ->SetUniform_LightScale( light->l.scale );
gl_forwardLightingShader_omniXYZ->SetUniform_LightScale( 1.0 );
gl_forwardLightingShader_omniXYZ->SetUniform_LightAttenuationMatrix( light->attenuationMatrix2 );

GL_CheckErrors();
Expand Down Expand Up @@ -1557,7 +1557,7 @@ static void Render_forwardLighting_DBS_proj( shaderStage_t *pStage,
gl_forwardLightingShader_projXYZ->SetUniform_LightOrigin( lightOrigin );
gl_forwardLightingShader_projXYZ->SetUniform_LightColor( lightColor.ToArray() );
gl_forwardLightingShader_projXYZ->SetUniform_LightRadius( light->sphereRadius );
gl_forwardLightingShader_projXYZ->SetUniform_LightScale( light->l.scale );
gl_forwardLightingShader_projXYZ->SetUniform_LightScale( 1.0 );
gl_forwardLightingShader_projXYZ->SetUniform_LightAttenuationMatrix( light->attenuationMatrix2 );

GL_CheckErrors();
Expand Down Expand Up @@ -1735,7 +1735,7 @@ static void Render_forwardLighting_DBS_directional( shaderStage_t *pStage, trRef
gl_forwardLightingShader_directionalSun->SetUniform_LightDir( lightDirection );
gl_forwardLightingShader_directionalSun->SetUniform_LightColor( lightColor.ToArray() );
gl_forwardLightingShader_directionalSun->SetUniform_LightRadius( light->sphereRadius );
gl_forwardLightingShader_directionalSun->SetUniform_LightScale( light->l.scale );
gl_forwardLightingShader_directionalSun->SetUniform_LightScale( 1.0 );
gl_forwardLightingShader_directionalSun->SetUniform_LightAttenuationMatrix( light->attenuationMatrix2 );

GL_CheckErrors();
Expand Down
4 changes: 1 addition & 3 deletions src/engine/renderer/tr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,7 @@ struct refLight_t
vec3_t origin;
quat_t rotation;
vec3_t center;
vec3_t color; // range from 0.0 to 1.0, should be color normalized

float scale;
vec3_t color; // should be color normalized

// omni-directional light specific
float radius;
Expand Down
2 changes: 1 addition & 1 deletion src/shared/client/cg_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ void trap_R_AddLightToScene( const vec3_t origin, float radius, float intensity,
{
std::array<float, 3> myorg;
VectorCopy( origin, myorg );
cmdBuffer.SendMsg<Render::AddLightToSceneMsg>(myorg, radius, intensity, r, g, b, flags);
cmdBuffer.SendMsg<Render::AddLightToSceneMsg>(myorg, radius, r * intensity, g * intensity, b * intensity, flags);
}

void trap_R_RenderScene( const refdef_t *fd )
Expand Down

0 comments on commit d6d0194

Please sign in to comment.