mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-20 04:34:48 +00:00
Merge branch 'PBR_ProbeArrayForward' into PBR_ProbeArrayGLWIP
# Conflicts: # Engine/source/renderInstance/renderProbeMgr.cpp
This commit is contained in:
commit
a0d1a076d5
|
|
@ -834,7 +834,7 @@ void GFXDevice::setCubeTexture( U32 stage, GFXCubemap *cubemap )
|
|||
//-----------------------------------------------------------------------------
|
||||
void GFXDevice::setCubeArrayTexture(U32 stage, GFXCubemapArray *cubemapArray)
|
||||
{
|
||||
AssertFatal(stage < getNumSamplers(), "GFXDevice::setTexture - out of range stage!");
|
||||
AssertFatal(stage < getNumSamplers(), avar("GFXDevice::setTexture - out of range stage! %i>%i", stage, getNumSamplers()));
|
||||
|
||||
if (mTexType[stage] == GFXTDT_CubeArray &&
|
||||
((mTextureDirty[stage] && mNewCubemapArray[stage].getPointer() == cubemapArray) ||
|
||||
|
|
|
|||
|
|
@ -119,7 +119,6 @@ void ProbeRenderInst::set(const ProbeRenderInst *probeInfo)
|
|||
ProbeShaderConstants::ProbeShaderConstants()
|
||||
: mInit(false),
|
||||
mShader(NULL),
|
||||
mProbeParamsSC(NULL),
|
||||
mProbePositionSC(NULL),
|
||||
mProbeRefPosSC(NULL),
|
||||
mProbeBoxMinSC(NULL),
|
||||
|
|
@ -127,7 +126,10 @@ ProbeShaderConstants::ProbeShaderConstants()
|
|||
mProbeConfigDataSC(NULL),
|
||||
mProbeSpecularCubemapSC(NULL),
|
||||
mProbeIrradianceCubemapSC(NULL),
|
||||
mProbeCountSC(NULL)
|
||||
mProbeCountSC(NULL),
|
||||
mSkylightSpecularMap(NULL),
|
||||
mSkylightIrradMap(NULL),
|
||||
mHasSkylight(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -150,9 +152,7 @@ void ProbeShaderConstants::init(GFXShader* shader)
|
|||
mShader = shader;
|
||||
mShader->getReloadSignal().notify(this, &ProbeShaderConstants::_onShaderReload);
|
||||
}
|
||||
|
||||
mProbeParamsSC = shader->getShaderConstHandle("$probeParams");
|
||||
|
||||
|
||||
//Reflection Probes
|
||||
mProbePositionSC = shader->getShaderConstHandle(ShaderGenVars::probePosition);
|
||||
mProbeRefPosSC = shader->getShaderConstHandle(ShaderGenVars::probeRefPos);
|
||||
|
|
@ -680,13 +680,8 @@ void RenderProbeMgr::_update4ProbeConsts(const SceneData &sgData,
|
|||
{
|
||||
if (curEntry.mPrefilterCubemap.isValid() && curEntry.mPrefilterCubemap.isValid())
|
||||
{
|
||||
S32 specSample = probeShaderConsts->mSkylightSpecularMap->getSamplerRegister();
|
||||
if (specSample != -1)
|
||||
GFX->setCubeTexture(specSample, curEntry.mPrefilterCubemap);
|
||||
|
||||
S32 irradSample = probeShaderConsts->mSkylightIrradMap->getSamplerRegister();
|
||||
if (irradSample != -1)
|
||||
GFX->setCubeTexture(irradSample, curEntry.mIrradianceCubemap);
|
||||
GFX->setCubeTexture(probeShaderConsts->mSkylightSpecularMap->getSamplerRegister(), curEntry.mPrefilterCubemap);
|
||||
GFX->setCubeTexture(probeShaderConsts->mSkylightIrradMap->getSamplerRegister(), curEntry.mIrradianceCubemap);
|
||||
|
||||
shaderConsts->setSafe(probeShaderConsts->mHasSkylight, 1.0f);
|
||||
hasSkylight = true;
|
||||
|
|
@ -719,14 +714,8 @@ void RenderProbeMgr::_update4ProbeConsts(const SceneData &sgData,
|
|||
shaderConsts->setSafe(probeShaderConsts->mProbeBoxMinSC, probeBoxMinArray);
|
||||
shaderConsts->setSafe(probeShaderConsts->mProbeBoxMaxSC, probeBoxMaxArray);
|
||||
shaderConsts->setSafe(probeShaderConsts->mProbeConfigDataSC, probeConfigArray);
|
||||
|
||||
S32 specSample = probeShaderConsts->mProbeSpecularCubemapSC->getSamplerRegister();
|
||||
if (specSample != -1)
|
||||
GFX->setCubeArrayTexture(specSample, mPrefilterArray);
|
||||
|
||||
S32 irradSample = probeShaderConsts->mProbeIrradianceCubemapSC->getSamplerRegister();
|
||||
if (irradSample != -1)
|
||||
GFX->setCubeArrayTexture(irradSample, mIrradianceArray);
|
||||
GFX->setCubeArrayTexture(probeShaderConsts->mProbeSpecularCubemapSC->getSamplerRegister(), mPrefilterArray);
|
||||
GFX->setCubeArrayTexture(probeShaderConsts->mProbeIrradianceCubemapSC->getSamplerRegister(), mIrradianceArray);
|
||||
|
||||
if (!hasSkylight)
|
||||
shaderConsts->setSafe(probeShaderConsts->mHasSkylight, 0.0f);
|
||||
|
|
|
|||
|
|
@ -131,9 +131,7 @@ struct ProbeShaderConstants
|
|||
bool mInit;
|
||||
|
||||
GFXShaderRef mShader;
|
||||
|
||||
GFXShaderConstHandle* mProbeParamsSC;
|
||||
|
||||
|
||||
//Reflection Probes
|
||||
GFXShaderConstHandle *mProbePositionSC;
|
||||
GFXShaderConstHandle *mProbeRefPosSC;
|
||||
|
|
|
|||
|
|
@ -3041,7 +3041,7 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
|
|||
BRDFTexture->sampler = true;
|
||||
BRDFTexture->constNum = Var::getTexUnitNum(); // used as texture unit num here
|
||||
|
||||
Var *BRDFTextureTex = new Var("BRDFTextureTex", "Texture2D");
|
||||
Var *BRDFTextureTex = new Var("texture_BRDFTexture", "Texture2D");
|
||||
BRDFTextureTex->uniform = true;
|
||||
BRDFTextureTex->texture = true;
|
||||
BRDFTextureTex->constNum = BRDFTexture->constNum;
|
||||
|
|
@ -3051,7 +3051,7 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
|
|||
specularCubemapAR->sampler = true;
|
||||
specularCubemapAR->constNum = Var::getTexUnitNum(); // used as texture unit num here
|
||||
|
||||
Var *specularCubemapARTex = new Var("specularCubemapARTex", "TextureCubeArray");
|
||||
Var *specularCubemapARTex = new Var("texture_specularCubemapAR", "TextureCubeArray");
|
||||
specularCubemapARTex->uniform = true;
|
||||
specularCubemapARTex->texture = true;
|
||||
specularCubemapARTex->constNum = specularCubemapAR->constNum;
|
||||
|
|
@ -3061,7 +3061,7 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
|
|||
irradianceCubemapAR->sampler = true;
|
||||
irradianceCubemapAR->constNum = Var::getTexUnitNum(); // used as texture unit num here
|
||||
|
||||
Var *irradianceCubemapARTex = new Var("irradianceCubemapARTex", "TextureCubeArray");
|
||||
Var *irradianceCubemapARTex = new Var("texture_irradianceCubemapAR", "TextureCubeArray");
|
||||
irradianceCubemapARTex->uniform = true;
|
||||
irradianceCubemapARTex->texture = true;
|
||||
irradianceCubemapARTex->constNum = irradianceCubemapAR->constNum;
|
||||
|
|
@ -3071,7 +3071,7 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
|
|||
skylightSpecularMap->sampler = true;
|
||||
skylightSpecularMap->constNum = Var::getTexUnitNum(); // used as texture unit num here
|
||||
|
||||
Var *skylightSpecularMapTex = new Var("skylightSpecularMapTex", "TextureCube");
|
||||
Var *skylightSpecularMapTex = new Var("texture_skylightSpecularMap", "TextureCube");
|
||||
skylightSpecularMapTex->uniform = true;
|
||||
skylightSpecularMapTex->texture = true;
|
||||
skylightSpecularMapTex->constNum = skylightSpecularMap->constNum;
|
||||
|
|
@ -3081,103 +3081,56 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
|
|||
skylightIrradMap->sampler = true;
|
||||
skylightIrradMap->constNum = Var::getTexUnitNum(); // used as texture unit num here
|
||||
|
||||
Var *skylightIrradMapTex = new Var("skylightIrradMapTex", "TextureCube");
|
||||
Var *skylightIrradMapTex = new Var("texture_skylightIrradMap", "TextureCube");
|
||||
skylightIrradMapTex->uniform = true;
|
||||
skylightIrradMapTex->texture = true;
|
||||
skylightIrradMapTex->constNum = skylightIrradMap->constNum;
|
||||
|
||||
/*Var *probeVec = new Var("probeVec", "float3");
|
||||
meta->addStatement(new GenOp(" @ = @[0] - @;\r\n", new DecOp(probeVec), inProbePos, wsPosition));
|
||||
|
||||
Var *nDotL = new Var("nDotL", "float");
|
||||
meta->addStatement(new GenOp(" @ = abs(dot(@, @));\r\n", new DecOp(nDotL), probeVec, wsNormal));
|
||||
|
||||
meta->addStatement(new GenOp(" \r\n"));
|
||||
|
||||
Var *reflectDir = new Var("reflectDir", "float3");
|
||||
meta->addStatement(new GenOp(" @ = reflect(-float4(@,0),float4(@,@)).xyz;\r\n", new DecOp(reflectDir), wsView, wsNormal, nDotL));
|
||||
|
||||
meta->addStatement(new GenOp(" \r\n"));
|
||||
|
||||
Var *nrDir = new Var("nrDir", "float3");
|
||||
meta->addStatement(new GenOp(" @ = normalize(@);\r\n", new DecOp(nrDir), reflectDir));
|
||||
|
||||
Var *rbmax = new Var("rbmax", "float3");
|
||||
meta->addStatement(new GenOp(" @ = (@[0] - @) / @;\r\n", new DecOp(rbmax), inProbeBoxMax, wsPosition, nrDir));
|
||||
|
||||
Var *rbmin = new Var("rbmin", "float3");
|
||||
meta->addStatement(new GenOp(" @ = (@[0] - @) / @;\r\n", new DecOp(rbmin), inProbeBoxMin, wsPosition, nrDir));
|
||||
|
||||
Var *rbMinMax = new Var("rbMinMax", "float3");
|
||||
meta->addStatement(new GenOp(" @ = (@ > 0.0) ? @ : @;\r\n", new DecOp(rbMinMax), nrDir, rbmax, rbmin));
|
||||
|
||||
meta->addStatement(new GenOp(" \r\n"));
|
||||
|
||||
Var *fa = new Var("fa", "float3");
|
||||
meta->addStatement(new GenOp(" @ = min(min(@.x,@.y),@.z);\r\n", new DecOp(fa), rbMinMax, rbMinMax, rbMinMax));
|
||||
|
||||
|
||||
meta->addStatement(new GenOp("/* if (dot( @, @ ) < 0.0f)\r\n", probeVec, wsNormal));
|
||||
meta->addStatement(new GenOp(" clip(@); *//*\r\n", fa));
|
||||
|
||||
|
||||
meta->addStatement(new GenOp(" \r\n"));
|
||||
|
||||
Var *posOnBox = new Var("posOnBox", "float3");
|
||||
meta->addStatement(new GenOp(" @ = @ + @ * @;\r\n", new DecOp(posOnBox), wsPosition, nrDir, fa));
|
||||
meta->addStatement(new GenOp(" @ = @ - @[0];\r\n", reflectDir, posOnBox, inProbePos));
|
||||
|
||||
meta->addStatement(new GenOp(" \r\n"));
|
||||
|
||||
Var *probeColor = new Var("wipProbeColor", "float3");
|
||||
|
||||
Var *probeMip = new Var("probeMip", "float");
|
||||
meta->addStatement(new GenOp(" @ = min((1.0 - @)*11.0 + 1.0, 8.0);\r\n", new DecOp(probeMip), smoothness));
|
||||
meta->addStatement(new GenOp(" @ = @.SampleLevel(@, @, @).rgb;\r\n", new DecOp(probeColor), inProbeCubemapTex, inProbeCubemap, reflectDir, probeMip));
|
||||
//meta->addStatement(new GenOp(" @ = @.rgb;\r\n", new DecOp(probeColor), inProbeTestColor));
|
||||
|
||||
Var *FRESNEL_BIAS = new Var("FRESNEL_BIAS", "float");
|
||||
meta->addStatement(new GenOp(" @ = 0.1;\r\n", new DecOp(FRESNEL_BIAS)));
|
||||
|
||||
Var *FRESNEL_POWER = new Var("FRESNEL_POWER", "float");
|
||||
meta->addStatement(new GenOp(" @ = 1;\r\n", new DecOp(FRESNEL_POWER)));
|
||||
|
||||
Var *angle = new Var("angle", "float");
|
||||
meta->addStatement(new GenOp(" @ = saturate(dot(@, @));\r\n", new DecOp(angle), wsView, wsNormal));
|
||||
meta->addStatement(new GenOp("\r\n"));
|
||||
|
||||
if (metalness)
|
||||
{
|
||||
Var *dColor = new Var("difColor", "float3");
|
||||
Var *reflectColor = new Var("reflctColor", "float3");
|
||||
|
||||
meta->addStatement(new GenOp(" @ = @.rgb - (@.rgb * @);\r\n", new DecOp(dColor), albedo, albedo, metalness));
|
||||
meta->addStatement(new GenOp(" @ = @; //@.rgb*(@).rgb*@;\r\n", new DecOp(reflectColor), probeColor, albedo, probeColor, metalness));
|
||||
|
||||
meta->addStatement(new GenOp(" @.rgb = simpleFresnel(@, @, @, @, @, @);\r\n", albedo, dColor, reflectColor, metalness, angle, FRESNEL_BIAS, FRESNEL_POWER));
|
||||
}
|
||||
//else if (lerpVal)
|
||||
// meta->addStatement(new GenOp(" @ *= float4(@.rgb*@.a, @.a);\r\n", targ, texCube, lerpVal, targ));
|
||||
else
|
||||
{
|
||||
meta->addStatement(new GenOp(" @.rgb = simpleFresnel(@.rgb, @, 0, @, @, @));\r\n", albedo, albedo, probeColor, angle, FRESNEL_BIAS, FRESNEL_POWER));
|
||||
}*/
|
||||
|
||||
Var *inTex = getInTexCoord("texCoord", "float2", componentList);
|
||||
if (!inTex)
|
||||
return;
|
||||
|
||||
Var *diffuseColor = (Var*)LangElement::find("diffuseColor");
|
||||
if (!diffuseColor)
|
||||
return;
|
||||
{
|
||||
diffuseColor = new Var;
|
||||
diffuseColor->setType("float4");
|
||||
diffuseColor->setName("diffuseColor");
|
||||
LangElement* colorDecl = new DecOp(diffuseColor);
|
||||
meta->addStatement(new GenOp(" @ = float4(1.0,1.0,1.0,1.0);\r\n", colorDecl)); //default to flat white
|
||||
}
|
||||
|
||||
Var *specularColor = (Var*)LangElement::find("specularColor");
|
||||
if (!specularColor)
|
||||
return;
|
||||
Var *matinfo = (Var*)LangElement::find("specularColor");
|
||||
if (!matinfo)
|
||||
{
|
||||
Var* metalness = (Var*)LangElement::find("metalness");
|
||||
if (!metalness)
|
||||
{
|
||||
metalness = new Var("metalness", "float");
|
||||
metalness->uniform = true;
|
||||
metalness->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
|
||||
Var* smoothness = (Var*)LangElement::find("smoothness");
|
||||
if (!smoothness)
|
||||
{
|
||||
smoothness = new Var("smoothness", "float");
|
||||
smoothness->uniform = true;
|
||||
smoothness->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
|
||||
matinfo = new Var("specularColor", "float4");
|
||||
LangElement* colorDecl = new DecOp(matinfo);
|
||||
meta->addStatement(new GenOp(" @ = float4(0.0,1.0,@,@);\r\n", colorDecl, smoothness, metalness)); //reconstruct matinfo, no ao darkening
|
||||
}
|
||||
|
||||
Var *bumpNormal = (Var*)LangElement::find("bumpNormal");
|
||||
if (!bumpNormal)
|
||||
return;
|
||||
{
|
||||
bumpNormal = new Var("bumpNormal", "float4");
|
||||
LangElement* colorDecl = new DecOp(bumpNormal);
|
||||
meta->addStatement(new GenOp(" @ = float4(1.0,0.0,0.0,0.0);\r\n", colorDecl)); //default to identity normal
|
||||
}
|
||||
|
||||
Var *wsEyePos = (Var*)LangElement::find("eyePosWorld");
|
||||
|
||||
|
|
@ -3193,13 +3146,17 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
|
|||
|
||||
//Reflection vec
|
||||
Var *surface = new Var("surface", "Surface");
|
||||
meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, bumpNormal, specularColor,
|
||||
meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, bumpNormal, matinfo,
|
||||
inTex, wsPosition, wsEyePos, wsView, worldToCamera));
|
||||
|
||||
meta->addStatement(new GenOp(" @.rgb = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t@,@,@,@,@,\r\n\t\t@,@,@,@,@,@).rgb;\r\n", albedo,
|
||||
surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, bbMinArray, bbMaxArray, inRefPosArray,
|
||||
hasSkylight, skylightIrradMap, skylightIrradMapTex, skylightSpecularMap, skylightSpecularMapTex,
|
||||
BRDFTexture, BRDFTextureTex, irradianceCubemapAR, irradianceCubemapARTex, specularCubemapAR, specularCubemapARTex));
|
||||
String computeForwardProbes = String::String(" @.rgb += computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t");
|
||||
computeForwardProbes += String::String("@,TORQUE_SAMPLER2D_MAKEARG(@),\r\n\t\t");
|
||||
computeForwardProbes += String::String("TORQUE_SAMPLERCUBE_MAKEARG(@), TORQUE_SAMPLERCUBE_MAKEARG(@), \r\n\t\t");
|
||||
computeForwardProbes += String::String("TORQUE_SAMPLERCUBEARRAY_MAKEARG(@),TORQUE_SAMPLERCUBEARRAY_MAKEARG(@)).rgb; \r\n");
|
||||
|
||||
meta->addStatement(new GenOp(computeForwardProbes.c_str(), albedo, surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, bbMinArray, bbMaxArray, inRefPosArray,
|
||||
hasSkylight, BRDFTexture,
|
||||
skylightIrradMap, skylightSpecularMap,
|
||||
irradianceCubemapAR, specularCubemapAR));
|
||||
|
||||
//meta->addStatement(new GenOp(" @.rgb = @.roughness.xxx;\r\n", albedo, surface));
|
||||
|
||||
|
|
@ -3210,11 +3167,8 @@ ShaderFeature::Resources ReflectionProbeFeatHLSL::getResources(const MaterialFea
|
|||
{
|
||||
Resources res;
|
||||
|
||||
//res.numTex = 4;
|
||||
//res.numTexReg = 4;
|
||||
|
||||
res.numTex = 4;
|
||||
res.numTexReg = 4;
|
||||
res.numTex = 5;
|
||||
res.numTexReg = 5;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
@ -3226,8 +3180,16 @@ void ReflectionProbeFeatHLSL::setTexData(Material::StageData &stageDat,
|
|||
{
|
||||
if (stageFeatures.features[MFT_ReflectionProbes])
|
||||
{
|
||||
passData.mSamplerNames[texIndex] = "BRDFTexture";
|
||||
passData.mTexType[texIndex++] = Material::Standard;
|
||||
// assuming here that it is a scenegraph cubemap
|
||||
passData.mSamplerNames[texIndex] = "inProbeCubemap";
|
||||
passData.mSamplerNames[texIndex] = "specularCubemapAR";
|
||||
passData.mTexType[texIndex++] = Material::SGCube;
|
||||
passData.mSamplerNames[texIndex] = "irradianceCubemapAR";
|
||||
passData.mTexType[texIndex++] = Material::SGCube;
|
||||
passData.mSamplerNames[texIndex] = "skylightSpecularMap";
|
||||
passData.mTexType[texIndex++] = Material::SGCube;
|
||||
passData.mSamplerNames[texIndex] = "skylightIrradMap";
|
||||
passData.mTexType[texIndex++] = Material::SGCube;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -303,9 +303,9 @@ float3 boxProject(float3 wsPosition, float3 wsReflectVec, float4x4 worldToObj, f
|
|||
float4 computeForwardProbes(Surface surface,
|
||||
float cubeMips, float 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],
|
||||
float hasSkylight, SamplerState skylightIrradMap, TextureCube skylightIrradMapTex, SamplerState skylightSpecularMap, TextureCube skylightSpecularMapTex,
|
||||
SamplerState BRDFTexture, Texture2D BRDFTextureTex, SamplerState irradianceCubemapAR, TextureCubeArray irradianceCubemapARTex,
|
||||
SamplerState specularCubemapAR, TextureCubeArray specularCubemapARTex)
|
||||
float hasSkylight, TORQUE_SAMPLER2D(BRDFTexture),
|
||||
TORQUE_SAMPLERCUBE(skylightIrradMap), TORQUE_SAMPLERCUBE(skylightSpecularMap),
|
||||
TORQUE_SAMPLERCUBEARRAY(irradianceCubemapAR), TORQUE_SAMPLERCUBEARRAY(specularCubemapAR))
|
||||
{
|
||||
int i = 0;
|
||||
float blendFactor[MAX_FORWARD_PROBES];
|
||||
|
|
@ -380,16 +380,16 @@ float4 computeForwardProbes(Surface surface,
|
|||
int cubemapIdx = probeConfigData[i].a;
|
||||
float3 dir = boxProject(surface.P, surface.R, worldToObjArray[i], bbMinArray[i].xyz, bbMaxArray[i].xyz, inRefPosArray[i].xyz);
|
||||
|
||||
irradiance += irradianceCubemapARTex.SampleLevel(irradianceCubemapAR,float4(dir,cubemapIdx),0).xyz * contrib;
|
||||
specular += specularCubemapARTex.SampleLevel(specularCubemapAR,float4(dir,cubemapIdx),lod).xyz * contrib;
|
||||
irradiance += TORQUE_TEXCUBEARRAYLOD(irradianceCubemapAR, dir, cubemapIdx, 0).xyz * contrib;
|
||||
specular += TORQUE_TEXCUBEARRAYLOD(specularCubemapAR, dir, cubemapIdx, lod).xyz * contrib;
|
||||
alpha -= contrib;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasSkylight && alpha > 0.001)
|
||||
{
|
||||
irradiance += skylightIrradMapTex.SampleLevel(skylightIrradMap,surface.R,0).xyz * alpha;
|
||||
specular += skylightSpecularMapTex.SampleLevel(skylightSpecularMap,surface.R,lod).xyz * alpha;
|
||||
irradiance += TORQUE_TEXCUBELOD(skylightIrradMap, float4(surface.R, 0)).xyz * alpha;
|
||||
specular += TORQUE_TEXCUBELOD(skylightSpecularMap, float4(surface.R, lod)).xyz * alpha;
|
||||
}
|
||||
|
||||
float3 F = FresnelSchlickRoughness(surface.NdotV, surface.f0, surface.roughness);
|
||||
|
|
@ -400,13 +400,12 @@ float4 computeForwardProbes(Surface surface,
|
|||
|
||||
//apply brdf
|
||||
//Do it once to save on texture samples
|
||||
float2 brdf = BRDFTextureTex.SampleLevel(BRDFTexture,float2(surface.roughness, surface.NdotV),0).xy;
|
||||
float2 brdf = TORQUE_TEX2DLOD(BRDFTexture,float4(surface.roughness, surface.NdotV, 0.0, 0.0)).xy;
|
||||
specular *= brdf.x * F + brdf.y;
|
||||
|
||||
//final diffuse color
|
||||
float3 diffuse = kD * irradiance * surface.baseColor.rgb;
|
||||
float4 finalColor = float4(diffuse + specular * surface.ao, 1.0);
|
||||
|
||||
finalColor = float4(irradiance.rgb,1);
|
||||
return finalColor;
|
||||
}
|
||||
Loading…
Reference in a new issue