mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-25 09:33:50 +00:00
adds wetness
cliffsnotes: $Core::WetnessTexture = "core/rendering/images/wetMap.png"; //for the influence degree map probes/skylight have a new canDamp boolean, set to off for probes, on for skylight by default. :levelinfo has a dampness multiplier (0-1) kicked up numTextures from 8 to 16 for shaderdata and postfx since that hit the 8 texture-in prior limit, and we've already adopted apis that can handle the higher count
This commit is contained in:
parent
e16351605b
commit
d23ee397e6
31 changed files with 352 additions and 100 deletions
|
|
@ -786,7 +786,6 @@ void Precipitation::unpackUpdate(NetConnection* con, BitStream* stream)
|
|||
mUseWind = stream->readFlag();
|
||||
mFollowCam = stream->readFlag();
|
||||
mAnimateSplashes = stream->readFlag();
|
||||
|
||||
mDropHitMask = dropHitMask |
|
||||
( mDropHitPlayers ? PlayerObjectType : 0 ) |
|
||||
( mDropHitVehicles ? VehicleObjectType : 0 );
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@
|
|||
|
||||
#include "torqueConfig.h"
|
||||
#include "T3D/accumulationVolume.h"
|
||||
#include "console/typeValidators.h"
|
||||
#include "materials/materialManager.h"
|
||||
|
||||
IMPLEMENT_CO_NETOBJECT_V1(LevelInfo);
|
||||
|
||||
|
|
@ -88,7 +90,8 @@ LevelInfo::LevelInfo()
|
|||
mAmbientLightBlendPhase( 1.f ),
|
||||
mSoundAmbience( NULL ),
|
||||
mSoundDistanceModel( SFXDistanceModelLinear ),
|
||||
mSoundscape( NULL )
|
||||
mSoundscape( NULL ),
|
||||
mDampness(0.0)
|
||||
{
|
||||
mFogData.density = 0.0f;
|
||||
mFogData.densityOffset = 0.0f;
|
||||
|
|
@ -120,6 +123,8 @@ LevelInfo::~LevelInfo()
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
FRangeValidator ValiDampnessRange(0.0f, 1.0f);
|
||||
|
||||
void LevelInfo::initPersistFields()
|
||||
{
|
||||
addGroup( "Visibility" );
|
||||
|
|
@ -130,6 +135,8 @@ void LevelInfo::initPersistFields()
|
|||
addField( "decalBias", TypeF32, Offset( mDecalBias, LevelInfo ),
|
||||
"NearPlane bias used when rendering Decal and DecalRoad. This should be tuned to the visibleDistance in your level." );
|
||||
|
||||
addFieldV("dampness", TypeF32, Offset(mDampness, LevelInfo), &ValiDampnessRange,
|
||||
"@brief dampness influence");
|
||||
endGroup( "Visibility" );
|
||||
|
||||
addGroup( "Fog" );
|
||||
|
|
@ -199,6 +206,7 @@ U32 LevelInfo::packUpdate(NetConnection *conn, U32 mask, BitStream *stream)
|
|||
stream->write( mNearClip );
|
||||
stream->write( mVisibleDistance );
|
||||
stream->write( mDecalBias );
|
||||
stream->write(mDampness);
|
||||
|
||||
stream->write( mFogData.density );
|
||||
stream->write( mFogData.densityOffset );
|
||||
|
|
@ -229,6 +237,8 @@ void LevelInfo::unpackUpdate(NetConnection *conn, BitStream *stream)
|
|||
stream->read( &mNearClip );
|
||||
stream->read( &mVisibleDistance );
|
||||
stream->read( &mDecalBias );
|
||||
stream->read(&mDampness);
|
||||
MATMGR->setDampness(mDampness);
|
||||
|
||||
stream->read( &mFogData.density );
|
||||
stream->read( &mFogData.densityOffset );
|
||||
|
|
|
|||
|
|
@ -92,6 +92,8 @@ class LevelInfo : public NetObject
|
|||
|
||||
///
|
||||
SFXSoundscape* mSoundscape;
|
||||
|
||||
F32 mDampness; ///<applies wetness
|
||||
|
||||
/// @}
|
||||
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@ ReflectionProbe::ReflectionProbe()
|
|||
mEditPosOffset = false;
|
||||
|
||||
mCaptureMask = REFLECTION_PROBE_CAPTURE_TYPEMASK;
|
||||
mCanDamp = false;
|
||||
}
|
||||
|
||||
ReflectionProbe::~ReflectionProbe()
|
||||
|
|
@ -150,6 +151,7 @@ ReflectionProbe::~ReflectionProbe()
|
|||
//-----------------------------------------------------------------------------
|
||||
void ReflectionProbe::initPersistFields()
|
||||
{
|
||||
addField("canDamp", TypeBool, Offset(mCanDamp, ReflectionProbe),"wetness allowed");
|
||||
addGroup("Rendering");
|
||||
addProtectedField("enabled", TypeBool, Offset(mEnabled, ReflectionProbe),
|
||||
&_setEnabled, &defaultProtectedGetFn, "Is the probe enabled or not");
|
||||
|
|
@ -435,6 +437,7 @@ U32 ReflectionProbe::packUpdate(NetConnection *conn, U32 mask, BitStream *stream
|
|||
{
|
||||
stream->writeFlag(mEnabled);
|
||||
}
|
||||
stream->writeFlag(mCanDamp);
|
||||
|
||||
return retMask;
|
||||
}
|
||||
|
|
@ -491,6 +494,7 @@ void ReflectionProbe::unpackUpdate(NetConnection *conn, BitStream *stream)
|
|||
|
||||
mDirty = true;
|
||||
}
|
||||
mCanDamp = stream->readFlag();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -555,7 +559,8 @@ void ReflectionProbe::updateProbeParams()
|
|||
|
||||
mProbeInfo.mProbeRefOffset = mProbeRefOffset;
|
||||
mProbeInfo.mProbeRefScale = mProbeRefScale;
|
||||
|
||||
mProbeInfo.mCanDamp = mCanDamp;
|
||||
|
||||
mProbeInfo.mDirty = true;
|
||||
|
||||
if (mCubemapDirty)
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ public:
|
|||
};
|
||||
|
||||
ProbeShapeType mProbeShapeType;
|
||||
|
||||
bool mCanDamp;
|
||||
public:
|
||||
|
||||
ProbeInfo() : mScore(0) {}
|
||||
|
|
@ -255,7 +255,7 @@ protected:
|
|||
|
||||
bool mResourcesCreated;
|
||||
U32 mCaptureMask;
|
||||
|
||||
bool mCanDamp;
|
||||
public:
|
||||
ReflectionProbe();
|
||||
virtual ~ReflectionProbe();
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ ConsoleDocClass(Skylight,
|
|||
Skylight::Skylight() : ReflectionProbe()
|
||||
{
|
||||
mCaptureMask = SKYLIGHT_CAPTURE_TYPEMASK;
|
||||
mCanDamp = true;
|
||||
}
|
||||
|
||||
Skylight::~Skylight()
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ String GFXTextureManager::smMissingTexturePath(Con::getVariable("$Core::MissingT
|
|||
String GFXTextureManager::smUnavailableTexturePath(Con::getVariable("$Core::UnAvailableTexturePath"));
|
||||
String GFXTextureManager::smWarningTexturePath(Con::getVariable("$Core::WarningTexturePath"));
|
||||
String GFXTextureManager::smBRDFTexturePath(Con::getVariable("$Core::BRDFTexture"));
|
||||
String GFXTextureManager::smWetnessTexturePath(Con::getVariable("$Core::WetnessTexture"));
|
||||
|
||||
GFXTextureManager::EventSignal GFXTextureManager::smEventSignal;
|
||||
|
||||
|
|
@ -74,7 +75,11 @@ void GFXTextureManager::init()
|
|||
"@ingroup GFX\n" );
|
||||
|
||||
Con::addVariable("$Core::BRDFTexture", TypeRealString, &smBRDFTexturePath,
|
||||
"The file path of the texture used as the default irradiance cubemap for PBR.\n"
|
||||
"The file path of the texture used as the default BRDF lut for PBR.\n"
|
||||
"@ingroup GFX\n");
|
||||
|
||||
Con::addVariable("$Core::WetnessTexture", TypeRealString, &smWetnessTexturePath,
|
||||
"The file path of the texture used as the default wetness influence map for PBR.\n"
|
||||
"@ingroup GFX\n");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ public:
|
|||
static const String& getWarningTexturePath() { return smWarningTexturePath; }
|
||||
|
||||
static const String& getBRDFTexturePath() { return smBRDFTexturePath; }
|
||||
static const String& getWetnessTexturePath() { return smWetnessTexturePath; }
|
||||
|
||||
/// Update width and height based on available resources.
|
||||
///
|
||||
|
|
@ -215,7 +216,8 @@ protected:
|
|||
static String smWarningTexturePath;
|
||||
|
||||
static String smBRDFTexturePath;
|
||||
|
||||
static String smWetnessTexturePath;
|
||||
|
||||
GFXTextureObject *mListHead;
|
||||
GFXTextureObject *mListTail;
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,8 @@ MaterialManager::MaterialManager()
|
|||
|
||||
mDt = 0.0f;
|
||||
mAccumTime = 0.0f;
|
||||
mLastTime = 0;
|
||||
mLastTime = 0;
|
||||
mDampness = 0.0f;
|
||||
mWarningInst = NULL;
|
||||
|
||||
GFXDevice::getDeviceEventSignal().notify( this, &MaterialManager::_handleGFXEvent );
|
||||
|
|
|
|||
|
|
@ -105,7 +105,10 @@ public:
|
|||
F32 getTotalTime() const { return mAccumTime; }
|
||||
F32 getDeltaTime() const { return mDt; }
|
||||
U32 getLastUpdateTime() const { return mLastTime; }
|
||||
|
||||
|
||||
F32 getDampness() const { return mDampness; }
|
||||
F32 getDampnessClamped() const { return mClampF(mDampness, 0.0, 1.0); }
|
||||
void setDampness(F32 dampness) { mDampness = dampness; }
|
||||
/// Signal used to notify systems that
|
||||
/// procedural shaders have been flushed.
|
||||
typedef Signal<void()> FlushSignal;
|
||||
|
|
@ -163,6 +166,7 @@ protected:
|
|||
F32 mDt;
|
||||
F32 mAccumTime;
|
||||
U32 mLastTime;
|
||||
F32 mDampness;
|
||||
|
||||
BaseMatInstance* mWarningInst;
|
||||
|
||||
|
|
|
|||
|
|
@ -319,8 +319,9 @@ bool ProcessedCustomMaterial::setupPass( SceneRenderState *state, const SceneDat
|
|||
if (pm)
|
||||
pm->setProbeInfo(this, NULL, sgData, state, pass, shaderConsts);
|
||||
|
||||
shaderConsts->setSafe(rpd->shaderHandles.mAccumTimeSC, MATMGR->getTotalTime());
|
||||
|
||||
shaderConsts->setSafe(rpd->shaderHandles.mAccumTimeSC, MATMGR->getTotalTime());
|
||||
shaderConsts->setSafe(rpd->shaderHandles.mDampnessSC, MATMGR->getDampnessClamped());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ void ShaderConstHandles::init( GFXShader *shader, CustomMaterial* mat /*=NULL*/)
|
|||
mEyeMatSC = shader->getShaderConstHandle(ShaderGenVars::eyeMat);
|
||||
mOneOverFarplane = shader->getShaderConstHandle(ShaderGenVars::oneOverFarplane);
|
||||
mAccumTimeSC = shader->getShaderConstHandle(ShaderGenVars::accumTime);
|
||||
mDampnessSC = shader->getShaderConstHandle(ShaderGenVars::dampness);
|
||||
mMinnaertConstantSC = shader->getShaderConstHandle(ShaderGenVars::minnaertConstant);
|
||||
mSubSurfaceParamsSC = shader->getShaderConstHandle(ShaderGenVars::subSurfaceParams);
|
||||
mDiffuseAtlasParamsSC = shader->getShaderConstHandle(ShaderGenVars::diffuseAtlasParams);
|
||||
|
|
@ -1097,6 +1098,7 @@ void ProcessedShaderMaterial::_setShaderConstants(SceneRenderState * state, cons
|
|||
|
||||
shaderConsts->setSafe( handles->mAccumTimeSC, MATMGR->getTotalTime() );
|
||||
|
||||
shaderConsts->setSafe(handles->mDampnessSC, MATMGR->getDampnessClamped());
|
||||
// If the shader constants have not been lost then
|
||||
// they contain the content from a previous render pass.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ public:
|
|||
GFXShaderConstHandle* mEyeMatSC;
|
||||
GFXShaderConstHandle* mOneOverFarplane;
|
||||
GFXShaderConstHandle* mAccumTimeSC;
|
||||
GFXShaderConstHandle* mDampnessSC;
|
||||
GFXShaderConstHandle* mMinnaertConstantSC;
|
||||
GFXShaderConstHandle* mSubSurfaceParamsSC;
|
||||
GFXShaderConstHandle* mDiffuseAtlasParamsSC;
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ protected:
|
|||
|
||||
enum
|
||||
{
|
||||
NumTextures = 8
|
||||
NumTextures = 16
|
||||
};
|
||||
|
||||
String mSamplerNames[NumTextures];
|
||||
|
|
@ -134,4 +134,4 @@ public:
|
|||
DECLARE_CONOBJECT(ShaderData);
|
||||
};
|
||||
|
||||
#endif // _SHADERTDATA_H_
|
||||
#endif // _SHADERTDATA_H_
|
||||
|
|
|
|||
|
|
@ -492,6 +492,7 @@ PostEffect::PostEffect()
|
|||
mLightDirectionSC( NULL ),
|
||||
mCameraForwardSC( NULL ),
|
||||
mAccumTimeSC( NULL ),
|
||||
mDampnessSC(NULL),
|
||||
mDeltaTimeSC( NULL ),
|
||||
mInvCameraMatSC( NULL ),
|
||||
mMatCameraToWorldSC( NULL),
|
||||
|
|
@ -785,6 +786,8 @@ void PostEffect::_setupConstants( const SceneRenderState *state )
|
|||
mCameraForwardSC = mShader->getShaderConstHandle( "$camForward" );
|
||||
|
||||
mAccumTimeSC = mShader->getShaderConstHandle( "$accumTime" );
|
||||
mDampnessSC = mShader->getShaderConstHandle("$dampness");
|
||||
|
||||
mDeltaTimeSC = mShader->getShaderConstHandle( "$deltaTime" );
|
||||
|
||||
mInvCameraMatSC = mShader->getShaderConstHandle( "$invCameraMat" );
|
||||
|
|
@ -965,7 +968,8 @@ void PostEffect::_setupConstants( const SceneRenderState *state )
|
|||
}
|
||||
mShaderConsts->setSafe( mAccumTimeSC, MATMGR->getTotalTime() );
|
||||
mShaderConsts->setSafe( mDeltaTimeSC, MATMGR->getDeltaTime() );
|
||||
|
||||
mShaderConsts->setSafe(mDampnessSC, MATMGR->getDampnessClamped());
|
||||
|
||||
// Now set all the constants that are dependent on the scene state.
|
||||
if ( state )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public:
|
|||
|
||||
enum
|
||||
{
|
||||
NumTextures = 8,
|
||||
NumTextures = 16,
|
||||
};
|
||||
|
||||
protected:
|
||||
|
|
@ -156,6 +156,7 @@ protected:
|
|||
GFXShaderConstHandle *mLightDirectionSC;
|
||||
GFXShaderConstHandle *mCameraForwardSC;
|
||||
GFXShaderConstHandle *mAccumTimeSC;
|
||||
GFXShaderConstHandle* mDampnessSC;
|
||||
GFXShaderConstHandle *mDeltaTimeSC;
|
||||
GFXShaderConstHandle *mInvCameraMatSC;
|
||||
GFXShaderConstHandle *mMatCameraToWorldSC;
|
||||
|
|
|
|||
|
|
@ -98,7 +98,9 @@ ProbeShaderConstants::ProbeShaderConstants()
|
|||
mProbeIrradianceCubemapArraySC(NULL),
|
||||
mProbeCountSC(NULL),
|
||||
mBRDFTextureMap(NULL),
|
||||
mWetnessTextureMap(NULL),
|
||||
mSkylightCubemapIdxSC(NULL),
|
||||
mSkylightDampSC(NULL),
|
||||
mWorldToObjArraySC(NULL),
|
||||
mMaxProbeDrawDistanceSC(NULL)
|
||||
{
|
||||
|
|
@ -135,8 +137,10 @@ void ProbeShaderConstants::init(GFXShader* shader)
|
|||
mProbeCountSC = shader->getShaderConstHandle(ShaderGenVars::probeCount);
|
||||
|
||||
mBRDFTextureMap = shader->getShaderConstHandle(ShaderGenVars::BRDFTextureMap);
|
||||
mWetnessTextureMap = shader->getShaderConstHandle(ShaderGenVars::WetnessTextureMap);
|
||||
|
||||
mSkylightCubemapIdxSC = shader->getShaderConstHandle(ShaderGenVars::skylightCubemapIdx);
|
||||
mSkylightCubemapIdxSC = shader->getShaderConstHandle(ShaderGenVars::skylightCubemapIdx);
|
||||
mSkylightDampSC = shader->getShaderConstHandle(ShaderGenVars::skylightDamp);
|
||||
|
||||
mMaxProbeDrawDistanceSC = shader->getShaderConstHandle(ShaderGenVars::maxProbeDrawDistance);
|
||||
|
||||
|
|
@ -145,10 +149,10 @@ void ProbeShaderConstants::init(GFXShader* shader)
|
|||
|
||||
bool ProbeShaderConstants::isValid()
|
||||
{
|
||||
if (mProbePositionArraySC->isValid() ||
|
||||
mProbeConfigDataArraySC->isValid() ||
|
||||
mRefScaleArraySC->isValid() ||
|
||||
mProbeSpecularCubemapArraySC->isValid() ||
|
||||
if (mProbePositionArraySC->isValid() &&
|
||||
mProbeConfigDataArraySC->isValid() &&
|
||||
mRefScaleArraySC->isValid() &&
|
||||
mProbeSpecularCubemapArraySC->isValid() &&
|
||||
mProbeIrradianceCubemapArraySC->isValid())
|
||||
return true;
|
||||
|
||||
|
|
@ -169,6 +173,7 @@ RenderProbeMgr::RenderProbeMgr()
|
|||
mLastConstants(nullptr),
|
||||
mHasSkylight(false),
|
||||
mSkylightCubemapIdx(-1),
|
||||
mSkylightDamp(true),
|
||||
mCubeMapCount(0),
|
||||
mUseHDRCaptures(true)
|
||||
{
|
||||
|
|
@ -197,6 +202,7 @@ RenderProbeMgr::RenderProbeMgr(RenderInstType riType, F32 renderOrder, F32 proce
|
|||
mEffectiveProbeCount = 0;
|
||||
mHasSkylight = false;
|
||||
mSkylightCubemapIdx = -1;
|
||||
mSkylightDamp = true;
|
||||
mLastConstants = nullptr;
|
||||
mMipCount = 0;
|
||||
mUseHDRCaptures = true;
|
||||
|
|
@ -236,6 +242,12 @@ bool RenderProbeMgr::onAdd()
|
|||
return false;
|
||||
}
|
||||
|
||||
String wetnessTexturePath = GFXTextureManager::getWetnessTexturePath();
|
||||
if (!mWetnessTexture.set(wetnessTexturePath, &GFXTexturePersistentProfile, "WetnessTexture"))
|
||||
{
|
||||
Con::errorf("RenderProbeMgr::onAdd: Failed to load Wetness Texture");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -306,6 +318,7 @@ void RenderProbeMgr::getBestProbes(const Point3F& objPosition, ProbeDataSet* pro
|
|||
else
|
||||
{
|
||||
probeDataSet->skyLightIdx = curEntry.mCubemapIndex;
|
||||
probeDataSet->skyLightDamp = curEntry.mProbeInfo->mCanDamp;
|
||||
mHasSkylight = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -330,13 +343,13 @@ void RenderProbeMgr::getBestProbes(const Point3F& objPosition, ProbeDataSet* pro
|
|||
probeDataSet->probeWorldToObjArray[i] = p2A;
|
||||
p2A.inverse();
|
||||
probeDataSet->refScaleArray[i] = curEntry.mProbeInfo->mProbeRefScale / (p2A.getScale()*2);
|
||||
probeDataSet->refScaleArray[i].w = curEntry.mProbeInfo->mCanDamp? 1.0 : 0.0;
|
||||
|
||||
Point3F probePos = curEntry.mProbeInfo->mObject->getPosition();
|
||||
Point3F refPos = probePos + curEntry.mProbeInfo->mProbeRefOffset * probeDataSet->refScaleArray[i].asPoint3F();
|
||||
|
||||
probeDataSet->probePositionArray[i] = Point4F(probePos.x, probePos.y, probePos.z, 0);
|
||||
probeDataSet->probeRefPositionArray[i] = Point4F(refPos.x, refPos.y, refPos.z, 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -422,7 +435,7 @@ PostEffect* RenderProbeMgr::getProbeArrayEffect()
|
|||
|
||||
mProbeArrayEffect->setShaderConst("$numProbes", (S32)0);
|
||||
mProbeArrayEffect->setShaderConst("$skylightCubemapIdx", (S32)-1);
|
||||
|
||||
mProbeArrayEffect->setShaderConst(ShaderGenVars::skylightDamp, (S32)true);
|
||||
mProbeArrayEffect->setShaderConst("$cubeMips", (float)0);
|
||||
mProbeArrayEffect->setShaderConst("$maxProbeDrawDistance", smMaxProbeDrawDistance);
|
||||
|
||||
|
|
@ -784,10 +797,14 @@ void RenderProbeMgr::_update4ProbeConsts(const SceneData& sgData,
|
|||
shaderConsts->setSafe(probeShaderConsts->mProbeConfigDataArraySC, probeConfigAlignedArray);
|
||||
}
|
||||
|
||||
if (probeShaderConsts->mBRDFTextureMap->getSamplerRegister() != -1 && mBRDFTexture.isValid())
|
||||
if (mBRDFTexture.isValid(), probeShaderConsts->mBRDFTextureMap->getSamplerRegister() != -1)
|
||||
GFX->setTexture(probeShaderConsts->mBRDFTextureMap->getSamplerRegister(), mBRDFTexture);
|
||||
|
||||
if (mWetnessTexture.isValid() && probeShaderConsts->mWetnessTextureMap->getSamplerRegister() != -1)
|
||||
GFX->setTexture(probeShaderConsts->mWetnessTextureMap->getSamplerRegister(), mWetnessTexture);
|
||||
|
||||
shaderConsts->setSafe(probeShaderConsts->mSkylightCubemapIdxSC, (float)probeSet.skyLightIdx);
|
||||
shaderConsts->setSafe(probeShaderConsts->mSkylightDampSC, (int)probeSet.skyLightDamp);
|
||||
|
||||
if (probeShaderConsts->mProbeSpecularCubemapArraySC->getSamplerRegister() != -1)
|
||||
GFX->setCubeArrayTexture(probeShaderConsts->mProbeSpecularCubemapArraySC->getSamplerRegister(), mPrefilterArray);
|
||||
|
|
@ -859,6 +876,11 @@ void RenderProbeMgr::render( SceneRenderState *state )
|
|||
|
||||
String probeCapturing = Con::getVariable("$Probes::Capturing", "0");
|
||||
mProbeArrayEffect->setShaderMacro("CAPTURING", probeCapturing);
|
||||
|
||||
mProbeArrayEffect->setTexture(3, mBRDFTexture);
|
||||
mProbeArrayEffect->setCubemapArrayTexture(4, mPrefilterArray);
|
||||
mProbeArrayEffect->setCubemapArrayTexture(5, mIrradianceArray);
|
||||
mProbeArrayEffect->setTexture(6, mWetnessTexture);
|
||||
//ssao mask
|
||||
if (AdvancedLightBinManager::smUseSSAOMask)
|
||||
{
|
||||
|
|
@ -868,20 +890,16 @@ void RenderProbeMgr::render( SceneRenderState *state )
|
|||
if (pTexObj)
|
||||
{
|
||||
mProbeArrayEffect->setShaderMacro("USE_SSAO_MASK");
|
||||
mProbeArrayEffect->setTexture(6, pTexObj);
|
||||
mProbeArrayEffect->setTexture(7, pTexObj);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mProbeArrayEffect->setTexture(6, GFXTexHandle(NULL));
|
||||
mProbeArrayEffect->setTexture(7, GFXTexHandle(NULL));
|
||||
}
|
||||
|
||||
mProbeArrayEffect->setTexture(3, mBRDFTexture);
|
||||
mProbeArrayEffect->setCubemapArrayTexture(4, mPrefilterArray);
|
||||
mProbeArrayEffect->setCubemapArrayTexture(5, mIrradianceArray);
|
||||
|
||||
mProbeArrayEffect->setShaderConst("$numProbes", (S32)mProbeData.effectiveProbeCount);
|
||||
mProbeArrayEffect->setShaderConst("$skylightCubemapIdx", (S32)mProbeData.skyLightIdx);
|
||||
mProbeArrayEffect->setShaderConst(ShaderGenVars::skylightDamp, mProbeData.skyLightDamp);
|
||||
|
||||
mProbeArrayEffect->setShaderConst("$cubeMips", (float)mPrefilterArray->getMipMapLevels());
|
||||
|
||||
|
|
|
|||
|
|
@ -98,8 +98,9 @@ struct ProbeShaderConstants
|
|||
GFXShaderConstHandle *mProbeCountSC;
|
||||
|
||||
GFXShaderConstHandle *mBRDFTextureMap;
|
||||
|
||||
GFXShaderConstHandle* mWetnessTextureMap;
|
||||
GFXShaderConstHandle *mSkylightCubemapIdxSC;
|
||||
GFXShaderConstHandle* mSkylightDampSC;
|
||||
|
||||
GFXShaderConstHandle* mMaxProbeDrawDistanceSC;
|
||||
|
||||
|
|
@ -127,9 +128,8 @@ struct ProbeDataSet
|
|||
Vector<Point4F> probeConfigArray;
|
||||
|
||||
Vector<MatrixF> probeWorldToObjArray;
|
||||
|
||||
S32 skyLightIdx;
|
||||
|
||||
bool skyLightDamp;
|
||||
U32 effectiveProbeCount;
|
||||
U32 maxProbeCount;
|
||||
|
||||
|
|
@ -141,10 +141,10 @@ struct ProbeDataSet
|
|||
probeConfigArray.setSize(0);
|
||||
|
||||
probeWorldToObjArray.setSize(0);
|
||||
|
||||
skyLightIdx = -1;
|
||||
effectiveProbeCount = 0;
|
||||
maxProbeCount = 0;
|
||||
skyLightDamp = true;
|
||||
}
|
||||
|
||||
ProbeDataSet(U32 _maxProbeCount)
|
||||
|
|
@ -212,7 +212,7 @@ private:
|
|||
/// If we have a skylight, what's the array pair index for it?
|
||||
/// </summary>
|
||||
S32 mSkylightCubemapIdx;
|
||||
|
||||
bool mSkylightDamp;
|
||||
/// <summary>
|
||||
/// The 'effective' probe count. This tracks the number of probes that are actually going to be rendered
|
||||
/// </summary>
|
||||
|
|
@ -279,7 +279,8 @@ private:
|
|||
/// The BRDF texture used in PBR math calculations
|
||||
/// </summary>
|
||||
GFXTexHandle mBRDFTexture;
|
||||
|
||||
GFXTexHandle mWetnessTexture;
|
||||
|
||||
/// <summary>
|
||||
/// Processed best probe selection list of the current frame when rendering in deferred mode.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -2982,6 +2982,10 @@ void ReflectionProbeFeatGLSL::processPix(Vector<ShaderComponent*>& componentList
|
|||
skylightCubemapIdx->uniform = true;
|
||||
skylightCubemapIdx->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
Var* SkylightDamp = new Var("SkylightDamp", "int");
|
||||
SkylightDamp->uniform = true;
|
||||
SkylightDamp->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
Var * inProbePosArray = new Var("inProbePosArray", "vec4");
|
||||
inProbePosArray->arraySize = MAX_FORWARD_PROBES;
|
||||
inProbePosArray->uniform = true;
|
||||
|
|
@ -3025,6 +3029,14 @@ void ReflectionProbeFeatGLSL::processPix(Vector<ShaderComponent*>& componentList
|
|||
irradianceCubemapAR->sampler = true;
|
||||
irradianceCubemapAR->constNum = Var::getTexUnitNum();
|
||||
|
||||
// create texture var
|
||||
Var* WetnessTexture = new Var;
|
||||
WetnessTexture->setType("sampler2D");
|
||||
WetnessTexture->setName("WetnessTexture");
|
||||
WetnessTexture->uniform = true;
|
||||
WetnessTexture->sampler = true;
|
||||
WetnessTexture->constNum = Var::getTexUnitNum(); // used as texture unit num here
|
||||
|
||||
Var* surface = getSurface(componentList, meta, fd);
|
||||
|
||||
if (!surface)
|
||||
|
|
@ -3051,14 +3063,29 @@ void ReflectionProbeFeatGLSL::processPix(Vector<ShaderComponent*>& componentList
|
|||
eyePos->uniform = true;
|
||||
eyePos->constSortPos = cspPass;
|
||||
}
|
||||
|
||||
|
||||
Var* accumTime = (Var*)LangElement::find("accumTime");
|
||||
if (!accumTime)
|
||||
{
|
||||
accumTime = new Var("accumTime", "float");
|
||||
accumTime->uniform = true;
|
||||
accumTime->constSortPos = cspPass;
|
||||
}
|
||||
Var* dampness = (Var*)LangElement::find("dampness");
|
||||
if (!dampness)
|
||||
{
|
||||
dampness = new Var("dampness", "float");
|
||||
dampness->uniform = true;
|
||||
dampness->constSortPos = cspPass;
|
||||
}
|
||||
|
||||
//Reflection vec
|
||||
String computeForwardProbes = String(" @ = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t");
|
||||
computeForwardProbes += String("@,@,\r\n\t\t");
|
||||
computeForwardProbes += String("@,@,@,@,@,@,\r\n\t\t");
|
||||
computeForwardProbes += String("@,@).rgb; \r\n");
|
||||
|
||||
meta->addStatement(new GenOp(computeForwardProbes.c_str(), new DecOp(ibl), surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, refScaleArray, inRefPosArray, eyePos,
|
||||
skylightCubemapIdx, BRDFTexture,
|
||||
skylightCubemapIdx, SkylightDamp, BRDFTexture, WetnessTexture, accumTime, dampness,
|
||||
irradianceCubemapAR, specularCubemapAR));
|
||||
|
||||
Var *ambient = (Var *)LangElement::find("ambient");
|
||||
|
|
@ -3078,8 +3105,8 @@ ShaderFeature::Resources ReflectionProbeFeatGLSL::getResources(const MaterialFea
|
|||
{
|
||||
Resources res;
|
||||
|
||||
res.numTex = 3;
|
||||
res.numTexReg = 3;
|
||||
res.numTex = 4;
|
||||
res.numTexReg = 4;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
@ -3098,5 +3125,7 @@ void ReflectionProbeFeatGLSL::setTexData(Material::StageData& stageDat,
|
|||
passData.mTexType[texIndex++] = Material::SGCube;
|
||||
passData.mSamplerNames[texIndex] = "IrradianceCubemapAR";
|
||||
passData.mTexType[texIndex++] = Material::SGCube;
|
||||
passData.mSamplerNames[texIndex] = "WetnessTexture";
|
||||
passData.mTexType[texIndex++] = Material::Standard;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3060,6 +3060,10 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
|
|||
skylightCubemapIdx->uniform = true;
|
||||
skylightCubemapIdx->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
Var* SkylightDamp = new Var("SkylightDamp", "int");
|
||||
SkylightDamp->uniform = true;
|
||||
SkylightDamp->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
Var *inProbePosArray = new Var("inProbePosArray", "float4");
|
||||
inProbePosArray->arraySize = MAX_FORWARD_PROBES;
|
||||
inProbePosArray->uniform = true;
|
||||
|
|
@ -3115,6 +3119,16 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
|
|||
irradianceCubemapARTex->texture = true;
|
||||
irradianceCubemapARTex->constNum = irradianceCubemapAR->constNum;
|
||||
|
||||
Var* WetnessTexture = new Var("WetnessTexture", "SamplerState");
|
||||
WetnessTexture->uniform = true;
|
||||
WetnessTexture->sampler = true;
|
||||
WetnessTexture->constNum = Var::getTexUnitNum(); // used as texture unit num here
|
||||
|
||||
Var* WetnessTextureTex = new Var("texture_WetnessTexture", "Texture2D");
|
||||
WetnessTextureTex->uniform = true;
|
||||
WetnessTextureTex->texture = true;
|
||||
WetnessTextureTex->constNum = WetnessTexture->constNum;
|
||||
|
||||
Var* surface = getSurface(componentList, meta, fd);
|
||||
|
||||
if (!surface)
|
||||
|
|
@ -3142,12 +3156,28 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
|
|||
eyePos->constSortPos = cspPass;
|
||||
}
|
||||
|
||||
Var* accumTime = (Var*)LangElement::find("accumTime");
|
||||
if (!accumTime)
|
||||
{
|
||||
accumTime = new Var("accumTime", "float");
|
||||
accumTime->uniform = true;
|
||||
accumTime->constSortPos = cspPass;
|
||||
}
|
||||
|
||||
Var* dampness = (Var*)LangElement::find("dampness");
|
||||
if (!dampness)
|
||||
{
|
||||
dampness = new Var("dampness", "float");
|
||||
dampness->uniform = true;
|
||||
dampness->constSortPos = cspPass;
|
||||
}
|
||||
|
||||
String computeForwardProbes = String(" @ = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t");
|
||||
computeForwardProbes += String("@,TORQUE_SAMPLER2D_MAKEARG(@),\r\n\t\t");
|
||||
computeForwardProbes += String("@,@,TORQUE_SAMPLER2D_MAKEARG(@),TORQUE_SAMPLER2D_MAKEARG(@), @, @,\r\n\t\t");
|
||||
computeForwardProbes += String("TORQUE_SAMPLERCUBEARRAY_MAKEARG(@),TORQUE_SAMPLERCUBEARRAY_MAKEARG(@)).rgb; \r\n");
|
||||
|
||||
meta->addStatement(new GenOp(computeForwardProbes.c_str(), new DecOp(ibl), surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, refScaleArray, inRefPosArray, eyePos,
|
||||
skylightCubemapIdx, BRDFTexture,
|
||||
skylightCubemapIdx, SkylightDamp, BRDFTexture, WetnessTexture, accumTime, dampness,
|
||||
irradianceCubemapAR, specularCubemapAR));
|
||||
|
||||
Var *ambient = (Var *)LangElement::find("ambient");
|
||||
|
|
@ -3167,8 +3197,8 @@ ShaderFeature::Resources ReflectionProbeFeatHLSL::getResources(const MaterialFea
|
|||
{
|
||||
Resources res;
|
||||
|
||||
res.numTex = 3;
|
||||
res.numTexReg = 3;
|
||||
res.numTex = 4;
|
||||
res.numTexReg = 4;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
@ -3187,5 +3217,7 @@ void ReflectionProbeFeatHLSL::setTexData(Material::StageData &stageDat,
|
|||
passData.mTexType[texIndex++] = Material::SGCube;
|
||||
passData.mSamplerNames[texIndex] = "IrradianceCubemapAR";
|
||||
passData.mTexType[texIndex++] = Material::SGCube;
|
||||
passData.mSamplerNames[texIndex] = "WetnessTexture";
|
||||
passData.mTexType[texIndex++] = Material::Standard;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ const String ShaderGenVars::colorMultiply("$colorMultiply");
|
|||
const String ShaderGenVars::alphaTestValue("$alphaTestValue");
|
||||
const String ShaderGenVars::texMat("$texMat");
|
||||
const String ShaderGenVars::accumTime("$accumTime");
|
||||
const String ShaderGenVars::dampness("$dampness");
|
||||
const String ShaderGenVars::minnaertConstant("$minnaertConstant");
|
||||
const String ShaderGenVars::subSurfaceParams("$subSurfaceParams");
|
||||
|
||||
|
|
@ -90,11 +91,13 @@ const String ShaderGenVars::irradianceCubemapAR("$IrradianceCubemapAR");
|
|||
const String ShaderGenVars::probeCount("$inNumProbes");
|
||||
|
||||
const String ShaderGenVars::BRDFTextureMap("$BRDFTexture");
|
||||
const String ShaderGenVars::WetnessTextureMap("$WetnessTexture");
|
||||
|
||||
const String ShaderGenVars::maxProbeDrawDistance("$maxProbeDrawDistance");
|
||||
|
||||
//Skylight
|
||||
const String ShaderGenVars::skylightCubemapIdx("$inSkylightCubemapIdx");
|
||||
const String ShaderGenVars::skylightDamp("$SkylightDamp");
|
||||
|
||||
// These are ignored by the D3D layers.
|
||||
const String ShaderGenVars::fogMap("$fogMap");
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ struct ShaderGenVars
|
|||
const static String alphaTestValue;
|
||||
const static String texMat;
|
||||
const static String accumTime;
|
||||
const static String dampness;
|
||||
const static String minnaertConstant;
|
||||
const static String subSurfaceParams;
|
||||
|
||||
|
|
@ -101,11 +102,12 @@ struct ShaderGenVars
|
|||
const static String probeCount;
|
||||
|
||||
const static String BRDFTextureMap;
|
||||
|
||||
const static String WetnessTextureMap;
|
||||
const static String maxProbeDrawDistance;
|
||||
|
||||
//Skylight
|
||||
const static String skylightCubemapIdx;
|
||||
const static String skylightDamp;
|
||||
|
||||
// Textures
|
||||
const static String fogMap;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue