ongoing WIP to sort out init'ing issues as well as correcting values so the probes actually correctly update data into the arrays

Additional sanity checks on the updateTexture calls added by timmy
This commit is contained in:
Areloch 2019-03-25 00:06:08 -05:00
parent 26471aaa77
commit 1627cbabe6
6 changed files with 116 additions and 114 deletions

View file

@ -391,6 +391,7 @@ void RenderProbeMgr::_setupStaticParameters()
cubeMaps.clear();
irradMaps.clear();
Vector<U32> cubemapIdxes;
if (probeCount != 0 && ProbeRenderInst::all[0]->mPrefilterCubemap != nullptr)
{
@ -420,15 +421,6 @@ void RenderProbeMgr::_setupStaticParameters()
continue;
}
//if (curEntry.mCubemap.isNull() || curEntry.mIrradianceCubemap.isNull())
// continue;
//if (!curEntry.mCubemap->isInitialized())
// continue;
//if (!curEntry.mIrradianceCubemap->isInitialized())
// continue;
//Setup
Point3F probePos = curEntry.getPosition();
Point3F refPos = curEntry.getPosition() +curEntry.mProbeRefOffset;
@ -444,21 +436,40 @@ void RenderProbeMgr::_setupStaticParameters()
probeConfigData[mEffectiveProbeCount] = Point4F(curEntry.mProbeShapeType,
curEntry.mRadius,
curEntry.mAtten,
1);
curEntry.mCubemapIndex);
//cubeMaps.push_back(curEntry.mCubemap);
//irradMaps.push_back(curEntry.mIrradianceCubemap);
cubeMaps.push_back(curEntry.mPrefilterCubemap);
irradMaps.push_back(curEntry.mIrradianceCubemap);
cubemapIdxes.push_back(i);
mEffectiveProbeCount++;
}
if (mEffectiveProbeCount != 0)
{
//mPrefilterArray = GFXCubemapArrayHandle(GFX->createCubemapArray());
//mIrradianceArray = GFXCubemapArrayHandle(GFX->createCubemapArray());
bool useOldWay = false;
if (useOldWay)
{
//old static way
mPrefilterArray = GFXCubemapArrayHandle(GFX->createCubemapArray());
mIrradianceArray = GFXCubemapArrayHandle(GFX->createCubemapArray());
//mPrefilterArray->initStatic(cubeMaps.address(), cubeMaps.size());
//mIrradianceArray->initStatic(irradMaps.address(), irradMaps.size());
mPrefilterArray->init(cubeMaps.address(), cubeMaps.size());
mIrradianceArray->init(irradMaps.address(), irradMaps.size());
}
else
{
//faked static way by doing it via update
for (U32 i = 0; i < cubemapIdxes.size(); i++)
{
U32 probeIdx = cubemapIdxes[i];
const U32 cubeIndex = ProbeRenderInst::all[probeIdx]->mCubemapIndex;
mIrradianceArray->updateTexture(irradMaps[i], cubeIndex);
mPrefilterArray->updateTexture(cubeMaps[i], cubeIndex);
}
}
}
}
@ -740,7 +751,6 @@ void RenderProbeMgr::render( SceneRenderState *state )
{
mProbeArrayEffect->setCubemapTexture(6, skylightPrefilterMap);
mProbeArrayEffect->setCubemapTexture(7, skylightIrradMap);
}
if (mEffectiveProbeCount != 0)
@ -909,6 +919,11 @@ void RenderProbeMgr::bakeProbe(ReflectionProbe *probe)
IBLUtilities::GenerateIrradianceMap(renderTarget, cubeRefl.getCubemap(), clientProbe->mIrridianceMap->mCubemap);
IBLUtilities::GeneratePrefilterMap(renderTarget, cubeRefl.getCubemap(), prefilterMipLevels, clientProbe->mPrefilterMap->mCubemap);
U32 endMSTime = Platform::getRealMilliseconds();
F32 diffTime = F32(endMSTime - startMSTime);
Con::warnf("RenderProbeMgr::bake() - Finished Capture! Took %g milliseconds", diffTime);
Con::warnf("RenderProbeMgr::bake() - Beginning save now!");
IBLUtilities::SaveCubeMap(clientProbe->getIrradianceMapPath(), clientProbe->mIrridianceMap->mCubemap);
IBLUtilities::SaveCubeMap(clientProbe->getPrefilterMapPath(), clientProbe->mPrefilterMap->mCubemap);
}

View file

@ -170,9 +170,9 @@ class RenderProbeMgr : public RenderBinManager
//number of slots to allocate at once in the cubemap array
static const U32 PROBE_ARRAY_SLOT_BUFFER_SIZE = 10;
static const U32 PROBE_IRRAD_SIZE = 32;
static const U32 PROBE_PREFILTER_SIZE = 128;
static const GFXFormat PROBE_FORMAT = GFXFormatR8G8B8A8;// when hdr fixed GFXFormatR16G16B16A16F; look into bc6h compression
static const U32 PROBE_IRRAD_SIZE = 64;
static const U32 PROBE_PREFILTER_SIZE = 64;
static const GFXFormat PROBE_FORMAT = GFXFormatR16G16B16A16F;// GFXFormatR8G8B8A8;// when hdr fixed GFXFormatR16G16B16A16F; look into bc6h compression
static const U32 INVALID_CUBE_SLOT = U32_MAX;
//Array rendering