Updating BaseGame to work with PBR, and a PBR example module

This commit is contained in:
Areloch 2019-05-08 01:27:51 -05:00
parent e83ec69292
commit cedbd387d9
98 changed files with 6762 additions and 2889 deletions

View file

@ -45,6 +45,8 @@ S32 GFXTextureManager::smTextureReductionLevel = 0;
String GFXTextureManager::smMissingTexturePath(Con::getVariable("$Core::MissingTexturePath"));
String GFXTextureManager::smUnavailableTexturePath(Con::getVariable("$Core::UnAvailableTexturePath"));
String GFXTextureManager::smWarningTexturePath(Con::getVariable("$Core::WarningTexturePath"));
String GFXTextureManager::smDefaultIrradianceCubemapPath(Con::getVariable("$Core::DefaultIrradianceCubemap"));
String GFXTextureManager::smDefaultPrefilterCubemapPath(Con::getVariable("$Core::DefaultPrefilterCubemap"));
GFXTextureManager::EventSignal GFXTextureManager::smEventSignal;
@ -70,6 +72,14 @@ void GFXTextureManager::init()
Con::addVariable( "$pref::Video::warningTexturePath", TypeRealString, &smWarningTexturePath,
"The file path of the texture used to warn the developer.\n"
"@ingroup GFX\n" );
Con::addVariable("$Core::DefaultIrradianceCubemap", TypeRealString, &smDefaultIrradianceCubemapPath,
"The file path of the texture used as the default irradiance cubemap for PBR.\n"
"@ingroup GFX\n");
Con::addVariable("$Core::DefaultPrefilterCubemap", TypeRealString, &smDefaultPrefilterCubemapPath,
"The file path of the texture used as the default specular cubemap for PBR.\n"
"@ingroup GFX\n");
}
GFXTextureManager::GFXTextureManager()

View file

@ -74,6 +74,9 @@ public:
/// Provide the path to the texture used to warn the developer
static const String& getWarningTexturePath() { return smWarningTexturePath; }
static const String& getDefaultIrradianceCubemapPath() { return smDefaultIrradianceCubemapPath; }
static const String& getDefaultPrefilterCubemapPath() { return smDefaultPrefilterCubemapPath; }
/// Update width and height based on available resources.
///
/// We provide a simple interface for managing texture memory usage. Specifically,
@ -210,6 +213,9 @@ protected:
/// File path to the warning texture
static String smWarningTexturePath;
static String smDefaultIrradianceCubemapPath;
static String smDefaultPrefilterCubemapPath;
GFXTextureObject *mListHead;
GFXTextureObject *mListTail;

View file

@ -199,7 +199,8 @@ RenderProbeMgr::RenderProbeMgr()
: RenderBinManager(RenderPassManager::RIT_Probes, 1.0f, 1.0f),
mLastShader(nullptr),
mLastConstants(nullptr),
mProbesDirty(false)
mProbesDirty(false),
hasSkylight(false)
{
mEffectiveProbeCount = 0;
mMipCount = 0;
@ -250,13 +251,17 @@ bool RenderProbeMgr::onAdd()
//create our own default default skylight
mDefaultSkyLight = new ProbeRenderInst;
mDefaultSkyLight->mProbeShapeType = ProbeRenderInst::Skylight;
if (!mDefaultSkyLight->mIrradianceCubemap.set("core/art/pbr/default_irradiance.dds"))
mDefaultSkyLight->mIsEnabled = false;
String defaultIrradMapPath = GFXTextureManager::getDefaultIrradianceCubemapPath();
if (!mDefaultSkyLight->mIrradianceCubemap.set(defaultIrradMapPath))
{
Con::errorf("RenderProbeMgr::onAdd: Failed to load default irradiance cubemap");
return false;
}
if (!mDefaultSkyLight->mPrefilterCubemap.set("core/art/pbr/default_prefilter.dds"))
String defaultPrefilterPath = GFXTextureManager::getDefaultPrefilterCubemapPath();
if (!mDefaultSkyLight->mPrefilterCubemap.set(defaultPrefilterPath))
{
Con::errorf("RenderProbeMgr::onAdd: Failed to load default prefilter cubemap");
return false;
@ -825,15 +830,15 @@ void RenderProbeMgr::render( SceneRenderState *state )
mProbeArrayEffect->setShaderConst("$probeContribColors", contribColors);
}
mProbeArrayEffect->setShaderConst("$inProbePosArray", probePositionsData);
mProbeArrayEffect->setShaderConst("$inRefPosArray", probeRefPositionsData);
mProbeArrayEffect->setShaderConst("$worldToObjArray", probeWorldToObjData);
mProbeArrayEffect->setShaderConst("$bbMinArray", probeBBMinData);
mProbeArrayEffect->setShaderConst("$bbMaxArray", probeBBMaxData);
mProbeArrayEffect->setShaderConst("$probeConfigData", probeConfigData);
}
mProbeArrayEffect->setShaderConst("$inProbePosArray", probePositionsData);
mProbeArrayEffect->setShaderConst("$inRefPosArray", probeRefPositionsData);
mProbeArrayEffect->setShaderConst("$worldToObjArray", probeWorldToObjData);
mProbeArrayEffect->setShaderConst("$bbMinArray", probeBBMinData);
mProbeArrayEffect->setShaderConst("$bbMaxArray", probeBBMaxData);
mProbeArrayEffect->setShaderConst("$probeConfigData", probeConfigData);
// Make sure the effect is gonna render.
getProbeArrayEffect()->setSkip(false);

View file

@ -210,10 +210,10 @@ void AssimpAppMaterial::initMaterial(const Torque::Path& path, Material* mat) co
mat->mSpecularMapFilename[0] = cleanTextureName(torquePath, cleanFile);
}
LinearColorF specularColor(1.0f, 1.0f, 1.0f, 1.0f);
/*LinearColorF specularColor(1.0f, 1.0f, 1.0f, 1.0f);
if (AI_SUCCESS == mAIMat->Get(AI_MATKEY_COLOR_SPECULAR, read_color))
specularColor.set(read_color.r, read_color.g, read_color.b, opacity);
mat->mSpecular[0] = specularColor;
mat->mMetalness[0] = specularColor;
// Specular Power
F32 specularPower = 1.0f;
@ -223,7 +223,7 @@ void AssimpAppMaterial::initMaterial(const Torque::Path& path, Material* mat) co
// Specular
F32 specularStrength = 0.0f;
if (AI_SUCCESS == mAIMat->Get(AI_MATKEY_SHININESS, specularStrength))
mat->mSpecularStrength[0] = specularStrength;
mat->mSpecularStrength[0] = specularStrength;*/
#endif
// Double-Sided
@ -343,4 +343,4 @@ void AssimpAppMaterial::enumerateMaterialProperties(aiMaterial* mtl)
}
}
}
#endif
#endif