From 01f69387462d735f96dfeffe2cd4847796daec40 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Fri, 28 Jun 2019 10:21:50 -0500 Subject: [PATCH] nomenclature shift for clarity: bunch of stuff tagged as probe that refferenced things properly tied conceptually to the reflection refrence box. --- .../source/renderInstance/renderProbeMgr.cpp | 51 +++++++++---------- Engine/source/renderInstance/renderProbeMgr.h | 12 ++--- .../shaderGen/GLSL/shaderFeatureGLSL.cpp | 4 +- .../shaderGen/HLSL/shaderFeatureHLSL.cpp | 4 +- Engine/source/shaderGen/shaderGenVars.cpp | 4 +- Engine/source/shaderGen/shaderGenVars.h | 4 +- .../game/core/rendering/shaders/lighting.hlsl | 8 +-- .../advanced/reflectionProbeArrayP.hlsl | 6 +-- 8 files changed, 45 insertions(+), 48 deletions(-) diff --git a/Engine/source/renderInstance/renderProbeMgr.cpp b/Engine/source/renderInstance/renderProbeMgr.cpp index e1f2a2ac6..2d0d0626c 100644 --- a/Engine/source/renderInstance/renderProbeMgr.cpp +++ b/Engine/source/renderInstance/renderProbeMgr.cpp @@ -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 probePositionArray(MAX_FORWARD_PROBES, sizeof(Point4F)); - static AlignedArray probeBoxMinArray(MAX_FORWARD_PROBES, sizeof(Point4F)); - static AlignedArray probeBoxMaxArray(MAX_FORWARD_PROBES, sizeof(Point4F)); + static AlignedArray refBoxMinArray(MAX_FORWARD_PROBES, sizeof(Point4F)); + static AlignedArray refBoxMaxArray(MAX_FORWARD_PROBES, sizeof(Point4F)); static AlignedArray probeRefPositionArray(MAX_FORWARD_PROBES, sizeof(Point4F)); static AlignedArray 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. diff --git a/Engine/source/renderInstance/renderProbeMgr.h b/Engine/source/renderInstance/renderProbeMgr.h index 8d01b8ae8..fff0f3ba9 100644 --- a/Engine/source/renderInstance/renderProbeMgr.h +++ b/Engine/source/renderInstance/renderProbeMgr.h @@ -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 probePositionsData; Vector probeRefPositionsData; Vector probeWorldToObjData; - Vector probeBBMinData; - Vector probeBBMaxData; + Vector refBoxMinData; + Vector refBoxMaxData; Vector probeConfigData; bool mHasSkylight; S32 mSkylightCubemapIdx; AlignedArray mProbePositions; - AlignedArray mProbeBBMin; - AlignedArray mProbeBBMax; + AlignedArray mRefBoxMin; + AlignedArray mRefBoxMax; AlignedArray mProbeUseSphereMode; AlignedArray mProbeRadius; AlignedArray mProbeAttenuation; diff --git a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp index 230df5c19..817e934d1 100644 --- a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp +++ b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp @@ -2927,12 +2927,12 @@ void ReflectionProbeFeatGLSL::processPix(Vector& 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; diff --git a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp index 8a8caf90b..884dfb9a0 100644 --- a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp +++ b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp @@ -3002,12 +3002,12 @@ void ReflectionProbeFeatHLSL::processPix(Vector &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; diff --git a/Engine/source/shaderGen/shaderGenVars.cpp b/Engine/source/shaderGen/shaderGenVars.cpp index 083bd09ac..9b08be0f9 100644 --- a/Engine/source/shaderGen/shaderGenVars.cpp +++ b/Engine/source/shaderGen/shaderGenVars.cpp @@ -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"); diff --git a/Engine/source/shaderGen/shaderGenVars.h b/Engine/source/shaderGen/shaderGenVars.h index d5612d600..a4d1df39b 100644 --- a/Engine/source/shaderGen/shaderGenVars.h +++ b/Engine/source/shaderGen/shaderGenVars.h @@ -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; diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl index 070eb4aca..369134092 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl @@ -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; diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/reflectionProbeArrayP.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/reflectionProbeArrayP.hlsl index df53fa3c9..444f4326f 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/reflectionProbeArrayP.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/reflectionProbeArrayP.hlsl @@ -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;