Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 18 additions & 0 deletions src/engine/renderer/Material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,12 @@ void ProcessMaterialGeneric3D( Material* material, shaderStage_t* pStage, drawSu
material->tcGen_Lightmap = pStage->tcGen_Lightmap;
material->deformIndex = pStage->deformIndex;

colorGen_t rgbGen = SetRgbGen( pStage );
alphaGen_t alphaGen = SetAlphaGen( pStage );

material->useAttrColor = rgbGen == colorGen_t::CGEN_VERTEX || rgbGen == colorGen_t::CGEN_ONE_MINUS_VERTEX
|| alphaGen == alphaGen_t::AGEN_VERTEX || alphaGen == alphaGen_t::AGEN_ONE_MINUS_VERTEX;

gl_genericShaderMaterial->SetTCGenEnvironment( pStage->tcGen_Environment );
gl_genericShaderMaterial->SetTCGenLightmap( pStage->tcGen_Lightmap );

Expand Down Expand Up @@ -1309,6 +1315,12 @@ void ProcessMaterialLightMapping( Material* material, shaderStage_t* pStage, dra

DAEMON_ASSERT( !( enableDeluxeMapping && enableGridDeluxeMapping ) );

colorGen_t rgbGen = SetRgbGen( pStage );
alphaGen_t alphaGen = SetAlphaGen( pStage );

material->useAttrColor = rgbGen == colorGen_t::CGEN_VERTEX || rgbGen == colorGen_t::CGEN_ONE_MINUS_VERTEX
|| alphaGen == alphaGen_t::AGEN_VERTEX || alphaGen == alphaGen_t::AGEN_ONE_MINUS_VERTEX;

material->enableDeluxeMapping = enableDeluxeMapping;
material->enableGridLighting = enableGridLighting;
material->enableGridDeluxeMapping = enableGridDeluxeMapping;
Expand Down Expand Up @@ -2152,6 +2164,12 @@ void MaterialSystem::RenderMaterial( Material& material, const uint32_t viewID )

backEnd.currentEntity = &tr.worldEntity;

if ( material.useAttrColor ) {
material.shader->AddVertexAttribBit( ATTR_COLOR );
} else {
material.shader->DelVertexAttribBit( ATTR_COLOR );
}

GL_State( stateBits );
if ( material.usePolygonOffset ) {
glEnable( GL_POLYGON_OFFSET_FILL );
Expand Down
5 changes: 4 additions & 1 deletion src/engine/renderer/Material.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ struct Material {
bool enableSpecularMapping;
bool enablePhysicalMapping;

bool useAttrColor = false;

cullType_t cullType;

uint32_t sort;
Expand All @@ -126,7 +128,8 @@ struct Material {

bool operator==( const Material& other ) {
return program == other.program && stateBits == other.stateBits && vbo == other.vbo && ibo == other.ibo
&& fog == other.fog && cullType == other.cullType && usePolygonOffset == other.usePolygonOffset;
&& fog == other.fog && cullType == other.cullType && usePolygonOffset == other.usePolygonOffset
&& useAttrColor == other.useAttrColor;
}

void AddTexture( Texture* texture ) {
Expand Down