mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-04 04:50:31 +00:00
Cleaned and repacked work to update the probe bin and reflection probe behavior to clean and standardize it.
This commit is contained in:
parent
68ae0ca96d
commit
79eebdd5f3
24 changed files with 1113 additions and 1012 deletions
|
|
@ -758,7 +758,7 @@ Var* ShaderFeatureGLSL::getWsView( Var *wsPosition, MultiLine *meta )
|
|||
eyePos->constSortPos = cspPass;
|
||||
}
|
||||
|
||||
meta->addStatement( new GenOp( " @ = normalize( @ - @ );\r\n",
|
||||
meta->addStatement( new GenOp( " @ = @ - @;\r\n",
|
||||
new DecOp( wsView ), eyePos, wsPosition ) );
|
||||
}
|
||||
|
||||
|
|
@ -838,79 +838,66 @@ Var* ShaderFeatureGLSL::addOutDetailTexCoord( Vector<ShaderComponent*> &compon
|
|||
|
||||
Var* ShaderFeatureGLSL::getSurface(Vector<ShaderComponent*>& componentList, MultiLine* meta, const MaterialFeatureData& fd)
|
||||
{
|
||||
ShaderConnector* connectComp = dynamic_cast<ShaderConnector*>(componentList[C_CONNECTOR]);
|
||||
|
||||
Var* diffuseColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||
|
||||
Var* ormConfig = (Var*)LangElement::find("ORMConfig");
|
||||
if (!ormConfig)
|
||||
{
|
||||
Var* metalness = (Var*)LangElement::find("metalness");
|
||||
if (!metalness)
|
||||
{
|
||||
metalness = new Var("metalness", "float");
|
||||
metalness->uniform = true;
|
||||
metalness->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
|
||||
Var* roughness = (Var*)LangElement::find("roughness");
|
||||
if (!roughness)
|
||||
{
|
||||
roughness = new Var("roughness", "float");
|
||||
roughness->uniform = true;
|
||||
roughness->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
|
||||
ormConfig = new Var("ORMConfig", "vec4");
|
||||
LangElement* colorDecl = new DecOp(ormConfig);
|
||||
meta->addStatement(new GenOp(" @ = vec4(0.0,1.0,@,@);\r\n", colorDecl, roughness, metalness)); //reconstruct ormConfig, no ao darkening
|
||||
}
|
||||
|
||||
Var* normal = (Var*)LangElement::find("normal");
|
||||
if (!normal)
|
||||
{
|
||||
normal = new Var("normal", "vec3");
|
||||
meta->addStatement(new GenOp(" @;\r\n\n", new DecOp(normal)));
|
||||
|
||||
Var* wsNormal = (Var*)LangElement::find("wsNormal");
|
||||
if (!fd.features[MFT_NormalMap])
|
||||
{
|
||||
if (!wsNormal)
|
||||
wsNormal = getInWorldNormal(componentList);
|
||||
meta->addStatement(new GenOp(" @ = normalize( @ );\r\n\n", normal, wsNormal));
|
||||
}
|
||||
else
|
||||
{
|
||||
meta->addStatement(new GenOp(" @ = normalize( @ );\r\n", normal, wsNormal));
|
||||
}
|
||||
}
|
||||
|
||||
Var* wsEyePos = (Var*)LangElement::find("eyePosWorld");
|
||||
|
||||
if (!wsEyePos)
|
||||
{
|
||||
wsEyePos = new Var("eyePosWorld", "vec3");
|
||||
wsEyePos->uniform = true;
|
||||
wsEyePos->constSortPos = cspPass;
|
||||
}
|
||||
|
||||
Var* wsPosition = getInWsPosition(componentList);
|
||||
Var* wsView = getWsView(wsPosition, meta);
|
||||
|
||||
Var* surface = (Var*)LangElement::find("surface");
|
||||
Var *surface = (Var *)LangElement::find("surface");
|
||||
|
||||
if (!surface)
|
||||
{
|
||||
Var* diffuseColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||
|
||||
Var* ormConfig = (Var*)LangElement::find("ORMConfig");
|
||||
if (!ormConfig)
|
||||
{
|
||||
Var* metalness = (Var*)LangElement::find("metalness");
|
||||
if (!metalness)
|
||||
{
|
||||
metalness = new Var("metalness", "float");
|
||||
metalness->uniform = true;
|
||||
metalness->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
|
||||
Var* roughness = (Var*)LangElement::find("roughness");
|
||||
if (!roughness)
|
||||
{
|
||||
roughness = new Var("roughness", "float");
|
||||
roughness->uniform = true;
|
||||
roughness->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
|
||||
ormConfig = new Var("ORMConfig", "vec4");
|
||||
LangElement* colorDecl = new DecOp(ormConfig);
|
||||
meta->addStatement(new GenOp(" @ = vec4(0.0,1.0,@,@);\r\n", colorDecl, roughness, metalness)); //reconstruct ormConfig, no ao darkening
|
||||
}
|
||||
|
||||
Var* normal = (Var*)LangElement::find("normal");
|
||||
if (!normal)
|
||||
{
|
||||
normal = new Var("normal", "vec3");
|
||||
meta->addStatement(new GenOp(" @;\r\n\n", new DecOp(normal)));
|
||||
|
||||
Var *wsNormal = (Var *)LangElement::find("wsNormal");
|
||||
if (!wsNormal)
|
||||
wsNormal = getInWorldNormal(componentList);
|
||||
|
||||
meta->addStatement(new GenOp(" @ = normalize( @ );\r\n", normal, wsNormal));
|
||||
}
|
||||
|
||||
Var* wsEyePos = (Var*)LangElement::find("eyePosWorld");
|
||||
|
||||
if (!wsEyePos)
|
||||
{
|
||||
wsEyePos = new Var("eyePosWorld", "vec3");
|
||||
wsEyePos->uniform = true;
|
||||
wsEyePos->constSortPos = cspPass;
|
||||
}
|
||||
|
||||
Var* wsPosition = getInWsPosition(componentList);
|
||||
Var* wsView = getWsView(wsPosition, meta);
|
||||
|
||||
surface = new Var("surface", "Surface");
|
||||
meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, normal, ormConfig,
|
||||
meta->addStatement(new GenOp(" @ = createForwardSurface(@,normalize(@),@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, normal, ormConfig,
|
||||
wsPosition, wsEyePos, wsView));
|
||||
}
|
||||
|
||||
/*Var* surface = (Var*)LangElement::find("surface");
|
||||
if (!surface)
|
||||
{
|
||||
surface = new Var("surface", "float");
|
||||
}*/
|
||||
return surface;
|
||||
}
|
||||
//****************************************************************************
|
||||
|
|
@ -3003,12 +2990,12 @@ void ReflectionProbeFeatGLSL::processPix(Vector<ShaderComponent*>& componentList
|
|||
inRefPosArray->uniform = true;
|
||||
inRefPosArray->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
Var * refScaleArray = new Var("inRefScale", "vec4");
|
||||
Var * refScaleArray = new Var("inRefScaleArray", "vec4");
|
||||
refScaleArray->arraySize = MAX_FORWARD_PROBES;
|
||||
refScaleArray->uniform = true;
|
||||
refScaleArray->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
Var * probeConfigData = new Var("inProbeConfigData", "vec4");
|
||||
Var * probeConfigData = new Var("inProbeConfigDataArray", "vec4");
|
||||
probeConfigData->arraySize = MAX_FORWARD_PROBES;
|
||||
probeConfigData->uniform = true;
|
||||
probeConfigData->constSortPos = cspPotentialPrimitive;
|
||||
|
|
@ -3026,12 +3013,12 @@ void ReflectionProbeFeatGLSL::processPix(Vector<ShaderComponent*>& componentList
|
|||
BRDFTexture->sampler = true;
|
||||
BRDFTexture->constNum = Var::getTexUnitNum(); // used as texture unit num here
|
||||
|
||||
Var * specularCubemapAR = new Var("inSpecularCubemapAR", "samplerCubeArray");
|
||||
Var * specularCubemapAR = new Var("SpecularCubemapAR", "samplerCubeArray");
|
||||
specularCubemapAR->uniform = true;
|
||||
specularCubemapAR->sampler = true;
|
||||
specularCubemapAR->constNum = Var::getTexUnitNum();
|
||||
|
||||
Var * irradianceCubemapAR = new Var("inIrradianceCubemapAR", "samplerCubeArray");
|
||||
Var * irradianceCubemapAR = new Var("IrradianceCubemapAR", "samplerCubeArray");
|
||||
irradianceCubemapAR->uniform = true;
|
||||
irradianceCubemapAR->sampler = true;
|
||||
irradianceCubemapAR->constNum = Var::getTexUnitNum();
|
||||
|
|
@ -3044,14 +3031,24 @@ void ReflectionProbeFeatGLSL::processPix(Vector<ShaderComponent*>& componentList
|
|||
return;
|
||||
}
|
||||
|
||||
Var* eyePos = (Var*)LangElement::find("eyePosWorld");
|
||||
if (!eyePos)
|
||||
{
|
||||
eyePos = new Var;
|
||||
eyePos->setType("vec3");
|
||||
eyePos->setName("eyePosWorld");
|
||||
eyePos->uniform = true;
|
||||
eyePos->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
|
||||
Var *curColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||
|
||||
//Reflection vec
|
||||
String computeForwardProbes = String(" @.rgb = computeForwardProbes(@,@,@,@,@,@,@,@,\r\n\t\t");
|
||||
String computeForwardProbes = String(" @.rgb = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t");
|
||||
computeForwardProbes += String("@,@,\r\n\t\t");
|
||||
computeForwardProbes += String("@,@).rgb; \r\n");
|
||||
|
||||
meta->addStatement(new GenOp(computeForwardProbes.c_str(), curColor, surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, refScaleArray, inRefPosArray,
|
||||
meta->addStatement(new GenOp(computeForwardProbes.c_str(), curColor, surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, refScaleArray, inRefPosArray, eyePos,
|
||||
skylightCubemapIdx, BRDFTexture,
|
||||
irradianceCubemapAR, specularCubemapAR));
|
||||
|
||||
|
|
@ -3078,9 +3075,9 @@ void ReflectionProbeFeatGLSL::setTexData(Material::StageData& stageDat,
|
|||
passData.mSamplerNames[texIndex] = "BRDFTexture";
|
||||
passData.mTexType[texIndex++] = Material::Standard;
|
||||
// assuming here that it is a scenegraph cubemap
|
||||
passData.mSamplerNames[texIndex] = "inSpecularCubemapAR";
|
||||
passData.mSamplerNames[texIndex] = "SpecularCubemapAR";
|
||||
passData.mTexType[texIndex++] = Material::SGCube;
|
||||
passData.mSamplerNames[texIndex] = "inIrradianceCubemapAR";
|
||||
passData.mSamplerNames[texIndex] = "IrradianceCubemapAR";
|
||||
passData.mTexType[texIndex++] = Material::SGCube;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue