mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 08:34:40 +00:00
get probes displaying with low Texture quality
refactored detection of texture sizes for cubemaps removed the assumption that if we give U32 GFXTextureManager::getTextureDownscalePower( GFXTextureProfile *profile ) no profile, it should go right ahead and downscale anyway sniped the downscaling strings in the resulting U32 getProbeTexSize(); and void setCubeTexSize(const U32 cubemapFaceSize); until sucj time as we can properly follow up all possible combinations of shiping in one scale, and a customer choosing to use lower resolution textures as the current result is a hard shutoff entirely
This commit is contained in:
parent
1541a8cc68
commit
ad3c961579
7 changed files with 61 additions and 55 deletions
|
|
@ -396,19 +396,8 @@ void GFXD3D11CubemapArray::init(GFXCubemapHandle *cubemaps, const U32 cubemapCou
|
||||||
AssertFatal(cubemaps, "GFXD3D11CubemapArray::initStatic - Got null GFXCubemapHandle!");
|
AssertFatal(cubemaps, "GFXD3D11CubemapArray::initStatic - Got null GFXCubemapHandle!");
|
||||||
AssertFatal(*cubemaps, "GFXD3D11CubemapArray::initStatic - Got empty cubemap!");
|
AssertFatal(*cubemaps, "GFXD3D11CubemapArray::initStatic - Got empty cubemap!");
|
||||||
|
|
||||||
U32 downscalePower = GFXTextureManager::smTextureReductionLevel;
|
setCubeTexSize(cubemaps);
|
||||||
U32 scaledSize = cubemaps[0]->getSize();
|
|
||||||
|
|
||||||
if (downscalePower != 0)
|
|
||||||
{
|
|
||||||
// Otherwise apply the appropriate scale...
|
|
||||||
scaledSize >>= downscalePower;
|
|
||||||
}
|
|
||||||
|
|
||||||
//all cubemaps must be the same size,format and number of mipmaps. Grab the details from the first cubemap
|
|
||||||
mSize = scaledSize;
|
|
||||||
mFormat = cubemaps[0]->getFormat();
|
mFormat = cubemaps[0]->getFormat();
|
||||||
mMipMapLevels = cubemaps[0]->getMipMapLevels() - downscalePower;
|
|
||||||
mNumCubemaps = cubemapCount;
|
mNumCubemaps = cubemapCount;
|
||||||
|
|
||||||
//create texture object
|
//create texture object
|
||||||
|
|
@ -475,16 +464,7 @@ void GFXD3D11CubemapArray::init(GFXCubemapHandle *cubemaps, const U32 cubemapCou
|
||||||
//Just allocate the cubemap array but we don't upload any data
|
//Just allocate the cubemap array but we don't upload any data
|
||||||
void GFXD3D11CubemapArray::init(const U32 cubemapCount, const U32 cubemapFaceSize, const GFXFormat format)
|
void GFXD3D11CubemapArray::init(const U32 cubemapCount, const U32 cubemapFaceSize, const GFXFormat format)
|
||||||
{
|
{
|
||||||
U32 downscalePower = GFXTextureManager::smTextureReductionLevel;
|
setCubeTexSize(cubemapFaceSize);
|
||||||
U32 scaledSize = cubemapFaceSize;
|
|
||||||
|
|
||||||
if (downscalePower != 0)
|
|
||||||
{
|
|
||||||
scaledSize >>= downscalePower;
|
|
||||||
}
|
|
||||||
|
|
||||||
mSize = scaledSize;
|
|
||||||
mMipMapLevels = ImageUtil::getMaxMipCount(cubemapFaceSize, cubemapFaceSize) - downscalePower;
|
|
||||||
mNumCubemaps = cubemapCount;
|
mNumCubemaps = cubemapCount;
|
||||||
mFormat = format;
|
mFormat = format;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
#include "gfx/gfxDevice.h"
|
#include "gfx/gfxDevice.h"
|
||||||
#include "gfx/bitmap/gBitmap.h"
|
#include "gfx/bitmap/gBitmap.h"
|
||||||
#include "gfx/gfxTextureManager.h"
|
#include "gfx/gfxTextureManager.h"
|
||||||
|
#include "gfx/bitmap/imageUtils.h"
|
||||||
|
|
||||||
|
|
||||||
GFXCubemap::GFXCubemap()
|
GFXCubemap::GFXCubemap()
|
||||||
|
|
@ -138,3 +139,33 @@ const String GFXCubemapArray::describeSelf() const
|
||||||
return String();
|
return String();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GFXCubemapArray::setCubeTexSize(GFXCubemapHandle* cubemaps)
|
||||||
|
{
|
||||||
|
U32 downscalePower = 0;// GFXTextureManager::smTextureReductionLevel;
|
||||||
|
U32 scaledSize = cubemaps[0]->getSize();
|
||||||
|
|
||||||
|
if (downscalePower != 0)
|
||||||
|
{
|
||||||
|
// Otherwise apply the appropriate scale...
|
||||||
|
scaledSize >>= downscalePower;
|
||||||
|
}
|
||||||
|
|
||||||
|
//all cubemaps must be the same size,format and number of mipmaps. Grab the details from the first cubemap
|
||||||
|
mSize = scaledSize;
|
||||||
|
mMipMapLevels = cubemaps[0]->getMipMapLevels() - downscalePower;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GFXCubemapArray::setCubeTexSize(U32 cubemapFaceSize)
|
||||||
|
{
|
||||||
|
U32 downscalePower = 0;// GFXTextureManager::smTextureReductionLevel;
|
||||||
|
U32 scaledSize = cubemapFaceSize;
|
||||||
|
|
||||||
|
if (downscalePower != 0)
|
||||||
|
{
|
||||||
|
scaledSize >>= downscalePower;
|
||||||
|
}
|
||||||
|
|
||||||
|
mSize = scaledSize;
|
||||||
|
mMipMapLevels = ImageUtil::getMaxMipCount(cubemapFaceSize, cubemapFaceSize) - downscalePower;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,10 @@ protected:
|
||||||
public:
|
public:
|
||||||
GFXCubemapArray() :mNumCubemaps(0), mSize(0), mMipMapLevels(0), mFormat(GFXFormat_FIRST) {}
|
GFXCubemapArray() :mNumCubemaps(0), mSize(0), mMipMapLevels(0), mFormat(GFXFormat_FIRST) {}
|
||||||
virtual ~GFXCubemapArray() {};
|
virtual ~GFXCubemapArray() {};
|
||||||
|
|
||||||
/// Initialize from an array of cubemaps
|
/// Initialize from an array of cubemaps
|
||||||
|
void setCubeTexSize(GFXCubemapHandle* cubemaps);
|
||||||
|
void setCubeTexSize(const U32 cubemapFaceSize);
|
||||||
virtual void init(GFXCubemapHandle *cubemaps, const U32 cubemapCount) = 0;
|
virtual void init(GFXCubemapHandle *cubemaps, const U32 cubemapCount) = 0;
|
||||||
/// Initialize cubemapCount number of blank cubemaps in the array
|
/// Initialize cubemapCount number of blank cubemaps in the array
|
||||||
virtual void init(const U32 cubemapCount, const U32 cubemapFaceSize, const GFXFormat format) = 0;
|
virtual void init(const U32 cubemapCount, const U32 cubemapFaceSize, const GFXFormat format) = 0;
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ GFXTextureManager::~GFXTextureManager()
|
||||||
|
|
||||||
U32 GFXTextureManager::getTextureDownscalePower( GFXTextureProfile *profile )
|
U32 GFXTextureManager::getTextureDownscalePower( GFXTextureProfile *profile )
|
||||||
{
|
{
|
||||||
if ( !profile || profile->canDownscale() )
|
if ( profile && profile->canDownscale() )
|
||||||
return smTextureReductionLevel;
|
return smTextureReductionLevel;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -322,19 +322,8 @@ void GFXGLCubemapArray::init(GFXCubemapHandle *cubemaps, const U32 cubemapCount)
|
||||||
AssertFatal(cubemaps, "GFXGLCubemapArray- Got null GFXCubemapHandle!");
|
AssertFatal(cubemaps, "GFXGLCubemapArray- Got null GFXCubemapHandle!");
|
||||||
AssertFatal(*cubemaps, "GFXGLCubemapArray - Got empty cubemap!");
|
AssertFatal(*cubemaps, "GFXGLCubemapArray - Got empty cubemap!");
|
||||||
|
|
||||||
U32 downscalePower = GFXTextureManager::smTextureReductionLevel;
|
setCubeTexSize(cubemaps);
|
||||||
U32 scaledSize = cubemaps[0]->getSize();
|
|
||||||
|
|
||||||
if (downscalePower != 0)
|
|
||||||
{
|
|
||||||
// Otherwise apply the appropriate scale...
|
|
||||||
scaledSize >>= downscalePower;
|
|
||||||
}
|
|
||||||
|
|
||||||
//all cubemaps must be the same size,format and number of mipmaps. Grab the details from the first cubemap
|
|
||||||
mSize = scaledSize;
|
|
||||||
mFormat = cubemaps[0]->getFormat();
|
mFormat = cubemaps[0]->getFormat();
|
||||||
mMipMapLevels = cubemaps[0]->getMipMapLevels() - downscalePower;
|
|
||||||
mNumCubemaps = cubemapCount;
|
mNumCubemaps = cubemapCount;
|
||||||
const bool isCompressed = ImageUtil::isCompressedFormat(mFormat);
|
const bool isCompressed = ImageUtil::isCompressedFormat(mFormat);
|
||||||
|
|
||||||
|
|
@ -379,19 +368,8 @@ void GFXGLCubemapArray::init(GFXCubemapHandle *cubemaps, const U32 cubemapCount)
|
||||||
//Just allocate the cubemap array but we don't upload any data
|
//Just allocate the cubemap array but we don't upload any data
|
||||||
void GFXGLCubemapArray::init(const U32 cubemapCount, const U32 cubemapFaceSize, const GFXFormat format)
|
void GFXGLCubemapArray::init(const U32 cubemapCount, const U32 cubemapFaceSize, const GFXFormat format)
|
||||||
{
|
{
|
||||||
U32 downscalePower = GFXTextureManager::smTextureReductionLevel;
|
setCubeTexSize(cubemapCount);
|
||||||
U32 scaledSize = cubemapFaceSize;
|
|
||||||
|
|
||||||
if (downscalePower != 0)
|
|
||||||
{
|
|
||||||
// Otherwise apply the appropriate scale...
|
|
||||||
scaledSize >>= downscalePower;
|
|
||||||
}
|
|
||||||
|
|
||||||
//all cubemaps must be the same size,format and number of mipmaps. Grab the details from the first cubemap
|
|
||||||
mSize = scaledSize;
|
|
||||||
mFormat = format;
|
mFormat = format;
|
||||||
mMipMapLevels = ImageUtil::getMaxMipCount(scaledSize, scaledSize);
|
|
||||||
mNumCubemaps = cubemapCount;
|
mNumCubemaps = cubemapCount;
|
||||||
const bool isCompressed = ImageUtil::isCompressedFormat(mFormat);
|
const bool isCompressed = ImageUtil::isCompressedFormat(mFormat);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -223,9 +223,10 @@ bool RenderProbeMgr::onAdd()
|
||||||
mIrradianceArray = GFXCubemapArrayHandle(GFX->createCubemapArray());
|
mIrradianceArray = GFXCubemapArrayHandle(GFX->createCubemapArray());
|
||||||
mPrefilterArray = GFXCubemapArrayHandle(GFX->createCubemapArray());
|
mPrefilterArray = GFXCubemapArrayHandle(GFX->createCubemapArray());
|
||||||
|
|
||||||
|
U32 scaledSize = getProbeTexSize();
|
||||||
//pre-allocate a few slots
|
//pre-allocate a few slots
|
||||||
mIrradianceArray->init(PROBE_ARRAY_SLOT_BUFFER_SIZE, RenderProbeMgr::smProbeBakeResolution, PROBE_FORMAT);
|
mIrradianceArray->init(PROBE_ARRAY_SLOT_BUFFER_SIZE, scaledSize, PROBE_FORMAT);
|
||||||
mPrefilterArray->init(PROBE_ARRAY_SLOT_BUFFER_SIZE, RenderProbeMgr::smProbeBakeResolution, PROBE_FORMAT);
|
mPrefilterArray->init(PROBE_ARRAY_SLOT_BUFFER_SIZE, scaledSize, PROBE_FORMAT);
|
||||||
mCubeSlotCount = PROBE_ARRAY_SLOT_BUFFER_SIZE;
|
mCubeSlotCount = PROBE_ARRAY_SLOT_BUFFER_SIZE;
|
||||||
|
|
||||||
String brdfTexturePath = GFXTextureManager::getBRDFTexturePath();
|
String brdfTexturePath = GFXTextureManager::getBRDFTexturePath();
|
||||||
|
|
@ -362,8 +363,9 @@ void RenderProbeMgr::registerProbe(ReflectionProbe::ProbeInfo* newProbe)
|
||||||
GFXCubemapArrayHandle irr = GFXCubemapArrayHandle(GFX->createCubemapArray());
|
GFXCubemapArrayHandle irr = GFXCubemapArrayHandle(GFX->createCubemapArray());
|
||||||
GFXCubemapArrayHandle prefilter = GFXCubemapArrayHandle(GFX->createCubemapArray());
|
GFXCubemapArrayHandle prefilter = GFXCubemapArrayHandle(GFX->createCubemapArray());
|
||||||
|
|
||||||
irr->init(mCubeSlotCount + PROBE_ARRAY_SLOT_BUFFER_SIZE, RenderProbeMgr::smProbeBakeResolution, PROBE_FORMAT);
|
U32 scaledSize = getProbeTexSize();
|
||||||
prefilter->init(mCubeSlotCount + PROBE_ARRAY_SLOT_BUFFER_SIZE, RenderProbeMgr::smProbeBakeResolution, PROBE_FORMAT);
|
irr->init(mCubeSlotCount + PROBE_ARRAY_SLOT_BUFFER_SIZE, scaledSize, PROBE_FORMAT);
|
||||||
|
prefilter->init(mCubeSlotCount + PROBE_ARRAY_SLOT_BUFFER_SIZE, scaledSize, PROBE_FORMAT);
|
||||||
|
|
||||||
mIrradianceArray->copyTo(irr);
|
mIrradianceArray->copyTo(irr);
|
||||||
mPrefilterArray->copyTo(prefilter);
|
mPrefilterArray->copyTo(prefilter);
|
||||||
|
|
@ -428,23 +430,35 @@ PostEffect* RenderProbeMgr::getProbeArrayEffect()
|
||||||
return mProbeArrayEffect;
|
return mProbeArrayEffect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
U32 RenderProbeMgr::getProbeTexSize()
|
||||||
|
{
|
||||||
|
U32 scaledSize = RenderProbeMgr::smProbeBakeResolution;
|
||||||
|
U32 downscalePower = 0;// GFXTextureManager::smTextureReductionLevel;
|
||||||
|
if (downscalePower != 0)
|
||||||
|
{
|
||||||
|
// Otherwise apply the appropriate scale...
|
||||||
|
scaledSize >>= downscalePower;
|
||||||
|
}
|
||||||
|
return scaledSize;
|
||||||
|
}
|
||||||
|
|
||||||
void RenderProbeMgr::updateProbeTexture(ReflectionProbe::ProbeInfo* probeInfo)
|
void RenderProbeMgr::updateProbeTexture(ReflectionProbe::ProbeInfo* probeInfo)
|
||||||
{
|
{
|
||||||
//If we don't have a registered probe, there's no point in updating the cubemap array for it
|
//If we don't have a registered probe, there's no point in updating the cubemap array for it
|
||||||
ProbeRenderInst* probe = findProbeInst(probeInfo);
|
ProbeRenderInst* probe = findProbeInst(probeInfo);
|
||||||
if (probe == nullptr)
|
if (probe == nullptr)
|
||||||
return;
|
return;
|
||||||
|
U32 scaledSize = getProbeTexSize();
|
||||||
//Some basic sanity checking that we have valid cubemaps to work with
|
//Some basic sanity checking that we have valid cubemaps to work with
|
||||||
if (probeInfo->mIrradianceCubemap.isNull() || !probeInfo->mIrradianceCubemap->isInitialized() ||
|
if (probeInfo->mIrradianceCubemap.isNull() || !probeInfo->mIrradianceCubemap->isInitialized() ||
|
||||||
probeInfo->mIrradianceCubemap->getSize() != RenderProbeMgr::smProbeBakeResolution)
|
probeInfo->mIrradianceCubemap->getSize() != scaledSize)
|
||||||
{
|
{
|
||||||
Con::errorf("RenderProbeMgr::updateProbeTexture() - tried to update a probe's texture with an invalid or uninitialized irradiance map!");
|
Con::errorf("RenderProbeMgr::updateProbeTexture() - tried to update a probe's texture with an invalid or uninitialized irradiance map!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (probeInfo->mPrefilterCubemap.isNull() || !probeInfo->mPrefilterCubemap->isInitialized() ||
|
if (probeInfo->mPrefilterCubemap.isNull() || !probeInfo->mPrefilterCubemap->isInitialized() ||
|
||||||
probeInfo->mPrefilterCubemap->getSize() != RenderProbeMgr::smProbeBakeResolution)
|
probeInfo->mPrefilterCubemap->getSize() != scaledSize)
|
||||||
{
|
{
|
||||||
Con::errorf("RenderProbeMgr::updateProbeTexture() - tried to update a probe's texture with an invalid or uninitialized specular map!");
|
Con::errorf("RenderProbeMgr::updateProbeTexture() - tried to update a probe's texture with an invalid or uninitialized specular map!");
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -402,7 +402,7 @@ public:
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>the PostEffect object</returns>
|
/// <returns>the PostEffect object</returns>
|
||||||
PostEffect* getProbeArrayEffect();
|
PostEffect* getProbeArrayEffect();
|
||||||
|
U32 getProbeTexSize();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Finds the associated cubemap array slot for the incoming ProbeInfo and updates the array's texture(s) from it
|
/// Finds the associated cubemap array slot for the incoming ProbeInfo and updates the array's texture(s) from it
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue