mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-29 16:25:42 +00:00
Merge branch 'alpha40Probework' of https://github.com/Azaezel/Torque3D into Preview4_0
This commit is contained in:
commit
a2aa241c92
8 changed files with 59 additions and 66 deletions
|
|
@ -124,8 +124,8 @@ ProbeShaderConstants::ProbeShaderConstants()
|
||||||
mShader(NULL),
|
mShader(NULL),
|
||||||
mProbePositionSC(NULL),
|
mProbePositionSC(NULL),
|
||||||
mProbeRefPosSC(NULL),
|
mProbeRefPosSC(NULL),
|
||||||
mProbeBoxMinSC(NULL),
|
mRefBoxMinSC(NULL),
|
||||||
mProbeBoxMaxSC(NULL),
|
mRefBoxMaxSC(NULL),
|
||||||
mProbeConfigDataSC(NULL),
|
mProbeConfigDataSC(NULL),
|
||||||
mProbeSpecularCubemapSC(NULL),
|
mProbeSpecularCubemapSC(NULL),
|
||||||
mProbeIrradianceCubemapSC(NULL),
|
mProbeIrradianceCubemapSC(NULL),
|
||||||
|
|
@ -159,8 +159,8 @@ void ProbeShaderConstants::init(GFXShader* shader)
|
||||||
//Reflection Probes
|
//Reflection Probes
|
||||||
mProbePositionSC = shader->getShaderConstHandle(ShaderGenVars::probePosition);
|
mProbePositionSC = shader->getShaderConstHandle(ShaderGenVars::probePosition);
|
||||||
mProbeRefPosSC = shader->getShaderConstHandle(ShaderGenVars::probeRefPos);
|
mProbeRefPosSC = shader->getShaderConstHandle(ShaderGenVars::probeRefPos);
|
||||||
mProbeBoxMinSC = shader->getShaderConstHandle(ShaderGenVars::probeBoxMin);
|
mRefBoxMinSC = shader->getShaderConstHandle(ShaderGenVars::refBoxMin);
|
||||||
mProbeBoxMaxSC = shader->getShaderConstHandle(ShaderGenVars::probeBoxMax);
|
mRefBoxMaxSC = shader->getShaderConstHandle(ShaderGenVars::refBoxMax);
|
||||||
mWorldToObjArraySC = shader->getShaderConstHandle(ShaderGenVars::worldToObjArray);
|
mWorldToObjArraySC = shader->getShaderConstHandle(ShaderGenVars::worldToObjArray);
|
||||||
mProbeConfigDataSC = shader->getShaderConstHandle(ShaderGenVars::probeConfigData);
|
mProbeConfigDataSC = shader->getShaderConstHandle(ShaderGenVars::probeConfigData);
|
||||||
mProbeSpecularCubemapSC = shader->getShaderConstHandle(ShaderGenVars::specularCubemapAR);
|
mProbeSpecularCubemapSC = shader->getShaderConstHandle(ShaderGenVars::specularCubemapAR);
|
||||||
|
|
@ -178,8 +178,8 @@ bool ProbeShaderConstants::isValid()
|
||||||
{
|
{
|
||||||
if (mProbePositionSC->isValid() ||
|
if (mProbePositionSC->isValid() ||
|
||||||
mProbeConfigDataSC->isValid() ||
|
mProbeConfigDataSC->isValid() ||
|
||||||
mProbeBoxMinSC->isValid() ||
|
mRefBoxMinSC->isValid() ||
|
||||||
mProbeBoxMaxSC->isValid() ||
|
mRefBoxMaxSC->isValid() ||
|
||||||
mProbeSpecularCubemapSC->isValid() ||
|
mProbeSpecularCubemapSC->isValid() ||
|
||||||
mProbeIrradianceCubemapSC->isValid())
|
mProbeIrradianceCubemapSC->isValid())
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -422,16 +422,16 @@ void RenderProbeMgr::_setupStaticParameters()
|
||||||
probePositionsData.setSize(MAXPROBECOUNT);
|
probePositionsData.setSize(MAXPROBECOUNT);
|
||||||
probeRefPositionsData.setSize(MAXPROBECOUNT);
|
probeRefPositionsData.setSize(MAXPROBECOUNT);
|
||||||
probeWorldToObjData.setSize(MAXPROBECOUNT);
|
probeWorldToObjData.setSize(MAXPROBECOUNT);
|
||||||
probeBBMinData.setSize(MAXPROBECOUNT);
|
refBoxMinData.setSize(MAXPROBECOUNT);
|
||||||
probeBBMaxData.setSize(MAXPROBECOUNT);
|
refBoxMaxData.setSize(MAXPROBECOUNT);
|
||||||
probeConfigData.setSize(MAXPROBECOUNT);
|
probeConfigData.setSize(MAXPROBECOUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
probePositionsData.fill(Point4F::Zero);
|
probePositionsData.fill(Point4F::Zero);
|
||||||
probeRefPositionsData.fill(Point4F::Zero);
|
probeRefPositionsData.fill(Point4F::Zero);
|
||||||
probeWorldToObjData.fill(MatrixF::Identity);
|
probeWorldToObjData.fill(MatrixF::Identity);
|
||||||
probeBBMinData.fill(Point4F::Zero);
|
refBoxMinData.fill(Point4F::Zero);
|
||||||
probeBBMaxData.fill(Point4F::Zero);
|
refBoxMaxData.fill(Point4F::Zero);
|
||||||
probeConfigData.fill(Point4F(-1,0,0,0));
|
probeConfigData.fill(Point4F(-1,0,0,0));
|
||||||
|
|
||||||
for (U32 i = 0; i < probeCount; i++)
|
for (U32 i = 0; i < probeCount; i++)
|
||||||
|
|
@ -461,8 +461,8 @@ void RenderProbeMgr::_setupStaticParameters()
|
||||||
probeWorldToObjData[mEffectiveProbeCount] = curEntry.getTransform();
|
probeWorldToObjData[mEffectiveProbeCount] = curEntry.getTransform();
|
||||||
Point3F bbMin = refPos - curEntry.mProbeRefScale/2 * curEntry.getTransform().getScale();
|
Point3F bbMin = refPos - curEntry.mProbeRefScale/2 * curEntry.getTransform().getScale();
|
||||||
Point3F bbMax = refPos + curEntry.mProbeRefScale/2 * curEntry.getTransform().getScale();
|
Point3F bbMax = refPos + curEntry.mProbeRefScale/2 * curEntry.getTransform().getScale();
|
||||||
probeBBMinData[mEffectiveProbeCount] = Point4F(bbMin.x, bbMin.y, bbMin.z, 0);
|
refBoxMinData[mEffectiveProbeCount] = Point4F(bbMin.x, bbMin.y, bbMin.z, 0);
|
||||||
probeBBMaxData[mEffectiveProbeCount] = Point4F(bbMax.x, bbMax.y, bbMax.z, 0);
|
refBoxMaxData[mEffectiveProbeCount] = Point4F(bbMax.x, bbMax.y, bbMax.z, 0);
|
||||||
|
|
||||||
probeConfigData[mEffectiveProbeCount] = Point4F(curEntry.mProbeShapeType,
|
probeConfigData[mEffectiveProbeCount] = Point4F(curEntry.mProbeShapeType,
|
||||||
curEntry.mRadius,
|
curEntry.mRadius,
|
||||||
|
|
@ -561,8 +561,8 @@ void RenderProbeMgr::_update4ProbeConsts(const SceneData &sgData,
|
||||||
const U32 MAX_FORWARD_PROBES = 4;
|
const U32 MAX_FORWARD_PROBES = 4;
|
||||||
|
|
||||||
static AlignedArray<Point4F> probePositionArray(MAX_FORWARD_PROBES, sizeof(Point4F));
|
static AlignedArray<Point4F> probePositionArray(MAX_FORWARD_PROBES, sizeof(Point4F));
|
||||||
static AlignedArray<Point4F> probeBoxMinArray(MAX_FORWARD_PROBES, sizeof(Point4F));
|
static AlignedArray<Point4F> refBoxMinArray(MAX_FORWARD_PROBES, sizeof(Point4F));
|
||||||
static AlignedArray<Point4F> probeBoxMaxArray(MAX_FORWARD_PROBES, sizeof(Point4F));
|
static AlignedArray<Point4F> refBoxMaxArray(MAX_FORWARD_PROBES, sizeof(Point4F));
|
||||||
static AlignedArray<Point4F> probeRefPositionArray(MAX_FORWARD_PROBES, sizeof(Point4F));
|
static AlignedArray<Point4F> probeRefPositionArray(MAX_FORWARD_PROBES, sizeof(Point4F));
|
||||||
static AlignedArray<Point4F> probeConfigArray(MAX_FORWARD_PROBES, sizeof(Point4F));
|
static AlignedArray<Point4F> probeConfigArray(MAX_FORWARD_PROBES, sizeof(Point4F));
|
||||||
|
|
||||||
|
|
@ -574,8 +574,8 @@ void RenderProbeMgr::_update4ProbeConsts(const SceneData &sgData,
|
||||||
// Need to clear the buffers so that we don't leak
|
// Need to clear the buffers so that we don't leak
|
||||||
// lights from previous passes or have NaNs.
|
// lights from previous passes or have NaNs.
|
||||||
dMemset(probePositionArray.getBuffer(), 0, probePositionArray.getBufferSize());
|
dMemset(probePositionArray.getBuffer(), 0, probePositionArray.getBufferSize());
|
||||||
dMemset(probeBoxMinArray.getBuffer(), 0, probeBoxMinArray.getBufferSize());
|
dMemset(refBoxMinArray.getBuffer(), 0, refBoxMinArray.getBufferSize());
|
||||||
dMemset(probeBoxMaxArray.getBuffer(), 0, probeBoxMaxArray.getBufferSize());
|
dMemset(refBoxMaxArray.getBuffer(), 0, refBoxMaxArray.getBufferSize());
|
||||||
dMemset(probeRefPositionArray.getBuffer(), 0, probeRefPositionArray.getBufferSize());
|
dMemset(probeRefPositionArray.getBuffer(), 0, probeRefPositionArray.getBufferSize());
|
||||||
dMemset(probeConfigArray.getBuffer(), 0, probeConfigArray.getBufferSize());
|
dMemset(probeConfigArray.getBuffer(), 0, probeConfigArray.getBufferSize());
|
||||||
|
|
||||||
|
|
@ -632,15 +632,12 @@ void RenderProbeMgr::_update4ProbeConsts(const SceneData &sgData,
|
||||||
probeRefPositionArray[effectiveProbeCount] = curEntry.mProbeRefOffset;
|
probeRefPositionArray[effectiveProbeCount] = curEntry.mProbeRefOffset;
|
||||||
probeWorldToObjArray[effectiveProbeCount] = curEntry.getTransform();
|
probeWorldToObjArray[effectiveProbeCount] = curEntry.getTransform();
|
||||||
|
|
||||||
/*
|
|
||||||
Point3F refPos = curEntry.getPosition() + curEntry.mProbeRefOffset;
|
Point3F refPos = curEntry.getPosition() + curEntry.mProbeRefOffset;
|
||||||
Point3F bbMin = refPos - curEntry.mProbeRefScale / 2 * curEntry.getTransform().getScale();
|
Point3F refBoxMin = refPos - curEntry.mProbeRefScale * curEntry.getTransform().getScale();
|
||||||
Point3F bbMax = refPos + curEntry.mProbeRefScale / 2 * curEntry.getTransform().getScale();
|
Point3F refBoxMax = refPos + curEntry.mProbeRefScale * curEntry.getTransform().getScale();
|
||||||
|
|
||||||
probeBoxMinArray[mEffectiveProbeCount] = Point4F(bbMin.x, bbMin.y, bbMin.z, 0);
|
refBoxMinArray[mEffectiveProbeCount] = Point4F(refBoxMin.x, refBoxMin.y, refBoxMin.z, 0);
|
||||||
probeBoxMaxArray[mEffectiveProbeCount] = Point4F(bbMax.x, bbMax.y, bbMax.z, 0);*/
|
refBoxMaxArray[mEffectiveProbeCount] = Point4F(refBoxMax.x, refBoxMax.y, refBoxMax.z, 0);
|
||||||
probeBoxMinArray[effectiveProbeCount] = curEntry.mBounds.minExtents;
|
|
||||||
probeBoxMaxArray[effectiveProbeCount] = curEntry.mBounds.maxExtents;
|
|
||||||
probeConfigArray[effectiveProbeCount] = Point4F(curEntry.mProbeShapeType,
|
probeConfigArray[effectiveProbeCount] = Point4F(curEntry.mProbeShapeType,
|
||||||
curEntry.mRadius,
|
curEntry.mRadius,
|
||||||
curEntry.mAtten,
|
curEntry.mAtten,
|
||||||
|
|
@ -657,8 +654,8 @@ void RenderProbeMgr::_update4ProbeConsts(const SceneData &sgData,
|
||||||
if(probeShaderConsts->isValid())
|
if(probeShaderConsts->isValid())
|
||||||
shaderConsts->set(probeShaderConsts->mWorldToObjArraySC, probeWorldToObjArray.address(), effectiveProbeCount, GFXSCT_Float4x4);
|
shaderConsts->set(probeShaderConsts->mWorldToObjArraySC, probeWorldToObjArray.address(), effectiveProbeCount, GFXSCT_Float4x4);
|
||||||
|
|
||||||
shaderConsts->setSafe(probeShaderConsts->mProbeBoxMinSC, probeBoxMinArray);
|
shaderConsts->setSafe(probeShaderConsts->mRefBoxMinSC, refBoxMinArray);
|
||||||
shaderConsts->setSafe(probeShaderConsts->mProbeBoxMaxSC, probeBoxMaxArray);
|
shaderConsts->setSafe(probeShaderConsts->mRefBoxMaxSC, refBoxMaxArray);
|
||||||
shaderConsts->setSafe(probeShaderConsts->mProbeConfigDataSC, probeConfigArray);
|
shaderConsts->setSafe(probeShaderConsts->mProbeConfigDataSC, probeConfigArray);
|
||||||
|
|
||||||
shaderConsts->setSafe(probeShaderConsts->mSkylightCubemapIdxSC, (float)skyLightIdx);
|
shaderConsts->setSafe(probeShaderConsts->mSkylightCubemapIdxSC, (float)skyLightIdx);
|
||||||
|
|
@ -789,8 +786,8 @@ void RenderProbeMgr::render( SceneRenderState *state )
|
||||||
mProbeArrayEffect->setShaderConst("$inProbePosArray", probePositionsData);
|
mProbeArrayEffect->setShaderConst("$inProbePosArray", probePositionsData);
|
||||||
mProbeArrayEffect->setShaderConst("$inRefPosArray", probeRefPositionsData);
|
mProbeArrayEffect->setShaderConst("$inRefPosArray", probeRefPositionsData);
|
||||||
mProbeArrayEffect->setShaderConst("$worldToObjArray", probeWorldToObjData);
|
mProbeArrayEffect->setShaderConst("$worldToObjArray", probeWorldToObjData);
|
||||||
mProbeArrayEffect->setShaderConst("$bbMinArray", probeBBMinData);
|
mProbeArrayEffect->setShaderConst("$refBoxMinArray", refBoxMinData);
|
||||||
mProbeArrayEffect->setShaderConst("$bbMaxArray", probeBBMaxData);
|
mProbeArrayEffect->setShaderConst("$refBoxMaxArray", refBoxMaxData);
|
||||||
mProbeArrayEffect->setShaderConst("$probeConfigData", probeConfigData);
|
mProbeArrayEffect->setShaderConst("$probeConfigData", probeConfigData);
|
||||||
|
|
||||||
// Make sure the effect is gonna render.
|
// Make sure the effect is gonna render.
|
||||||
|
|
|
||||||
|
|
@ -141,8 +141,8 @@ struct ProbeShaderConstants
|
||||||
//Reflection Probes
|
//Reflection Probes
|
||||||
GFXShaderConstHandle *mProbePositionSC;
|
GFXShaderConstHandle *mProbePositionSC;
|
||||||
GFXShaderConstHandle *mProbeRefPosSC;
|
GFXShaderConstHandle *mProbeRefPosSC;
|
||||||
GFXShaderConstHandle *mProbeBoxMinSC;
|
GFXShaderConstHandle *mRefBoxMinSC;
|
||||||
GFXShaderConstHandle *mProbeBoxMaxSC;
|
GFXShaderConstHandle *mRefBoxMaxSC;
|
||||||
GFXShaderConstHandle *mWorldToObjArraySC;
|
GFXShaderConstHandle *mWorldToObjArraySC;
|
||||||
GFXShaderConstHandle *mProbeConfigDataSC;
|
GFXShaderConstHandle *mProbeConfigDataSC;
|
||||||
GFXShaderConstHandle *mProbeSpecularCubemapSC;
|
GFXShaderConstHandle *mProbeSpecularCubemapSC;
|
||||||
|
|
@ -194,16 +194,16 @@ class RenderProbeMgr : public RenderBinManager
|
||||||
Vector<Point4F> probePositionsData;
|
Vector<Point4F> probePositionsData;
|
||||||
Vector<Point4F> probeRefPositionsData;
|
Vector<Point4F> probeRefPositionsData;
|
||||||
Vector<MatrixF> probeWorldToObjData;
|
Vector<MatrixF> probeWorldToObjData;
|
||||||
Vector<Point4F> probeBBMinData;
|
Vector<Point4F> refBoxMinData;
|
||||||
Vector<Point4F> probeBBMaxData;
|
Vector<Point4F> refBoxMaxData;
|
||||||
Vector<Point4F> probeConfigData;
|
Vector<Point4F> probeConfigData;
|
||||||
|
|
||||||
bool mHasSkylight;
|
bool mHasSkylight;
|
||||||
S32 mSkylightCubemapIdx;
|
S32 mSkylightCubemapIdx;
|
||||||
|
|
||||||
AlignedArray<Point4F> mProbePositions;
|
AlignedArray<Point4F> mProbePositions;
|
||||||
AlignedArray<Point4F> mProbeBBMin;
|
AlignedArray<Point4F> mRefBoxMin;
|
||||||
AlignedArray<Point4F> mProbeBBMax;
|
AlignedArray<Point4F> mRefBoxMax;
|
||||||
AlignedArray<float> mProbeUseSphereMode;
|
AlignedArray<float> mProbeUseSphereMode;
|
||||||
AlignedArray<float> mProbeRadius;
|
AlignedArray<float> mProbeRadius;
|
||||||
AlignedArray<float> mProbeAttenuation;
|
AlignedArray<float> mProbeAttenuation;
|
||||||
|
|
|
||||||
|
|
@ -2927,15 +2927,15 @@ void ReflectionProbeFeatGLSL::processPix(Vector<ShaderComponent*>& componentList
|
||||||
inRefPosArray->uniform = true;
|
inRefPosArray->uniform = true;
|
||||||
inRefPosArray->constSortPos = cspPotentialPrimitive;
|
inRefPosArray->constSortPos = cspPotentialPrimitive;
|
||||||
|
|
||||||
Var * bbMinArray = new Var("inProbeBoxMin", "vec4");
|
Var * refBoxMinArray = new Var("inRefBoxMin", "vec4");
|
||||||
bbMinArray->arraySize = MAX_FORWARD_PROBES;
|
refBoxMinArray->arraySize = MAX_FORWARD_PROBES;
|
||||||
bbMinArray->uniform = true;
|
refBoxMinArray->uniform = true;
|
||||||
bbMinArray->constSortPos = cspPotentialPrimitive;
|
refBoxMinArray->constSortPos = cspPotentialPrimitive;
|
||||||
|
|
||||||
Var * bbMaxArray = new Var("inProbeBoxMax", "vec4");
|
Var * refBoxMaxArray = new Var("inRefBoxMax", "vec4");
|
||||||
bbMaxArray->arraySize = MAX_FORWARD_PROBES;
|
refBoxMaxArray->arraySize = MAX_FORWARD_PROBES;
|
||||||
bbMaxArray->uniform = true;
|
refBoxMaxArray->uniform = true;
|
||||||
bbMaxArray->constSortPos = cspPotentialPrimitive;
|
refBoxMaxArray->constSortPos = cspPotentialPrimitive;
|
||||||
|
|
||||||
Var * probeConfigData = new Var("probeConfigData", "vec4");
|
Var * probeConfigData = new Var("probeConfigData", "vec4");
|
||||||
probeConfigData->arraySize = MAX_FORWARD_PROBES;
|
probeConfigData->arraySize = MAX_FORWARD_PROBES;
|
||||||
|
|
@ -3043,7 +3043,7 @@ void ReflectionProbeFeatGLSL::processPix(Vector<ShaderComponent*>& componentList
|
||||||
computeForwardProbes += String("@, @, \r\n\t\t");
|
computeForwardProbes += String("@, @, \r\n\t\t");
|
||||||
computeForwardProbes += String("@,@).rgb; \r\n");
|
computeForwardProbes += String("@,@).rgb; \r\n");
|
||||||
|
|
||||||
meta->addStatement(new GenOp(computeForwardProbes.c_str(), albedo, surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, bbMinArray, bbMaxArray, inRefPosArray,
|
meta->addStatement(new GenOp(computeForwardProbes.c_str(), albedo, surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, refBoxMinArray, refBoxMaxArray, inRefPosArray,
|
||||||
hasSkylight, BRDFTexture,
|
hasSkylight, BRDFTexture,
|
||||||
skylightIrradMap, skylightSpecularMap,
|
skylightIrradMap, skylightSpecularMap,
|
||||||
irradianceCubemapAR, specularCubemapAR));
|
irradianceCubemapAR, specularCubemapAR));
|
||||||
|
|
|
||||||
|
|
@ -3002,15 +3002,15 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
|
||||||
inRefPosArray->uniform = true;
|
inRefPosArray->uniform = true;
|
||||||
inRefPosArray->constSortPos = cspPotentialPrimitive;
|
inRefPosArray->constSortPos = cspPotentialPrimitive;
|
||||||
|
|
||||||
Var *bbMinArray = new Var("inProbeBoxMin", "float4");
|
Var * refBoxMinArray = new Var("inRefBoxMin", "float4");
|
||||||
bbMinArray->arraySize = MAX_FORWARD_PROBES;
|
refBoxMinArray->arraySize = MAX_FORWARD_PROBES;
|
||||||
bbMinArray->uniform = true;
|
refBoxMinArray->uniform = true;
|
||||||
bbMinArray->constSortPos = cspPotentialPrimitive;
|
refBoxMinArray->constSortPos = cspPotentialPrimitive;
|
||||||
|
|
||||||
Var *bbMaxArray = new Var("inProbeBoxMax", "float4");
|
Var * refBoxMaxArray = new Var("inRefBoxMax", "float4");
|
||||||
bbMaxArray->arraySize = MAX_FORWARD_PROBES;
|
refBoxMaxArray->arraySize = MAX_FORWARD_PROBES;
|
||||||
bbMaxArray->uniform = true;
|
refBoxMaxArray->uniform = true;
|
||||||
bbMaxArray->constSortPos = cspPotentialPrimitive;
|
refBoxMaxArray->constSortPos = cspPotentialPrimitive;
|
||||||
|
|
||||||
Var *probeConfigData = new Var("probeConfigData", "float4");
|
Var *probeConfigData = new Var("probeConfigData", "float4");
|
||||||
probeConfigData->arraySize = MAX_FORWARD_PROBES;
|
probeConfigData->arraySize = MAX_FORWARD_PROBES;
|
||||||
|
|
@ -3112,7 +3112,7 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
|
||||||
computeForwardProbes += String::String("@,TORQUE_SAMPLER2D_MAKEARG(@),\r\n\t\t");
|
computeForwardProbes += String::String("@,TORQUE_SAMPLER2D_MAKEARG(@),\r\n\t\t");
|
||||||
computeForwardProbes += String::String("TORQUE_SAMPLERCUBEARRAY_MAKEARG(@),TORQUE_SAMPLERCUBEARRAY_MAKEARG(@)).rgb; \r\n");
|
computeForwardProbes += String::String("TORQUE_SAMPLERCUBEARRAY_MAKEARG(@),TORQUE_SAMPLERCUBEARRAY_MAKEARG(@)).rgb; \r\n");
|
||||||
|
|
||||||
meta->addStatement(new GenOp(computeForwardProbes.c_str(), diffuseColor, surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, bbMinArray, bbMaxArray, inRefPosArray,
|
meta->addStatement(new GenOp(computeForwardProbes.c_str(), diffuseColor, surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, refBoxMinArray, refBoxMaxArray, inRefPosArray,
|
||||||
skylightCubemapIdx, BRDFTexture,
|
skylightCubemapIdx, BRDFTexture,
|
||||||
irradianceCubemapAR, specularCubemapAR));
|
irradianceCubemapAR, specularCubemapAR));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,8 +72,8 @@ const String ShaderGenVars::metalness("$metalness");
|
||||||
//Reflection Probes
|
//Reflection Probes
|
||||||
const String ShaderGenVars::probePosition("$inProbePosArray");
|
const String ShaderGenVars::probePosition("$inProbePosArray");
|
||||||
const String ShaderGenVars::probeRefPos("$inRefPosArray");
|
const String ShaderGenVars::probeRefPos("$inRefPosArray");
|
||||||
const String ShaderGenVars::probeBoxMin("$inProbeBoxMin");
|
const String ShaderGenVars::refBoxMin("$inProbeBoxMin");
|
||||||
const String ShaderGenVars::probeBoxMax("$inProbeBoxMax");
|
const String ShaderGenVars::refBoxMax("$inProbeBoxMax");
|
||||||
const String ShaderGenVars::worldToObjArray("$worldToObjArray");
|
const String ShaderGenVars::worldToObjArray("$worldToObjArray");
|
||||||
const String ShaderGenVars::probeConfigData("$probeConfigData");
|
const String ShaderGenVars::probeConfigData("$probeConfigData");
|
||||||
const String ShaderGenVars::specularCubemapAR("$specularCubemapAR");
|
const String ShaderGenVars::specularCubemapAR("$specularCubemapAR");
|
||||||
|
|
|
||||||
|
|
@ -85,8 +85,8 @@ struct ShaderGenVars
|
||||||
//Reflection Probes
|
//Reflection Probes
|
||||||
const static String probePosition;
|
const static String probePosition;
|
||||||
const static String probeRefPos;
|
const static String probeRefPos;
|
||||||
const static String probeBoxMin;
|
const static String refBoxMin;
|
||||||
const static String probeBoxMax;
|
const static String refBoxMax;
|
||||||
const static String worldToObjArray;
|
const static String worldToObjArray;
|
||||||
const static String probeConfigData;
|
const static String probeConfigData;
|
||||||
const static String specularCubemapAR;
|
const static String specularCubemapAR;
|
||||||
|
|
|
||||||
|
|
@ -398,12 +398,12 @@ float defineBoxSpaceInfluence(float3 wsPosition, float4x4 worldToObj, float atte
|
||||||
// Box Projected IBL Lighting
|
// Box Projected IBL Lighting
|
||||||
// Based on: http://www.gamedev.net/topic/568829-box-projected-cubemap-environment-mapping/
|
// Based on: http://www.gamedev.net/topic/568829-box-projected-cubemap-environment-mapping/
|
||||||
// and https://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/
|
// and https://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/
|
||||||
float3 boxProject(float3 wsPosition, float3 wsReflectVec, float4x4 worldToObj, float3 bbMin, float3 bbMax, float3 refPosition)
|
float3 boxProject(float3 wsPosition, float3 wsReflectVec, float4x4 worldToObj, float3 refBoxMin, float3 refBoxMax, float3 refPosition)
|
||||||
{
|
{
|
||||||
float3 RayLS = mul(worldToObj, float4(wsReflectVec, 0.0)).xyz;
|
float3 RayLS = mul(worldToObj, float4(wsReflectVec, 0.0)).xyz;
|
||||||
float3 PositionLS = mul(worldToObj, float4(wsPosition, 1.0)).xyz;
|
float3 PositionLS = mul(worldToObj, float4(wsPosition, 1.0)).xyz;
|
||||||
|
|
||||||
float3 unit = bbMax.xyz - bbMin.xyz;
|
float3 unit = refBoxMax.xyz - refBoxMin.xyz;
|
||||||
float3 plane1vec = (unit / 2 - PositionLS) / RayLS;
|
float3 plane1vec = (unit / 2 - PositionLS) / RayLS;
|
||||||
float3 plane2vec = (-unit / 2 - PositionLS) / RayLS;
|
float3 plane2vec = (-unit / 2 - PositionLS) / RayLS;
|
||||||
float3 furthestPlane = max(plane1vec, plane2vec);
|
float3 furthestPlane = max(plane1vec, plane2vec);
|
||||||
|
|
@ -415,7 +415,7 @@ float3 boxProject(float3 wsPosition, float3 wsReflectVec, float4x4 worldToObj, f
|
||||||
|
|
||||||
float4 computeForwardProbes(Surface surface,
|
float4 computeForwardProbes(Surface surface,
|
||||||
float cubeMips, int numProbes, float4x4 worldToObjArray[MAX_FORWARD_PROBES], float4 probeConfigData[MAX_FORWARD_PROBES],
|
float cubeMips, int numProbes, float4x4 worldToObjArray[MAX_FORWARD_PROBES], float4 probeConfigData[MAX_FORWARD_PROBES],
|
||||||
float4 inProbePosArray[MAX_FORWARD_PROBES], float4 bbMinArray[MAX_FORWARD_PROBES], float4 bbMaxArray[MAX_FORWARD_PROBES], float4 inRefPosArray[MAX_FORWARD_PROBES],
|
float4 inProbePosArray[MAX_FORWARD_PROBES], float4 refBoxMinArray[MAX_FORWARD_PROBES], float4 refBoxMaxArray[MAX_FORWARD_PROBES], float4 inRefPosArray[MAX_FORWARD_PROBES],
|
||||||
float skylightCubemapIdx, TORQUE_SAMPLER2D(BRDFTexture),
|
float skylightCubemapIdx, TORQUE_SAMPLER2D(BRDFTexture),
|
||||||
TORQUE_SAMPLERCUBEARRAY(irradianceCubemapAR), TORQUE_SAMPLERCUBEARRAY(specularCubemapAR))
|
TORQUE_SAMPLERCUBEARRAY(irradianceCubemapAR), TORQUE_SAMPLERCUBEARRAY(specularCubemapAR))
|
||||||
{
|
{
|
||||||
|
|
@ -444,8 +444,6 @@ float4 computeForwardProbes(Surface surface,
|
||||||
if (contribution[i] > 0.0)
|
if (contribution[i] > 0.0)
|
||||||
probehits++;
|
probehits++;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
continue;
|
|
||||||
|
|
||||||
contribution[i] = max(contribution[i], 0);
|
contribution[i] = max(contribution[i], 0);
|
||||||
|
|
||||||
|
|
@ -524,7 +522,7 @@ float4 computeForwardProbes(Surface surface,
|
||||||
if (contrib != 0)
|
if (contrib != 0)
|
||||||
{
|
{
|
||||||
int cubemapIdx = probeConfigData[i].a;
|
int cubemapIdx = probeConfigData[i].a;
|
||||||
float3 dir = boxProject(surface.P, surface.R, worldToObjArray[i], bbMinArray[i].xyz, bbMaxArray[i].xyz, inRefPosArray[i].xyz);
|
float3 dir = boxProject(surface.P, surface.R, worldToObjArray[i], refBoxMinArray[i].xyz, refBoxMaxArray[i].xyz, inRefPosArray[i].xyz);
|
||||||
|
|
||||||
irradiance += TORQUE_TEXCUBEARRAYLOD(irradianceCubemapAR, dir, cubemapIdx, 0).xyz * contrib;
|
irradiance += TORQUE_TEXCUBEARRAYLOD(irradianceCubemapAR, dir, cubemapIdx, 0).xyz * contrib;
|
||||||
specular += TORQUE_TEXCUBEARRAYLOD(specularCubemapAR, dir, cubemapIdx, lod).xyz * contrib;
|
specular += TORQUE_TEXCUBEARRAYLOD(specularCubemapAR, dir, cubemapIdx, lod).xyz * contrib;
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@ TORQUE_UNIFORM_SAMPLERCUBEARRAY(irradianceCubemapAR, 5);
|
||||||
uniform float4 inProbePosArray[MAX_PROBES];
|
uniform float4 inProbePosArray[MAX_PROBES];
|
||||||
uniform float4 inRefPosArray[MAX_PROBES];
|
uniform float4 inRefPosArray[MAX_PROBES];
|
||||||
uniform float4x4 worldToObjArray[MAX_PROBES];
|
uniform float4x4 worldToObjArray[MAX_PROBES];
|
||||||
uniform float4 bbMinArray[MAX_PROBES];
|
uniform float4 refBoxMinArray[MAX_PROBES];
|
||||||
uniform float4 bbMaxArray[MAX_PROBES];
|
uniform float4 refBoxMaxArray[MAX_PROBES];
|
||||||
uniform float4 probeConfigData[MAX_PROBES]; //r,g,b/mode,radius,atten
|
uniform float4 probeConfigData[MAX_PROBES]; //r,g,b/mode,radius,atten
|
||||||
|
|
||||||
#if DEBUGVIZ_CONTRIB
|
#if DEBUGVIZ_CONTRIB
|
||||||
|
|
@ -80,8 +80,6 @@ float4 main(PFXVertToPix IN) : SV_TARGET
|
||||||
if (contribution[i]>0.0)
|
if (contribution[i]>0.0)
|
||||||
probehits++;
|
probehits++;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
continue;
|
|
||||||
|
|
||||||
contribution[i] = max(contribution[i],0);
|
contribution[i] = max(contribution[i],0);
|
||||||
|
|
||||||
|
|
@ -167,7 +165,7 @@ float4 main(PFXVertToPix IN) : SV_TARGET
|
||||||
if (contrib != 0)
|
if (contrib != 0)
|
||||||
{
|
{
|
||||||
int cubemapIdx = probeConfigData[i].a;
|
int cubemapIdx = probeConfigData[i].a;
|
||||||
float3 dir = boxProject(surface.P, surface.R, worldToObjArray[i], bbMinArray[i].xyz, bbMaxArray[i].xyz, inRefPosArray[i].xyz);
|
float3 dir = boxProject(surface.P, surface.R, worldToObjArray[i], refBoxMinArray[i].xyz, refBoxMaxArray[i].xyz, inRefPosArray[i].xyz);
|
||||||
|
|
||||||
irradiance += TORQUE_TEXCUBEARRAYLOD(irradianceCubemapAR, dir, cubemapIdx, 0).xyz * contrib;
|
irradiance += TORQUE_TEXCUBEARRAYLOD(irradianceCubemapAR, dir, cubemapIdx, 0).xyz * contrib;
|
||||||
specular += TORQUE_TEXCUBEARRAYLOD(specularCubemapAR, dir, cubemapIdx, lod).xyz * contrib;
|
specular += TORQUE_TEXCUBEARRAYLOD(specularCubemapAR, dir, cubemapIdx, lod).xyz * contrib;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue