mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
nomenclature shift for clarity: bunch of stuff tagged as probe that refferenced things properly tied conceptually to the reflection refrence box.
This commit is contained in:
parent
261bcd9a45
commit
01f6938746
|
|
@ -124,8 +124,8 @@ ProbeShaderConstants::ProbeShaderConstants()
|
|||
mShader(NULL),
|
||||
mProbePositionSC(NULL),
|
||||
mProbeRefPosSC(NULL),
|
||||
mProbeBoxMinSC(NULL),
|
||||
mProbeBoxMaxSC(NULL),
|
||||
mRefBoxMinSC(NULL),
|
||||
mRefBoxMaxSC(NULL),
|
||||
mProbeConfigDataSC(NULL),
|
||||
mProbeSpecularCubemapSC(NULL),
|
||||
mProbeIrradianceCubemapSC(NULL),
|
||||
|
|
@ -159,8 +159,8 @@ void ProbeShaderConstants::init(GFXShader* shader)
|
|||
//Reflection Probes
|
||||
mProbePositionSC = shader->getShaderConstHandle(ShaderGenVars::probePosition);
|
||||
mProbeRefPosSC = shader->getShaderConstHandle(ShaderGenVars::probeRefPos);
|
||||
mProbeBoxMinSC = shader->getShaderConstHandle(ShaderGenVars::probeBoxMin);
|
||||
mProbeBoxMaxSC = shader->getShaderConstHandle(ShaderGenVars::probeBoxMax);
|
||||
mRefBoxMinSC = shader->getShaderConstHandle(ShaderGenVars::refBoxMin);
|
||||
mRefBoxMaxSC = shader->getShaderConstHandle(ShaderGenVars::refBoxMax);
|
||||
mWorldToObjArraySC = shader->getShaderConstHandle(ShaderGenVars::worldToObjArray);
|
||||
mProbeConfigDataSC = shader->getShaderConstHandle(ShaderGenVars::probeConfigData);
|
||||
mProbeSpecularCubemapSC = shader->getShaderConstHandle(ShaderGenVars::specularCubemapAR);
|
||||
|
|
@ -178,8 +178,8 @@ bool ProbeShaderConstants::isValid()
|
|||
{
|
||||
if (mProbePositionSC->isValid() ||
|
||||
mProbeConfigDataSC->isValid() ||
|
||||
mProbeBoxMinSC->isValid() ||
|
||||
mProbeBoxMaxSC->isValid() ||
|
||||
mRefBoxMinSC->isValid() ||
|
||||
mRefBoxMaxSC->isValid() ||
|
||||
mProbeSpecularCubemapSC->isValid() ||
|
||||
mProbeIrradianceCubemapSC->isValid())
|
||||
return true;
|
||||
|
|
@ -422,16 +422,16 @@ void RenderProbeMgr::_setupStaticParameters()
|
|||
probePositionsData.setSize(MAXPROBECOUNT);
|
||||
probeRefPositionsData.setSize(MAXPROBECOUNT);
|
||||
probeWorldToObjData.setSize(MAXPROBECOUNT);
|
||||
probeBBMinData.setSize(MAXPROBECOUNT);
|
||||
probeBBMaxData.setSize(MAXPROBECOUNT);
|
||||
refBoxMinData.setSize(MAXPROBECOUNT);
|
||||
refBoxMaxData.setSize(MAXPROBECOUNT);
|
||||
probeConfigData.setSize(MAXPROBECOUNT);
|
||||
}
|
||||
|
||||
probePositionsData.fill(Point4F::Zero);
|
||||
probeRefPositionsData.fill(Point4F::Zero);
|
||||
probeWorldToObjData.fill(MatrixF::Identity);
|
||||
probeBBMinData.fill(Point4F::Zero);
|
||||
probeBBMaxData.fill(Point4F::Zero);
|
||||
refBoxMinData.fill(Point4F::Zero);
|
||||
refBoxMaxData.fill(Point4F::Zero);
|
||||
probeConfigData.fill(Point4F(-1,0,0,0));
|
||||
|
||||
for (U32 i = 0; i < probeCount; i++)
|
||||
|
|
@ -461,8 +461,8 @@ void RenderProbeMgr::_setupStaticParameters()
|
|||
probeWorldToObjData[mEffectiveProbeCount] = curEntry.getTransform();
|
||||
Point3F bbMin = 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);
|
||||
probeBBMaxData[mEffectiveProbeCount] = Point4F(bbMax.x, bbMax.y, bbMax.z, 0);
|
||||
refBoxMinData[mEffectiveProbeCount] = Point4F(bbMin.x, bbMin.y, bbMin.z, 0);
|
||||
refBoxMaxData[mEffectiveProbeCount] = Point4F(bbMax.x, bbMax.y, bbMax.z, 0);
|
||||
|
||||
probeConfigData[mEffectiveProbeCount] = Point4F(curEntry.mProbeShapeType,
|
||||
curEntry.mRadius,
|
||||
|
|
@ -561,8 +561,8 @@ void RenderProbeMgr::_update4ProbeConsts(const SceneData &sgData,
|
|||
const U32 MAX_FORWARD_PROBES = 4;
|
||||
|
||||
static AlignedArray<Point4F> probePositionArray(MAX_FORWARD_PROBES, sizeof(Point4F));
|
||||
static AlignedArray<Point4F> probeBoxMinArray(MAX_FORWARD_PROBES, sizeof(Point4F));
|
||||
static AlignedArray<Point4F> probeBoxMaxArray(MAX_FORWARD_PROBES, sizeof(Point4F));
|
||||
static AlignedArray<Point4F> refBoxMinArray(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> 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
|
||||
// lights from previous passes or have NaNs.
|
||||
dMemset(probePositionArray.getBuffer(), 0, probePositionArray.getBufferSize());
|
||||
dMemset(probeBoxMinArray.getBuffer(), 0, probeBoxMinArray.getBufferSize());
|
||||
dMemset(probeBoxMaxArray.getBuffer(), 0, probeBoxMaxArray.getBufferSize());
|
||||
dMemset(refBoxMinArray.getBuffer(), 0, refBoxMinArray.getBufferSize());
|
||||
dMemset(refBoxMaxArray.getBuffer(), 0, refBoxMaxArray.getBufferSize());
|
||||
dMemset(probeRefPositionArray.getBuffer(), 0, probeRefPositionArray.getBufferSize());
|
||||
dMemset(probeConfigArray.getBuffer(), 0, probeConfigArray.getBufferSize());
|
||||
|
||||
|
|
@ -632,15 +632,12 @@ void RenderProbeMgr::_update4ProbeConsts(const SceneData &sgData,
|
|||
probeRefPositionArray[effectiveProbeCount] = curEntry.mProbeRefOffset;
|
||||
probeWorldToObjArray[effectiveProbeCount] = curEntry.getTransform();
|
||||
|
||||
/*
|
||||
Point3F refPos = curEntry.getPosition() + curEntry.mProbeRefOffset;
|
||||
Point3F bbMin = refPos - curEntry.mProbeRefScale / 2 * curEntry.getTransform().getScale();
|
||||
Point3F bbMax = refPos + curEntry.mProbeRefScale / 2 * curEntry.getTransform().getScale();
|
||||
Point3F refBoxMin = refPos - curEntry.mProbeRefScale * curEntry.getTransform().getScale();
|
||||
Point3F refBoxMax = refPos + curEntry.mProbeRefScale * curEntry.getTransform().getScale();
|
||||
|
||||
probeBoxMinArray[mEffectiveProbeCount] = Point4F(bbMin.x, bbMin.y, bbMin.z, 0);
|
||||
probeBoxMaxArray[mEffectiveProbeCount] = Point4F(bbMax.x, bbMax.y, bbMax.z, 0);*/
|
||||
probeBoxMinArray[effectiveProbeCount] = curEntry.mBounds.minExtents;
|
||||
probeBoxMaxArray[effectiveProbeCount] = curEntry.mBounds.maxExtents;
|
||||
refBoxMinArray[mEffectiveProbeCount] = Point4F(refBoxMin.x, refBoxMin.y, refBoxMin.z, 0);
|
||||
refBoxMaxArray[mEffectiveProbeCount] = Point4F(refBoxMax.x, refBoxMax.y, refBoxMax.z, 0);
|
||||
probeConfigArray[effectiveProbeCount] = Point4F(curEntry.mProbeShapeType,
|
||||
curEntry.mRadius,
|
||||
curEntry.mAtten,
|
||||
|
|
@ -657,8 +654,8 @@ void RenderProbeMgr::_update4ProbeConsts(const SceneData &sgData,
|
|||
if(probeShaderConsts->isValid())
|
||||
shaderConsts->set(probeShaderConsts->mWorldToObjArraySC, probeWorldToObjArray.address(), effectiveProbeCount, GFXSCT_Float4x4);
|
||||
|
||||
shaderConsts->setSafe(probeShaderConsts->mProbeBoxMinSC, probeBoxMinArray);
|
||||
shaderConsts->setSafe(probeShaderConsts->mProbeBoxMaxSC, probeBoxMaxArray);
|
||||
shaderConsts->setSafe(probeShaderConsts->mRefBoxMinSC, refBoxMinArray);
|
||||
shaderConsts->setSafe(probeShaderConsts->mRefBoxMaxSC, refBoxMaxArray);
|
||||
shaderConsts->setSafe(probeShaderConsts->mProbeConfigDataSC, probeConfigArray);
|
||||
|
||||
shaderConsts->setSafe(probeShaderConsts->mSkylightCubemapIdxSC, (float)skyLightIdx);
|
||||
|
|
@ -789,8 +786,8 @@ void RenderProbeMgr::render( SceneRenderState *state )
|
|||
mProbeArrayEffect->setShaderConst("$inProbePosArray", probePositionsData);
|
||||
mProbeArrayEffect->setShaderConst("$inRefPosArray", probeRefPositionsData);
|
||||
mProbeArrayEffect->setShaderConst("$worldToObjArray", probeWorldToObjData);
|
||||
mProbeArrayEffect->setShaderConst("$bbMinArray", probeBBMinData);
|
||||
mProbeArrayEffect->setShaderConst("$bbMaxArray", probeBBMaxData);
|
||||
mProbeArrayEffect->setShaderConst("$bbMinArray", refBoxMinData);
|
||||
mProbeArrayEffect->setShaderConst("$bbMaxArray", refBoxMaxData);
|
||||
mProbeArrayEffect->setShaderConst("$probeConfigData", probeConfigData);
|
||||
|
||||
// Make sure the effect is gonna render.
|
||||
|
|
|
|||
|
|
@ -141,8 +141,8 @@ struct ProbeShaderConstants
|
|||
//Reflection Probes
|
||||
GFXShaderConstHandle *mProbePositionSC;
|
||||
GFXShaderConstHandle *mProbeRefPosSC;
|
||||
GFXShaderConstHandle *mProbeBoxMinSC;
|
||||
GFXShaderConstHandle *mProbeBoxMaxSC;
|
||||
GFXShaderConstHandle *mRefBoxMinSC;
|
||||
GFXShaderConstHandle *mRefBoxMaxSC;
|
||||
GFXShaderConstHandle *mWorldToObjArraySC;
|
||||
GFXShaderConstHandle *mProbeConfigDataSC;
|
||||
GFXShaderConstHandle *mProbeSpecularCubemapSC;
|
||||
|
|
@ -194,16 +194,16 @@ class RenderProbeMgr : public RenderBinManager
|
|||
Vector<Point4F> probePositionsData;
|
||||
Vector<Point4F> probeRefPositionsData;
|
||||
Vector<MatrixF> probeWorldToObjData;
|
||||
Vector<Point4F> probeBBMinData;
|
||||
Vector<Point4F> probeBBMaxData;
|
||||
Vector<Point4F> refBoxMinData;
|
||||
Vector<Point4F> refBoxMaxData;
|
||||
Vector<Point4F> probeConfigData;
|
||||
|
||||
bool mHasSkylight;
|
||||
S32 mSkylightCubemapIdx;
|
||||
|
||||
AlignedArray<Point4F> mProbePositions;
|
||||
AlignedArray<Point4F> mProbeBBMin;
|
||||
AlignedArray<Point4F> mProbeBBMax;
|
||||
AlignedArray<Point4F> mRefBoxMin;
|
||||
AlignedArray<Point4F> mRefBoxMax;
|
||||
AlignedArray<float> mProbeUseSphereMode;
|
||||
AlignedArray<float> mProbeRadius;
|
||||
AlignedArray<float> mProbeAttenuation;
|
||||
|
|
|
|||
|
|
@ -2927,12 +2927,12 @@ void ReflectionProbeFeatGLSL::processPix(Vector<ShaderComponent*>& componentList
|
|||
inRefPosArray->uniform = true;
|
||||
inRefPosArray->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
Var * bbMinArray = new Var("inProbeBoxMin", "vec4");
|
||||
Var * bbMinArray = new Var("inRefBoxMin", "vec4");
|
||||
bbMinArray->arraySize = MAX_FORWARD_PROBES;
|
||||
bbMinArray->uniform = true;
|
||||
bbMinArray->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
Var * bbMaxArray = new Var("inProbeBoxMax", "vec4");
|
||||
Var * bbMaxArray = new Var("inRefBoxMax", "vec4");
|
||||
bbMaxArray->arraySize = MAX_FORWARD_PROBES;
|
||||
bbMaxArray->uniform = true;
|
||||
bbMaxArray->constSortPos = cspPotentialPrimitive;
|
||||
|
|
|
|||
|
|
@ -3002,12 +3002,12 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
|
|||
inRefPosArray->uniform = true;
|
||||
inRefPosArray->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
Var *bbMinArray = new Var("inProbeBoxMin", "float4");
|
||||
Var *bbMinArray = new Var("inRefBoxMin", "float4");
|
||||
bbMinArray->arraySize = MAX_FORWARD_PROBES;
|
||||
bbMinArray->uniform = true;
|
||||
bbMinArray->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
Var *bbMaxArray = new Var("inProbeBoxMax", "float4");
|
||||
Var *bbMaxArray = new Var("inRefBoxMax", "float4");
|
||||
bbMaxArray->arraySize = MAX_FORWARD_PROBES;
|
||||
bbMaxArray->uniform = true;
|
||||
bbMaxArray->constSortPos = cspPotentialPrimitive;
|
||||
|
|
|
|||
|
|
@ -72,8 +72,8 @@ const String ShaderGenVars::metalness("$metalness");
|
|||
//Reflection Probes
|
||||
const String ShaderGenVars::probePosition("$inProbePosArray");
|
||||
const String ShaderGenVars::probeRefPos("$inRefPosArray");
|
||||
const String ShaderGenVars::probeBoxMin("$inProbeBoxMin");
|
||||
const String ShaderGenVars::probeBoxMax("$inProbeBoxMax");
|
||||
const String ShaderGenVars::refBoxMin("$inProbeBoxMin");
|
||||
const String ShaderGenVars::refBoxMax("$inProbeBoxMax");
|
||||
const String ShaderGenVars::worldToObjArray("$worldToObjArray");
|
||||
const String ShaderGenVars::probeConfigData("$probeConfigData");
|
||||
const String ShaderGenVars::specularCubemapAR("$specularCubemapAR");
|
||||
|
|
|
|||
|
|
@ -85,8 +85,8 @@ struct ShaderGenVars
|
|||
//Reflection Probes
|
||||
const static String probePosition;
|
||||
const static String probeRefPos;
|
||||
const static String probeBoxMin;
|
||||
const static String probeBoxMax;
|
||||
const static String refBoxMin;
|
||||
const static String refBoxMax;
|
||||
const static String worldToObjArray;
|
||||
const static String probeConfigData;
|
||||
const static String specularCubemapAR;
|
||||
|
|
|
|||
|
|
@ -398,12 +398,12 @@ float defineBoxSpaceInfluence(float3 wsPosition, float4x4 worldToObj, float atte
|
|||
// Box Projected IBL Lighting
|
||||
// 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/
|
||||
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 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 plane2vec = (-unit / 2 - PositionLS) / RayLS;
|
||||
float3 furthestPlane = max(plane1vec, plane2vec);
|
||||
|
|
@ -415,7 +415,7 @@ float3 boxProject(float3 wsPosition, float3 wsReflectVec, float4x4 worldToObj, f
|
|||
|
||||
float4 computeForwardProbes(Surface surface,
|
||||
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),
|
||||
TORQUE_SAMPLERCUBEARRAY(irradianceCubemapAR), TORQUE_SAMPLERCUBEARRAY(specularCubemapAR))
|
||||
{
|
||||
|
|
@ -524,7 +524,7 @@ float4 computeForwardProbes(Surface surface,
|
|||
if (contrib != 0)
|
||||
{
|
||||
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], refBoxArray[i].xyz, refBoxMaxArray[i].xyz, inRefPosArray[i].xyz);
|
||||
|
||||
irradiance += TORQUE_TEXCUBEARRAYLOD(irradianceCubemapAR, dir, cubemapIdx, 0).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 inRefPosArray[MAX_PROBES];
|
||||
uniform float4x4 worldToObjArray[MAX_PROBES];
|
||||
uniform float4 bbMinArray[MAX_PROBES];
|
||||
uniform float4 bbMaxArray[MAX_PROBES];
|
||||
uniform float4 refBoxMinArray[MAX_PROBES];
|
||||
uniform float4 refBoxArray[MAX_PROBES];
|
||||
uniform float4 probeConfigData[MAX_PROBES]; //r,g,b/mode,radius,atten
|
||||
|
||||
#if DEBUGVIZ_CONTRIB
|
||||
|
|
@ -167,7 +167,7 @@ float4 main(PFXVertToPix IN) : SV_TARGET
|
|||
if (contrib != 0)
|
||||
{
|
||||
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;
|
||||
specular += TORQUE_TEXCUBEARRAYLOD(specularCubemapAR, dir, cubemapIdx, lod).xyz * contrib;
|
||||
|
|
|
|||
Loading…
Reference in a new issue