|
@@ -301,6 +301,26 @@ void ReflectionProbe::onRemove()
|
|
|
Parent::onRemove();
|
|
|
}
|
|
|
|
|
|
+void ReflectionProbe::deleteObject()
|
|
|
+{
|
|
|
+ //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::deleteObject();
|
|
|
+}
|
|
|
+
|
|
|
void ReflectionProbe::setTransform(const MatrixF & mat)
|
|
|
{
|
|
|
// Let SceneObject handle all of the matrix manipulation
|
|
@@ -424,8 +444,14 @@ void ReflectionProbe::unpackUpdate(NetConnection *conn, BitStream *stream)
|
|
|
{
|
|
|
mUseCubemap = stream->readFlag();
|
|
|
|
|
|
+ String newCubemapName;
|
|
|
stream->read(&mCubemapName);
|
|
|
|
|
|
+ //if (newCubemapName != mCubemapName)
|
|
|
+ {
|
|
|
+ processStaticCubemap();
|
|
|
+ }
|
|
|
+
|
|
|
isMaterialDirty = true;
|
|
|
}
|
|
|
|
|
@@ -502,62 +528,57 @@ void ReflectionProbe::updateProbeParams()
|
|
|
mProbeInfo->mScore = mMaxDrawDistance;
|
|
|
}
|
|
|
|
|
|
-void ReflectionProbe::updateMaterial()
|
|
|
+void ReflectionProbe::processStaticCubemap()
|
|
|
{
|
|
|
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 (!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 +587,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 +610,6 @@ bool ReflectionProbe::createClientResources()
|
|
|
mIrridianceMap->createMap();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
String irrPath = getIrradianceMapPath();
|
|
|
if (Platform::isFile(irrPath))
|
|
|
{
|