explicitly bound the namedtexttargets to input slots. shifted brdf slot on up to 3 (from 5) to cluster flat vs array entries. though it does not appear at time of writing that that is in fact binding...

This commit is contained in:
Azaezel 2019-01-28 22:10:57 -06:00
parent 7a8dd96808
commit 1dfd130d85
2 changed files with 25 additions and 10 deletions

View file

@ -741,7 +741,6 @@ void RenderProbeMgr::render( SceneRenderState *state )
break; break;
ProbeRenderInst* curEntry = ProbeRenderInst::all[i]; ProbeRenderInst* curEntry = ProbeRenderInst::all[i];
if (!curEntry->mIsEnabled) if (!curEntry->mIsEnabled)
continue; continue;
@ -751,6 +750,7 @@ void RenderProbeMgr::render( SceneRenderState *state )
if (!curEntry->mCubemap->isInitialised()) if (!curEntry->mCubemap->isInitialised())
continue; continue;
//Setup //Setup
const Point3F &probePos = curEntry->getPosition(); const Point3F &probePos = curEntry->getPosition();
probePositions[i] = probePos + curEntry->mProbePosOffset; probePositions[i] = probePos + curEntry->mProbePosOffset;
@ -787,9 +787,22 @@ void RenderProbeMgr::render( SceneRenderState *state )
mCubemapArray->initStatic(cubeMaps.address(), cubeMaps.size()); mCubemapArray->initStatic(cubeMaps.address(), cubeMaps.size());
mIrradArray->initStatic(irradMaps.address(), irradMaps.size()); mIrradArray->initStatic(irradMaps.address(), irradMaps.size());
GFX->setCubeArrayTexture(3, mCubemapArray); NamedTexTarget *deferredTarget = NamedTexTarget::find(RenderDeferredMgr::BufferName);
GFX->setCubeArrayTexture(4, mIrradArray); if (deferredTarget)
GFX->setTexture(5, mBrdfTexture); GFX->setTexture(0, deferredTarget->getTexture());
NamedTexTarget *colorTarget = NamedTexTarget::find(RenderDeferredMgr::ColorBufferName);
if (colorTarget)
GFX->setTexture(1, colorTarget->getTexture());
NamedTexTarget *matinfoTarget = NamedTexTarget::find(RenderDeferredMgr::MatInfoBufferName);
if (matinfoTarget)
GFX->setTexture(2, matinfoTarget->getTexture());
GFX->setTexture(3, mBrdfTexture);
GFX->setCubeArrayTexture(4, mCubemapArray);
GFX->setCubeArrayTexture(5, mIrradArray);
matParams->set(probePositionSC, probePositions); matParams->set(probePositionSC, probePositions);
matParams->set(probeWorldToObjSC, probeWorldToObj.address(), probeWorldToObj.size()); matParams->set(probeWorldToObjSC, probeWorldToObj.address(), probeWorldToObj.size());

View file

@ -22,7 +22,7 @@ struct ConvexConnectP
TORQUE_UNIFORM_SAMPLER2D(deferredBuffer, 0); TORQUE_UNIFORM_SAMPLER2D(deferredBuffer, 0);
TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 1); TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 1);
TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 2); TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 2);
TORQUE_UNIFORM_SAMPLER2D(BRDFTexture, 5); TORQUE_UNIFORM_SAMPLER2D(BRDFTexture, 3);
uniform float4 rtParams0; uniform float4 rtParams0;
uniform float4 vsFarPlane; uniform float4 vsFarPlane;
@ -34,8 +34,8 @@ uniform float cubeMips;
#define MAX_PROBES 50 #define MAX_PROBES 50
uniform float numProbes; uniform float numProbes;
TORQUE_UNIFORM_SAMPLERCUBEARRAY(cubeMap, 3); TORQUE_UNIFORM_SAMPLERCUBEARRAY(cubeMap, 4);
TORQUE_UNIFORM_SAMPLERCUBEARRAY(irradianceCubemap, 4); TORQUE_UNIFORM_SAMPLERCUBEARRAY(irradianceCubemap, 5);
uniform float3 inProbePosArray[MAX_PROBES]; uniform float3 inProbePosArray[MAX_PROBES];
uniform float4x4 worldToObjArray[MAX_PROBES]; uniform float4x4 worldToObjArray[MAX_PROBES];
uniform float3 bbMinArray[MAX_PROBES]; uniform float3 bbMinArray[MAX_PROBES];
@ -65,7 +65,8 @@ float3 iblBoxDiffuse( Surface surface, int id)
{ {
float3 cubeN = boxProject(surface.P, surface.N, inProbePosArray[id], bbMinArray[id], bbMaxArray[id]); float3 cubeN = boxProject(surface.P, surface.N, inProbePosArray[id], bbMinArray[id], bbMaxArray[id]);
cubeN.z *=-1; cubeN.z *=-1;
return TORQUE_TEXCUBEARRAYLOD(irradianceCubemap,cubeN,id,0).xyz; //return TORQUE_TEXCUBEARRAYLOD(irradianceCubemap,cubeN,id,0).xyz;
return float3(1,1,1);
} }
float3 iblBoxSpecular(Surface surface, float3 surfToEye, TORQUE_SAMPLER2D(brdfTexture), int id) float3 iblBoxSpecular(Surface surface, float3 surfToEye, TORQUE_SAMPLER2D(brdfTexture), int id)
@ -81,7 +82,8 @@ float3 iblBoxSpecular(Surface surface, float3 surfToEye, TORQUE_SAMPLER2D(brdfTe
float3 cubeR = normalize(r); float3 cubeR = normalize(r);
cubeR = boxProject(surface.P, surface.N, inProbePosArray[id], bbMinArray[id], bbMaxArray[id]); cubeR = boxProject(surface.P, surface.N, inProbePosArray[id], bbMinArray[id], bbMaxArray[id]);
float3 radiance = TORQUE_TEXCUBEARRAYLOD(cubeMap,cubeR,lod,id).xyz * (brdf.x + brdf.y); //float3 radiance = TORQUE_TEXCUBEARRAYLOD(cubeMap,cubeR,id,lod).xyz * (brdf.x + brdf.y);
float3 radiance = float3(1,1,1);
return radiance; return radiance;
} }
@ -148,7 +150,7 @@ float4 main( ConvexConnectP IN ) : SV_TARGET
blendVal[i] = max(0,blendVal[i]); blendVal[i] = max(0,blendVal[i]);
} }
blendSum += blendVal[i]; blendSum += blendVal[i];
invBlendSum +=(1.0f - blendVal[i]); invBlendSum +=(1.0f - blendVal[i]);
} }
// Weight0 = normalized NDF, inverted to have 1 at center, 0 at boundary. // Weight0 = normalized NDF, inverted to have 1 at center, 0 at boundary.