From 702e63cb0c76f9a2e60448679d0ffc9b3bbc4b4c Mon Sep 17 00:00:00 2001 From: Azaezel Date: Tue, 7 Jun 2016 13:54:30 -0500 Subject: [PATCH 1/2] puts forward-lit #targetname assignment of faux diffuse maps back --- Engine/source/materials/processedShaderMaterial.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Engine/source/materials/processedShaderMaterial.cpp b/Engine/source/materials/processedShaderMaterial.cpp index cd230ef534..fbc2a92ce4 100644 --- a/Engine/source/materials/processedShaderMaterial.cpp +++ b/Engine/source/materials/processedShaderMaterial.cpp @@ -211,6 +211,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; } From 2d934032ea96576d6d0325495c341c0e28d9f39f Mon Sep 17 00:00:00 2001 From: Areloch Date: Thu, 7 Jul 2016 00:52:57 -0500 Subject: [PATCH 2/2] Adds a check so if we're trying to hit a named target, it doesn't spam the console with errors about not finding the diffuse texture. --- Engine/source/materials/processedMaterial.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Engine/source/materials/processedMaterial.cpp b/Engine/source/materials/processedMaterial.cpp index 00a3b8ec26..b013ee45bb 100644 --- a/Engine/source/materials/processedMaterial.cpp +++ b/Engine/source/materials/processedMaterial.cpp @@ -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.