Skip to content

Commit

Permalink
Merge pull request #1636 from Azaezel/TranslucentTargetTweak
Browse files Browse the repository at this point in the history
puts forward-lit #targetname assignment of faux diffuse maps back
  • Loading branch information
Lopuska authored Aug 21, 2016
2 parents fcfe2d6 + 2d93403 commit 5d38357
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Engine/source/materials/processedMaterial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,10 @@ void ProcessedMaterial::_setStageData()
mStages[i].setTex( MFT_DiffuseMap, _createTexture( mMaterial->mDiffuseMapFilename[i], &GFXDefaultStaticDiffuseProfile ) );
if (!mStages[i].getTex( MFT_DiffuseMap ))
{
mMaterial->logError("Failed to load diffuse map %s for stage %i", _getTexturePath(mMaterial->mDiffuseMapFilename[i]).c_str(), i);
//If we start with a #, we're probably actually attempting to hit a named target and it may not get a hit on the first pass. So we'll
//pass on the error rather than spamming the console
if (!mMaterial->mDiffuseMapFilename[i].startsWith("#"))
mMaterial->logError("Failed to load diffuse map %s for stage %i", _getTexturePath(mMaterial->mDiffuseMapFilename[i]).c_str(), i);

// Load a debug texture to make it clear to the user
// that the texture for this stage was missing.
Expand Down
13 changes: 13 additions & 0 deletions Engine/source/materials/processedShaderMaterial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,19 @@ bool ProcessedShaderMaterial::init( const FeatureSet &features,
mInstancingState = new InstancingState();
mInstancingState->setFormat( _getRPD( 0 )->shader->getInstancingFormat(), mVertexFormat );
}
if (mMaterial && mMaterial->mDiffuseMapFilename[0].isNotEmpty() && mMaterial->mDiffuseMapFilename[0].substr(0, 1).equal("#"))
{
String texTargetBufferName = mMaterial->mDiffuseMapFilename[0].substr(1, mMaterial->mDiffuseMapFilename[0].length() - 1);
NamedTexTarget *texTarget = NamedTexTarget::find(texTargetBufferName);
RenderPassData* rpd = getPass(0);

if (rpd)
{
rpd->mTexSlot[0].texTarget = texTarget;
rpd->mTexType[0] = Material::TexTarget;
rpd->mSamplerNames[0] = "diffuseMap";
}
}
return true;
}

Expand Down

0 comments on commit 5d38357

Please sign in to comment.