|
@@ -301,6 +301,26 @@ void ReflectionProbe::onRemove()
|
|
|
Parent::onRemove();
|
|
|
}
|
|
|
|
|
|
+void ReflectionProbe::handleDeleteAction()
|
|
|
+{
|
|
|
+ //we're deleting it?
|
|
|
+ //Then we need to clear out the processed cubemaps(if we have them)
|
|
|
+
|
|
|
+ String prefilPath = getPrefilterMapPath();
|
|
|
+ if (Platform::isFile(prefilPath))
|
|
|
+ {
|
|
|
+ Platform::fileDelete(prefilPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ String irrPath = getIrradianceMapPath();
|
|
|
+ if (Platform::isFile(irrPath))
|
|
|
+ {
|
|
|
+ Platform::fileDelete(irrPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ Parent::handleDeleteAction();
|
|
|
+}
|
|
|
+
|
|
|
void ReflectionProbe::setTransform(const MatrixF & mat)
|
|
|
{
|
|
|
// Let SceneObject handle all of the matrix manipulation
|
|
@@ -420,17 +440,23 @@ void ReflectionProbe::unpackUpdate(NetConnection *conn, BitStream *stream)
|
|
|
isMaterialDirty = true;
|
|
|
}
|
|
|
|
|
|
+ updateProbeParams();
|
|
|
+
|
|
|
if (stream->readFlag()) // CubemapMask
|
|
|
{
|
|
|
mUseCubemap = stream->readFlag();
|
|
|
|
|
|
+ String newCubemapName;
|
|
|
stream->read(&mCubemapName);
|
|
|
|
|
|
+ //if (newCubemapName != mCubemapName)
|
|
|
+ {
|
|
|
+ processStaticCubemap();
|
|
|
+ }
|
|
|
+
|
|
|
isMaterialDirty = true;
|
|
|
}
|
|
|
|
|
|
- updateProbeParams();
|
|
|
-
|
|
|
if (isMaterialDirty)
|
|
|
{
|
|
|
updateMaterial();
|
|
@@ -502,62 +528,71 @@ void ReflectionProbe::updateProbeParams()
|
|
|
mProbeInfo->mScore = mMaxDrawDistance;
|
|
|
}
|
|
|
|
|
|
-void ReflectionProbe::updateMaterial()
|
|
|
+void ReflectionProbe::processStaticCubemap()
|
|
|
{
|
|
|
+ if (mReflectionModeType != StaticCubemap)
|
|
|
+ return;
|
|
|
+
|
|
|
createClientResources();
|
|
|
|
|
|
- if (mReflectionModeType != DynamicCubemap)
|
|
|
+ Sim::findObject(mCubemapName, mStaticCubemap);
|
|
|
+
|
|
|
+ if (!mStaticCubemap)
|
|
|
{
|
|
|
- if ((mReflectionModeType == BakedCubemap) && !mProbeUniqueID.isEmpty())
|
|
|
- {
|
|
|
- if (mPrefilterMap != nullptr && mPrefilterMap->mCubemap.isValid())
|
|
|
- {
|
|
|
- mProbeInfo->mCubemap = &mPrefilterMap->mCubemap;
|
|
|
- }
|
|
|
- if (mIrridianceMap != nullptr && mIrridianceMap->mCubemap.isValid())
|
|
|
- {
|
|
|
- mProbeInfo->mIrradianceCubemap = &mIrridianceMap->mCubemap;
|
|
|
- }
|
|
|
- if (mBrdfTexture.isValid())
|
|
|
- {
|
|
|
- mProbeInfo->mBRDFTexture = &mBrdfTexture;
|
|
|
- }
|
|
|
- }
|
|
|
- else if (mReflectionModeType == StaticCubemap && !mCubemapName.isEmpty())
|
|
|
- {
|
|
|
- Sim::findObject(mCubemapName, mStaticCubemap);
|
|
|
+ Con::errorf("ReflectionProbe::updateMaterial() - unable to find static cubemap file!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- if (!mStaticCubemap)
|
|
|
- {
|
|
|
- Con::errorf("ReflectionProbe::updateMaterial() - unable to find static cubemap file!");
|
|
|
- return;
|
|
|
- }
|
|
|
+ if (mStaticCubemap->mCubemap == nullptr)
|
|
|
+ {
|
|
|
+ mStaticCubemap->createMap();
|
|
|
+ mStaticCubemap->updateFaces();
|
|
|
+ }
|
|
|
|
|
|
- if (mStaticCubemap->mCubemap == nullptr)
|
|
|
- {
|
|
|
- mStaticCubemap->createMap();
|
|
|
- mStaticCubemap->updateFaces();
|
|
|
- }
|
|
|
+ String prefilPath = getPrefilterMapPath();
|
|
|
+ String irrPath = getIrradianceMapPath();
|
|
|
+
|
|
|
+ if (mUseHDRCaptures)
|
|
|
+ {
|
|
|
+ mIrridianceMap->mCubemap->initDynamic(mPrefilterSize, GFXFormatR16G16B16A16F);
|
|
|
+ mPrefilterMap->mCubemap->initDynamic(mPrefilterSize, GFXFormatR16G16B16A16F);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ mIrridianceMap->mCubemap->initDynamic(mPrefilterSize, GFXFormatR8G8B8A8);
|
|
|
+ mPrefilterMap->mCubemap->initDynamic(mPrefilterSize, GFXFormatR8G8B8A8);
|
|
|
+ }
|
|
|
+
|
|
|
+ //if (!Platform::isFile(irrPath) || !Platform::isFile(prefilPath))
|
|
|
+ {
|
|
|
+ GFXTextureTargetRef renderTarget = GFX->allocRenderToTextureTarget(false);
|
|
|
+
|
|
|
+ IBLUtilities::GenerateIrradianceMap(renderTarget, mStaticCubemap->mCubemap, mIrridianceMap->mCubemap);
|
|
|
+ IBLUtilities::GeneratePrefilterMap(renderTarget, mStaticCubemap->mCubemap, mPrefilterMipLevels, mPrefilterMap->mCubemap);
|
|
|
|
|
|
- //GFXTextureTargetRef renderTarget = GFX->allocRenderToTextureTarget(false);
|
|
|
+ IBLUtilities::SaveCubeMap(getIrradianceMapPath(), mIrridianceMap->mCubemap);
|
|
|
+ IBLUtilities::SaveCubeMap(getPrefilterMapPath(), mPrefilterMap->mCubemap);
|
|
|
+ }
|
|
|
|
|
|
- //IBLUtilities::GenerateIrradianceMap(renderTarget, mStaticCubemap->mCubemap, mIrridianceMap->mCubemap);
|
|
|
- //IBLUtilities::GeneratePrefilterMap(renderTarget, mStaticCubemap->mCubemap, mPrefilterMipLevels, mPrefilterMap->mCubemap);
|
|
|
+ mProbeInfo->mCubemap = &mPrefilterMap->mCubemap;
|
|
|
+ mProbeInfo->mIrradianceCubemap = &mIrridianceMap->mCubemap;
|
|
|
+}
|
|
|
|
|
|
- mProbeInfo->mCubemap = &mStaticCubemap->mCubemap;
|
|
|
- mProbeInfo->mIrradianceCubemap = &mStaticCubemap->mCubemap;
|
|
|
+void ReflectionProbe::updateMaterial()
|
|
|
+{
|
|
|
+ createClientResources();
|
|
|
|
|
|
- /*if (mPrefilterMap != nullptr && mPrefilterMap->mCubemap.isValid())
|
|
|
+ if (mReflectionModeType != DynamicCubemap)
|
|
|
+ {
|
|
|
+ if ((mReflectionModeType == BakedCubemap) && !mProbeUniqueID.isEmpty())
|
|
|
+ {
|
|
|
+ if (mPrefilterMap != nullptr && mPrefilterMap->mCubemap.isValid())
|
|
|
{
|
|
|
mProbeInfo->mCubemap = &mPrefilterMap->mCubemap;
|
|
|
}
|
|
|
if (mIrridianceMap != nullptr && mIrridianceMap->mCubemap.isValid())
|
|
|
{
|
|
|
mProbeInfo->mIrradianceCubemap = &mIrridianceMap->mCubemap;
|
|
|
- }*/
|
|
|
- if (mBrdfTexture.isValid())
|
|
|
- {
|
|
|
- mProbeInfo->mBRDFTexture = &mBrdfTexture;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -566,6 +601,11 @@ void ReflectionProbe::updateMaterial()
|
|
|
mProbeInfo->mCubemap = &mDynamicCubemap;
|
|
|
}
|
|
|
|
|
|
+ if (mBrdfTexture.isValid())
|
|
|
+ {
|
|
|
+ mProbeInfo->mBRDFTexture = &mBrdfTexture;
|
|
|
+ }
|
|
|
+
|
|
|
//Make us ready to render
|
|
|
if (mEnabled)
|
|
|
mProbeInfo->mIsEnabled = true;
|
|
@@ -584,7 +624,6 @@ bool ReflectionProbe::createClientResources()
|
|
|
mIrridianceMap->createMap();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
String irrPath = getIrradianceMapPath();
|
|
|
if (Platform::isFile(irrPath))
|
|
|
{
|