mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 08:04:40 +00:00
conversionwork courtessy of jeff. seeems float3f aligned arrays were nonfuncntional, so shifts a few over to float4s
This commit is contained in:
parent
e8c2912498
commit
2e485c4946
2 changed files with 145 additions and 179 deletions
|
|
@ -638,198 +638,164 @@ void RenderProbeMgr::render( SceneRenderState *state )
|
||||||
|
|
||||||
ReflectProbeMaterialInfo* reflProbeMat = getReflectProbeMaterial();
|
ReflectProbeMaterialInfo* reflProbeMat = getReflectProbeMaterial();
|
||||||
|
|
||||||
/*for (U32 i = 0; i < ProbeRenderInst::all.size(); i++)
|
if (reflProbeMat == nullptr || reflProbeMat->matInstance == nullptr)
|
||||||
{
|
return;
|
||||||
ProbeRenderInst* curEntry = ProbeRenderInst::all[i];
|
|
||||||
|
|
||||||
if (!curEntry->mIsEnabled)
|
MaterialParameters *matParams = reflProbeMat->matInstance->getMaterialParameters();
|
||||||
continue;
|
|
||||||
|
|
||||||
if (curEntry->numPrims == 0)
|
MaterialParameterHandle *numProbesSC = reflProbeMat->matInstance->getMaterialParameterHandle("$numProbes");
|
||||||
continue;
|
|
||||||
|
|
||||||
if (curEntry->mIsSkylight && (!skylightMat || !skylightMat->matInstance))
|
MaterialParameterHandle *probePositionSC = reflProbeMat->matInstance->getMaterialParameterHandle("$inProbePosArray");
|
||||||
continue;
|
MaterialParameterHandle *probeWorldToObjSC = reflProbeMat->matInstance->getMaterialParameterHandle("$worldToObjArray");
|
||||||
|
MaterialParameterHandle *probeBBMinSC = reflProbeMat->matInstance->getMaterialParameterHandle("$bbMinArray");
|
||||||
if (!curEntry->mIsSkylight && (!reflProbeMat || !reflProbeMat->matInstance))
|
MaterialParameterHandle *probeBBMaxSC = reflProbeMat->matInstance->getMaterialParameterHandle("$bbMaxArray");
|
||||||
break;
|
MaterialParameterHandle *probeUseSphereModeSC = reflProbeMat->matInstance->getMaterialParameterHandle("$useSphereMode");
|
||||||
|
MaterialParameterHandle *probeRadiusSC = reflProbeMat->matInstance->getMaterialParameterHandle("$radius");
|
||||||
if (curEntry->mIsSkylight)
|
MaterialParameterHandle *probeAttenuationSC = reflProbeMat->matInstance->getMaterialParameterHandle("$attenuation");
|
||||||
{
|
|
||||||
//Setup
|
|
||||||
MatrixF probeTrans = curEntry->getTransform();
|
|
||||||
|
|
||||||
// Set geometry
|
|
||||||
GFX->setVertexBuffer(curEntry->vertBuffer);
|
|
||||||
GFX->setPrimitiveBuffer(curEntry->primBuffer);
|
|
||||||
probeTrans.scale(10); //force it to be big enough to surround the camera
|
|
||||||
sgData.objTrans = &probeTrans;
|
|
||||||
skylightMat->setProbeParameters(curEntry, state, worldToCameraXfm);
|
|
||||||
|
|
||||||
while (skylightMat->matInstance->setupPass(state, sgData))
|
|
||||||
{
|
|
||||||
// Set transforms
|
|
||||||
matrixSet.setWorld(*sgData.objTrans);
|
|
||||||
skylightMat->matInstance->setTransforms(matrixSet, state);
|
|
||||||
skylightMat->matInstance->setSceneInfo(state, sgData);
|
|
||||||
|
|
||||||
GFX->drawPrimitive(GFXTriangleList, 0, curEntry->numPrims);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//Array rendering
|
//Array rendering
|
||||||
static U32 MAXPROBECOUNT = 50;
|
static U32 MAXPROBECOUNT = 50;
|
||||||
|
|
||||||
U32 probeCount = ProbeRenderInst::all.size();
|
U32 probeCount = ProbeRenderInst::all.size();
|
||||||
|
|
||||||
if (probeCount != 0)
|
if (probeCount == 0)
|
||||||
|
return;
|
||||||
|
MatrixF trans = MatrixF::Identity;
|
||||||
|
sgData.objTrans = &trans;
|
||||||
|
|
||||||
|
Vector<Point3F> probePositions;
|
||||||
|
Vector<MatrixF> probeWorldToObj;
|
||||||
|
Vector<Point3F> probeBBMin;
|
||||||
|
Vector<Point3F> probeBBMax;
|
||||||
|
Vector<float> probeUseSphereMode;
|
||||||
|
Vector<float> probeRadius;
|
||||||
|
Vector<float> probeAttenuation;
|
||||||
|
|
||||||
|
probePositions.setSize(MAXPROBECOUNT);
|
||||||
|
probeWorldToObj.setSize(MAXPROBECOUNT);
|
||||||
|
probeBBMin.setSize(MAXPROBECOUNT);
|
||||||
|
probeBBMax.setSize(MAXPROBECOUNT);
|
||||||
|
probeUseSphereMode.setSize(MAXPROBECOUNT);
|
||||||
|
probeRadius.setSize(MAXPROBECOUNT);
|
||||||
|
probeAttenuation.setSize(MAXPROBECOUNT);
|
||||||
|
|
||||||
|
Vector<GFXCubemapHandle> cubeMaps;
|
||||||
|
Vector<GFXCubemapHandle> irradMaps;
|
||||||
|
|
||||||
|
U32 effectiveProbeCount = 0;
|
||||||
|
|
||||||
|
for (U32 i = 0; i < probeCount; i++)
|
||||||
{
|
{
|
||||||
MatrixF trans = MatrixF::Identity;
|
if (effectiveProbeCount >= MAXPROBECOUNT)
|
||||||
sgData.objTrans = &trans;
|
break;
|
||||||
|
|
||||||
AlignedArray<Point3F> probePositions(MAXPROBECOUNT, sizeof(Point3F));
|
ProbeRenderInst* curEntry = ProbeRenderInst::all[i];
|
||||||
Vector<MatrixF> probeWorldToObj;
|
if (!curEntry->mIsEnabled)
|
||||||
AlignedArray<Point3F> probeBBMin(MAXPROBECOUNT, sizeof(Point3F));
|
continue;
|
||||||
AlignedArray<Point3F> probeBBMax(MAXPROBECOUNT, sizeof(Point3F));
|
|
||||||
AlignedArray<float> probeUseSphereMode(MAXPROBECOUNT, sizeof(float));
|
|
||||||
AlignedArray<float> probeRadius(MAXPROBECOUNT, sizeof(float));
|
|
||||||
AlignedArray<float> probeAttenuation(MAXPROBECOUNT, sizeof(float));
|
|
||||||
|
|
||||||
dMemset(probePositions.getBuffer(), 0, probePositions.getBufferSize());
|
if (curEntry->mCubemap.isNull() || curEntry->mIrradianceCubemap.isNull())
|
||||||
probeWorldToObj.setSize(MAXPROBECOUNT);
|
continue;
|
||||||
dMemset(probeBBMin.getBuffer(), 0, probeBBMin.getBufferSize());
|
|
||||||
dMemset(probeBBMax.getBuffer(), 0, probeBBMax.getBufferSize());
|
|
||||||
dMemset(probeUseSphereMode.getBuffer(), 0, probeUseSphereMode.getBufferSize());
|
|
||||||
dMemset(probeRadius.getBuffer(), 0, probeRadius.getBufferSize());
|
|
||||||
dMemset(probeAttenuation.getBuffer(), 0, probeAttenuation.getBufferSize());
|
|
||||||
|
|
||||||
Vector<GFXCubemapHandle> cubeMaps;
|
if (!curEntry->mCubemap->isInitialised())
|
||||||
Vector<GFXCubemapHandle> irradMaps;
|
continue;
|
||||||
|
|
||||||
if (reflProbeMat && reflProbeMat->matInstance)
|
if (curEntry->mIsSkylight)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
//Setup
|
||||||
|
const Point3F &probePos = curEntry->getPosition();
|
||||||
|
probePositions[i] = probePos + curEntry->mProbePosOffset;
|
||||||
|
|
||||||
|
MatrixF trans = curEntry->getTransform();
|
||||||
|
trans.inverse();
|
||||||
|
|
||||||
|
probeWorldToObj.push_back(trans);
|
||||||
|
|
||||||
|
probeBBMin[i] = curEntry->mBounds.minExtents;
|
||||||
|
probeBBMax[i] = curEntry->mBounds.maxExtents;
|
||||||
|
|
||||||
|
probeUseSphereMode[i] = curEntry->mProbeShapeType == ProbeRenderInst::Sphere ? 1 : 0;
|
||||||
|
|
||||||
|
probeRadius[i] = curEntry->mRadius;
|
||||||
|
probeAttenuation[i] = 1;
|
||||||
|
|
||||||
|
cubeMaps.push_back(curEntry->mCubemap);
|
||||||
|
irradMaps.push_back(curEntry->mIrradianceCubemap);
|
||||||
|
|
||||||
|
effectiveProbeCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (effectiveProbeCount != 0)
|
||||||
|
{
|
||||||
|
matParams->setSafe(numProbesSC, (float)effectiveProbeCount);
|
||||||
|
|
||||||
|
GFXCubemapArrayHandle mCubemapArray;
|
||||||
|
mCubemapArray = GFXCubemapArrayHandle(GFX->createCubemapArray());
|
||||||
|
|
||||||
|
GFXCubemapArrayHandle mIrradArray;
|
||||||
|
mIrradArray = GFXCubemapArrayHandle(GFX->createCubemapArray());
|
||||||
|
|
||||||
|
mCubemapArray->initStatic(cubeMaps.address(), cubeMaps.size());
|
||||||
|
mIrradArray->initStatic(irradMaps.address(), irradMaps.size());
|
||||||
|
|
||||||
|
NamedTexTarget *deferredTarget = NamedTexTarget::find(RenderDeferredMgr::BufferName);
|
||||||
|
if (deferredTarget)
|
||||||
|
GFX->setTexture(0, deferredTarget->getTexture());
|
||||||
|
else
|
||||||
|
GFX->setTexture(0, NULL);
|
||||||
|
|
||||||
|
NamedTexTarget *colorTarget = NamedTexTarget::find(RenderDeferredMgr::ColorBufferName);
|
||||||
|
if (colorTarget)
|
||||||
|
GFX->setTexture(1, colorTarget->getTexture());
|
||||||
|
else
|
||||||
|
GFX->setTexture(1, NULL);
|
||||||
|
|
||||||
|
NamedTexTarget *matinfoTarget = NamedTexTarget::find(RenderDeferredMgr::MatInfoBufferName);
|
||||||
|
if (matinfoTarget)
|
||||||
|
GFX->setTexture(2, matinfoTarget->getTexture());
|
||||||
|
else
|
||||||
|
GFX->setTexture(2, NULL);
|
||||||
|
|
||||||
|
if (mBrdfTexture)
|
||||||
{
|
{
|
||||||
MaterialParameters *matParams = reflProbeMat->matInstance->getMaterialParameters();
|
GFX->setTexture(3, mBrdfTexture);
|
||||||
|
}
|
||||||
MaterialParameterHandle *numProbesSC = reflProbeMat->matInstance->getMaterialParameterHandle("$numProbes");
|
else
|
||||||
|
GFX->setTexture(3, NULL);
|
||||||
MaterialParameterHandle *probePositionSC = reflProbeMat->matInstance->getMaterialParameterHandle("$inProbePosArray");
|
|
||||||
MaterialParameterHandle *probeWorldToObjSC = reflProbeMat->matInstance->getMaterialParameterHandle("$worldToObjArray");
|
|
||||||
MaterialParameterHandle *probeBBMinSC = reflProbeMat->matInstance->getMaterialParameterHandle("$bbMinArray");
|
|
||||||
MaterialParameterHandle *probeBBMaxSC = reflProbeMat->matInstance->getMaterialParameterHandle("$bbMaxArray");
|
|
||||||
MaterialParameterHandle *probeUseSphereModeSC = reflProbeMat->matInstance->getMaterialParameterHandle("$useSphereMode");
|
|
||||||
MaterialParameterHandle *probeRadiusSC = reflProbeMat->matInstance->getMaterialParameterHandle("$radius");
|
|
||||||
MaterialParameterHandle *probeAttenuationSC = reflProbeMat->matInstance->getMaterialParameterHandle("$attenuation");
|
|
||||||
|
|
||||||
U32 effectiveProbeCount = 0;
|
|
||||||
|
|
||||||
for (U32 i = 0; i < probeCount; i++)
|
|
||||||
{
|
|
||||||
if (effectiveProbeCount >= MAXPROBECOUNT)
|
|
||||||
break;
|
|
||||||
|
|
||||||
ProbeRenderInst* curEntry = ProbeRenderInst::all[i];
|
|
||||||
if (!curEntry->mIsEnabled)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (curEntry->mCubemap.isNull() || curEntry->mIrradianceCubemap.isNull())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!curEntry->mCubemap->isInitialised())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
|
|
||||||
//Setup
|
GFX->setCubeArrayTexture(4, mCubemapArray);
|
||||||
const Point3F &probePos = curEntry->getPosition();
|
GFX->setCubeArrayTexture(5, mIrradArray);
|
||||||
probePositions[i] = probePos + curEntry->mProbePosOffset;
|
//Final packing
|
||||||
|
AlignedArray<Point4F> _probePositions(effectiveProbeCount, sizeof(Point4F), (U8*)probePositions.address(), false);
|
||||||
|
AlignedArray<Point4F> _probeBBMin(effectiveProbeCount, sizeof(Point4F), (U8*)probeBBMin.address(), false);
|
||||||
|
AlignedArray<Point4F> _probeBBMax(effectiveProbeCount, sizeof(Point4F), (U8*)probeBBMax.address(), false);
|
||||||
|
AlignedArray<float> _probeUseSphereMode(effectiveProbeCount, sizeof(float), (U8*)probeUseSphereMode.address(), false);
|
||||||
|
AlignedArray<float> _probeRadius(effectiveProbeCount, sizeof(float), (U8*)probeRadius.address(), false);
|
||||||
|
AlignedArray<float> _probeAttenuation(effectiveProbeCount, sizeof(float), (U8*)probeAttenuation.address(), false);
|
||||||
|
|
||||||
MatrixF trans = curEntry->getTransform();
|
matParams->set(probePositionSC, _probePositions);
|
||||||
trans.inverse();
|
matParams->set(probeWorldToObjSC, probeWorldToObj.address(), effectiveProbeCount);
|
||||||
|
matParams->set(probeBBMinSC, _probeBBMin);
|
||||||
|
matParams->set(probeBBMaxSC, _probeBBMax);
|
||||||
|
matParams->set(probeUseSphereModeSC, _probeUseSphereMode);
|
||||||
|
matParams->set(probeRadiusSC, _probeRadius);
|
||||||
|
matParams->set(probeAttenuationSC, _probeAttenuation);
|
||||||
|
|
||||||
probeWorldToObj[i] = trans;
|
// Set geometry
|
||||||
|
GFX->setVertexBuffer(mFarFrustumQuadVerts);
|
||||||
|
GFX->setPrimitiveBuffer(NULL);
|
||||||
|
|
||||||
probeBBMin[i] = curEntry->mBounds.minExtents;
|
while (reflProbeMat->matInstance->setupPass(state, sgData))
|
||||||
probeBBMax[i] = curEntry->mBounds.maxExtents;
|
{
|
||||||
|
// Set transforms
|
||||||
|
matrixSet.setWorld(*sgData.objTrans);
|
||||||
|
reflProbeMat->matInstance->setTransforms(matrixSet, state);
|
||||||
|
reflProbeMat->matInstance->setSceneInfo(state, sgData);
|
||||||
|
|
||||||
probeUseSphereMode[i] = curEntry->mProbeShapeType == ProbeRenderInst::Sphere ? 1 : 0;
|
GFX->drawPrimitive(GFXTriangleStrip, 0, 2);
|
||||||
|
|
||||||
probeRadius[i] = curEntry->mRadius;
|
|
||||||
probeAttenuation[i] = 1;
|
|
||||||
|
|
||||||
cubeMaps.push_back(curEntry->mCubemap);
|
|
||||||
irradMaps.push_back(curEntry->mIrradianceCubemap);
|
|
||||||
|
|
||||||
effectiveProbeCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (effectiveProbeCount != 0)
|
|
||||||
{
|
|
||||||
matParams->setSafe(numProbesSC, (float)effectiveProbeCount);
|
|
||||||
|
|
||||||
GFXCubemapArrayHandle mCubemapArray;
|
|
||||||
mCubemapArray = GFXCubemapArrayHandle(GFX->createCubemapArray());
|
|
||||||
|
|
||||||
GFXCubemapArrayHandle mIrradArray;
|
|
||||||
mIrradArray = GFXCubemapArrayHandle(GFX->createCubemapArray());
|
|
||||||
|
|
||||||
mCubemapArray->initStatic(cubeMaps.address(), cubeMaps.size());
|
|
||||||
mIrradArray->initStatic(irradMaps.address(), irradMaps.size());
|
|
||||||
|
|
||||||
NamedTexTarget *deferredTarget = NamedTexTarget::find(RenderDeferredMgr::BufferName);
|
|
||||||
if (deferredTarget)
|
|
||||||
GFX->setTexture(0, deferredTarget->getTexture());
|
|
||||||
else
|
|
||||||
GFX->setTexture(0, NULL);
|
|
||||||
|
|
||||||
NamedTexTarget *colorTarget = NamedTexTarget::find(RenderDeferredMgr::ColorBufferName);
|
|
||||||
if (colorTarget)
|
|
||||||
GFX->setTexture(1, colorTarget->getTexture());
|
|
||||||
else
|
|
||||||
GFX->setTexture(1, NULL);
|
|
||||||
|
|
||||||
NamedTexTarget *matinfoTarget = NamedTexTarget::find(RenderDeferredMgr::MatInfoBufferName);
|
|
||||||
if (matinfoTarget)
|
|
||||||
GFX->setTexture(2, matinfoTarget->getTexture());
|
|
||||||
else
|
|
||||||
GFX->setTexture(2, NULL);
|
|
||||||
|
|
||||||
if (mBrdfTexture)
|
|
||||||
{
|
|
||||||
GFX->setTexture(3, mBrdfTexture);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
GFX->setTexture(3, NULL);
|
|
||||||
|
|
||||||
|
|
||||||
GFX->setCubeArrayTexture(4, mCubemapArray);
|
|
||||||
GFX->setCubeArrayTexture(5, mIrradArray);
|
|
||||||
|
|
||||||
matParams->set(probePositionSC, probePositions);
|
|
||||||
matParams->set(probeWorldToObjSC, probeWorldToObj.address(), probeWorldToObj.size());
|
|
||||||
matParams->set(probeBBMinSC, probeBBMin);
|
|
||||||
matParams->set(probeBBMaxSC, probeBBMax);
|
|
||||||
matParams->set(probeUseSphereModeSC, probeUseSphereMode);
|
|
||||||
matParams->set(probeRadiusSC, probeRadius);
|
|
||||||
matParams->set(probeAttenuationSC, probeAttenuation);
|
|
||||||
|
|
||||||
// Set geometry
|
|
||||||
GFX->setVertexBuffer(mFarFrustumQuadVerts);
|
|
||||||
GFX->setPrimitiveBuffer(NULL);
|
|
||||||
|
|
||||||
while (reflProbeMat->matInstance->setupPass(state, sgData))
|
|
||||||
{
|
|
||||||
// Set transforms
|
|
||||||
matrixSet.setWorld(*sgData.objTrans);
|
|
||||||
reflProbeMat->matInstance->setTransforms(matrixSet, state);
|
|
||||||
reflProbeMat->matInstance->setSceneInfo(state, sgData);
|
|
||||||
|
|
||||||
GFX->drawPrimitive(GFXTriangleStrip, 0, 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
GFX->popActiveRenderTarget();
|
GFX->popActiveRenderTarget();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,10 @@ uniform float cubeMips;
|
||||||
uniform float numProbes;
|
uniform float numProbes;
|
||||||
TORQUE_UNIFORM_SAMPLERCUBEARRAY(cubeMapAR, 4);
|
TORQUE_UNIFORM_SAMPLERCUBEARRAY(cubeMapAR, 4);
|
||||||
TORQUE_UNIFORM_SAMPLERCUBEARRAY(irradianceCubemapAR, 5);
|
TORQUE_UNIFORM_SAMPLERCUBEARRAY(irradianceCubemapAR, 5);
|
||||||
uniform float3 inProbePosArray[MAX_PROBES];
|
uniform float4 inProbePosArray[MAX_PROBES];
|
||||||
uniform float4x4 worldToObjArray[MAX_PROBES];
|
uniform float4x4 worldToObjArray[MAX_PROBES];
|
||||||
uniform float3 bbMinArray[MAX_PROBES];
|
uniform float4 bbMinArray[MAX_PROBES];
|
||||||
uniform float3 bbMaxArray[MAX_PROBES];
|
uniform float4 bbMaxArray[MAX_PROBES];
|
||||||
uniform float useSphereMode[MAX_PROBES];
|
uniform float useSphereMode[MAX_PROBES];
|
||||||
uniform float radius[MAX_PROBES];
|
uniform float radius[MAX_PROBES];
|
||||||
uniform float2 attenuation[MAX_PROBES];
|
uniform float2 attenuation[MAX_PROBES];
|
||||||
|
|
@ -48,7 +48,7 @@ float3 boxProject(float3 wsPosition, float3 reflectDir, float3 boxWSPos, float3
|
||||||
|
|
||||||
float3 iblBoxDiffuse( Surface surface, int id)
|
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].xyz, bbMinArray[id].xyz, bbMaxArray[id].xyz);
|
||||||
cubeN.z *=-1;
|
cubeN.z *=-1;
|
||||||
return TORQUE_TEXCUBEARRAYLOD(irradianceCubemapAR,cubeN,id,0).xyz;
|
return TORQUE_TEXCUBEARRAYLOD(irradianceCubemapAR,cubeN,id,0).xyz;
|
||||||
}
|
}
|
||||||
|
|
@ -64,7 +64,7 @@ float3 iblBoxSpecular(Surface surface, float3 surfToEye, TORQUE_SAMPLER2D(brdfTe
|
||||||
float lod = surface.roughness*cubeMips;
|
float lod = surface.roughness*cubeMips;
|
||||||
float3 r = reflect(surfToEye, surface.N);
|
float3 r = reflect(surfToEye, surface.N);
|
||||||
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].xyz, bbMinArray[id].xyz, bbMaxArray[id].xyz);
|
||||||
|
|
||||||
float3 radiance = TORQUE_TEXCUBEARRAYLOD(cubeMapAR,cubeR,id,lod).xyz * (brdf.x + brdf.y);
|
float3 radiance = TORQUE_TEXCUBEARRAYLOD(cubeMapAR,cubeR,id,lod).xyz * (brdf.x + brdf.y);
|
||||||
|
|
||||||
|
|
@ -76,8 +76,8 @@ float defineBoxSpaceInfluence(Surface surface, int id)
|
||||||
float tempAttenVal = 3.5; //replace with per probe atten
|
float tempAttenVal = 3.5; //replace with per probe atten
|
||||||
float3 surfPosLS = mul( worldToObjArray[id], float4(surface.P,1.0)).xyz;
|
float3 surfPosLS = mul( worldToObjArray[id], float4(surface.P,1.0)).xyz;
|
||||||
|
|
||||||
float3 boxMinLS = inProbePosArray[id]-(float3(1,1,1)*radius[id]);
|
float3 boxMinLS = inProbePosArray[id].xyz-(float3(1,1,1)*radius[0]);
|
||||||
float3 boxMaxLS = inProbePosArray[id]+(float3(1,1,1)*radius[id]);
|
float3 boxMaxLS = inProbePosArray[id].xyz+(float3(1,1,1)*radius[0]);
|
||||||
|
|
||||||
float boxOuterRange = length(boxMaxLS - boxMinLS);
|
float boxOuterRange = length(boxMaxLS - boxMinLS);
|
||||||
float boxInnerRange = boxOuterRange / tempAttenVal;
|
float boxInnerRange = boxOuterRange / tempAttenVal;
|
||||||
|
|
@ -105,18 +105,18 @@ float4 main( FarFrustumQuadConnectP IN ) : SV_TARGET
|
||||||
float blendVal[MAX_PROBES];
|
float blendVal[MAX_PROBES];
|
||||||
float3 surfToEye = normalize(surface.P - eyePosWorld);
|
float3 surfToEye = normalize(surface.P - eyePosWorld);
|
||||||
|
|
||||||
int i;
|
int i = 0;
|
||||||
float blendSum = 0;
|
float blendSum = 0;
|
||||||
float invBlendSum = 0;
|
float invBlendSum = 0;
|
||||||
|
|
||||||
for(i=0; i < numProbes; i++)
|
for(i=0; i < numProbes; i++)
|
||||||
{
|
{
|
||||||
float3 probeWS = inProbePosArray[i];
|
float3 probeWS = inProbePosArray[i].xyz;
|
||||||
float3 L = probeWS - surface.P;
|
float3 L = probeWS - surface.P;
|
||||||
|
|
||||||
if(useSphereMode[i])
|
if(useSphereMode[i])
|
||||||
{
|
{
|
||||||
float3 L = inProbePosArray[i] - surface.P;
|
float3 L = inProbePosArray[i].xyz - surface.P;
|
||||||
blendVal[i] = 1.0-length(L)/radius[i];
|
blendVal[i] = 1.0-length(L)/radius[i];
|
||||||
blendVal[i] = max(0,blendVal[i]);
|
blendVal[i] = max(0,blendVal[i]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue