Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 10 additions & 26 deletions src/engine/renderer/gl_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,11 @@ static bool IsUnusedPermutation( const char *compileMacros )
const char* token;
while ( *( token = COM_ParseExt2( &compileMacros, false ) ) )
{
if ( strcmp( token, "USE_DELUXE_MAPPING" ) == 0 )
if ( strcmp( token, "USE_VERTEX_SKINNING" ) == 0 )
{
if ( !glConfig.vboVertexSkinningAvailable ) return true;
}
else if ( strcmp( token, "USE_DELUXE_MAPPING" ) == 0 )
{
if ( !glConfig.deluxeMapping ) return true;
}
Expand Down Expand Up @@ -2042,11 +2046,6 @@ bool GLCompileMacro_USE_VERTEX_SKINNING::HasConflictingMacros( size_t permutatio
return false;
}

bool GLCompileMacro_USE_VERTEX_SKINNING::MissesRequiredMacros( size_t /*permutation*/, const std::vector< GLCompileMacro * > &/*macros*/ ) const
{
return !glConfig.vboVertexSkinningAvailable;
}

bool GLCompileMacro_USE_VERTEX_ANIMATION::HasConflictingMacros( size_t permutation, const std::vector< GLCompileMacro * > &macros ) const
{
for (const GLCompileMacro* macro : macros)
Expand Down Expand Up @@ -2113,20 +2112,13 @@ bool GLCompileMacro_USE_GRID_DELUXE_MAPPING::HasConflictingMacros(size_t permuta
{
for (const GLCompileMacro* macro : macros)
{
if ((permutation & macro->GetBit()) != 0 && (macro->GetType() == USE_DELUXE_MAPPING || macro->GetType() == USE_BSP_SURFACE))
if ((permutation & macro->GetBit()) != 0 && (macro->GetType() == USE_DELUXE_MAPPING))
{
return true;
}
}

return false;
}

bool GLCompileMacro_USE_GRID_LIGHTING::HasConflictingMacros(size_t permutation, const std::vector<GLCompileMacro*> &macros) const
{
for (const GLCompileMacro* macro : macros)
{
if ((permutation & macro->GetBit()) != 0 && (macro->GetType() == USE_DELUXE_MAPPING))
// grid lighting is required
if ((macro->GetType() == USE_GRID_LIGHTING) && !(permutation & macro->GetBit()))
{
return true;
}
Expand All @@ -2135,11 +2127,11 @@ bool GLCompileMacro_USE_GRID_LIGHTING::HasConflictingMacros(size_t permutation,
return false;
}

bool GLCompileMacro_USE_BSP_SURFACE::HasConflictingMacros(size_t permutation, const std::vector<GLCompileMacro*> &macros) const
bool GLCompileMacro_USE_GRID_LIGHTING::HasConflictingMacros(size_t permutation, const std::vector<GLCompileMacro*> &macros) const
{
for (const GLCompileMacro* macro : macros)
{
if ((permutation & macro->GetBit()) != 0 && (macro->GetType() == USE_GRID_DELUXE_MAPPING))
if ((permutation & macro->GetBit()) != 0 && (macro->GetType() == USE_DELUXE_MAPPING))
{
return true;
}
Expand Down Expand Up @@ -2246,10 +2238,6 @@ uint32_t GLShader::GetUniqueCompileMacros( size_t permutation, const int type )
continue;
}

if ( macro->MissesRequiredMacros( permutation, _compileMacros ) ) {
continue;
}

if ( !( macro->GetShaderTypes() & type ) ) {
continue;
}
Expand All @@ -2270,10 +2258,6 @@ bool GLShader::GetCompileMacrosString( size_t permutation, std::string &compileM
return false;
}

if ( macro->MissesRequiredMacros( permutation, _compileMacros ) ) {
return false;
}

if ( !( macro->GetShaderTypes() & type ) ) {
return false;
}
Expand Down
8 changes: 0 additions & 8 deletions src/engine/renderer/gl_shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -952,11 +952,6 @@ class GLCompileMacro
return false;
}

virtual bool MissesRequiredMacros( size_t, const std::vector<GLCompileMacro*>& ) const
{
return false;
}

virtual uint32_t GetRequiredVertexAttributes() const
{
return 0;
Expand Down Expand Up @@ -1034,8 +1029,6 @@ class GLCompileMacro_USE_BSP_SURFACE :
return "USE_BSP_SURFACE";
}

bool HasConflictingMacros(size_t permutation, const std::vector< GLCompileMacro * > &macros) const override;

EGLCompileMacro GetType() const override
{
return EGLCompileMacro::USE_BSP_SURFACE;
Expand Down Expand Up @@ -1075,7 +1068,6 @@ class GLCompileMacro_USE_VERTEX_SKINNING :
}

bool HasConflictingMacros( size_t permutation, const std::vector< GLCompileMacro * > &macros ) const override;
bool MissesRequiredMacros( size_t permutation, const std::vector< GLCompileMacro * > &macros ) const override;

uint32_t GetRequiredVertexAttributes() const override
{
Expand Down
2 changes: 1 addition & 1 deletion src/engine/renderer/glsl_source/computeLight_fp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void computeDeluxeLight( vec3 lightDir, vec3 normal, vec3 viewDir, vec3 lightCol
// clamp( NdotL, 0.0, 1.0 ) is done below
float NdotL = dot( normal, lightDir );

#if !defined(USE_BSP_SURFACE) && defined(r_halfLambertLighting)
#if defined(USE_GRID_LIGHTING) && defined(r_halfLambertLighting)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The !defined(USE_BSP_SURFACE) was because half lambert lighting is supposedly only meaningful on models, it wasn't a convoluted way to select grid lighting.

Is it intentional to use half lambert lighting on BSP surfaces as well? Maybe it makes sense because maybe models need half lambert because they are lit with the grid light to begin with.

I want to be sure this is intentional.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The case where half-Lambert clearly doesn't make sense is with lightmaps, since the lightmap precomputation already considers light bouncing. With grid lighting on the other hand, it seems to me an especially good idea as a way to soften the directionality, since with the way q3map2 works it always picks a direction and attributes lots of light as directed, even if there is roughly the same amount of light from all directions. In my tests with r_lightMode 2 a lot of places that looked bad were fixed by enabling half-Lambert lighting.

// http://developer.valvesoftware.com/wiki/Half_Lambert
NdotL = NdotL * 0.5 + 0.5;
NdotL *= NdotL;
Expand Down
6 changes: 5 additions & 1 deletion src/engine/renderer/tr_bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4657,7 +4657,11 @@ static void SetWorldLight() {
// Game model surfaces use grid lighting, they don't have vertex light colors.
tr.modelDeluxe = deluxeMode_t::GRID;

// Only game models use emulated deluxe map from light direction grid.
// Only game models use emulated deluxe map from light direction grid, unless the
// `r_lightMode 2` debug option is used.
if ( tr.worldLight == lightMode_t::GRID ) {
tr.worldDeluxe = deluxeMode_t::GRID;
}
}
}

Expand Down
Loading