Merge pull request #809 from Azaezel/alpha40/ambientAug

allow ambient light injection into ibl
This commit is contained in:
Brian Roberts 2022-06-07 22:12:24 -05:00 committed by GitHub
commit 53aea82614
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 39 additions and 10 deletions

View file

@ -1425,6 +1425,7 @@ void DecalManager::prepRenderImage( SceneRenderState* state )
ri->prim->numPrimitives = currentBatch->iCount / 3;
ri->prim->startVertex = 0;
ri->prim->numVertices = currentBatch->vCount;
ri->translucentSort = !currentBatch->matInst->getMaterial()->isTranslucent();
// Ugly hack for ProjectedShadow!
if ( customTex )

View file

@ -734,7 +734,7 @@ void DecalRoad::prepRenderImage( SceneRenderState* state )
coreRI.sortDistSq = F32_MAX;
// If we need lights then set them up.
if ( matInst->isForwardLit() )
if ( matInst->isForwardLit() && !coreRI.lights[0])
{
LightQuery query;
query.init( getWorldSphere() );
@ -784,6 +784,7 @@ void DecalRoad::prepRenderImage( SceneRenderState* state )
*ri = coreRI;
ri->matInst = matInst;
ri->prim = renderPass->allocPrim();
ri->prim->type = GFXTriangleList;
ri->prim->minIndex = 0;
@ -791,6 +792,7 @@ void DecalRoad::prepRenderImage( SceneRenderState* state )
ri->prim->numPrimitives = triangleCount;
ri->prim->startVertex = 0;
ri->prim->numVertices = endBatch.endVert + 1;
ri->translucentSort = !matInst->getMaterial()->isTranslucent();
// For sorting we first sort by render priority
// and then by objectId.

View file

@ -536,7 +536,7 @@ bool Material::onAdd()
if (mTranslucentBlendOp >= NumBlendTypes || mTranslucentBlendOp < 0)
{
Con::errorf("Invalid blend op in material: %s", getName());
mTranslucentBlendOp = LerpAlpha;
mTranslucentBlendOp = PreMul;
}
SimSet* matSet = MATMGR->getMaterialSet();

View file

@ -3033,6 +3033,15 @@ void ReflectionProbeFeatGLSL::processPix(Vector<ShaderComponent*>& componentList
return;
}
Var *curColor = (Var *)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
//Reflection vec
Var *ibl = (Var *)LangElement::find("ibl");
if (!ibl)
{
ibl = new Var("ibl", "float3");
}
Var* eyePos = (Var*)LangElement::find("eyePosWorld");
if (!eyePos)
{
@ -3042,18 +3051,26 @@ void ReflectionProbeFeatGLSL::processPix(Vector<ShaderComponent*>& componentList
eyePos->uniform = true;
eyePos->constSortPos = cspPass;
}
Var *curColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
//Reflection vec
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, eyePos,
meta->addStatement(new GenOp(computeForwardProbes.c_str(), new DecOp(ibl), surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, refScaleArray, inRefPosArray, eyePos,
skylightCubemapIdx, BRDFTexture,
irradianceCubemapAR, specularCubemapAR));
Var *ambient = (Var *)LangElement::find("ambient");
if (!ambient)
{
ambient = new Var("ambient", "vec3");
eyePos->uniform = true;
eyePos->constSortPos = cspPass;
}
meta->addStatement(new GenOp(" @.rgb *= @.rgb;\r\n", ibl, ambient));
meta->addStatement(new GenOp(" @.rgb = @.rgb;\r\n", curColor, ibl));
output = meta;
}

View file

@ -3149,7 +3149,15 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
meta->addStatement(new GenOp(computeForwardProbes.c_str(), new DecOp(ibl), surface, cubeMips, numProbes, worldToObjArray, probeConfigData, inProbePosArray, refScaleArray, inRefPosArray, eyePos,
skylightCubemapIdx, BRDFTexture,
irradianceCubemapAR, specularCubemapAR));
Var *ambient = (Var *)LangElement::find("ambient");
if (!ambient)
{
ambient = new Var("ambient","float3");
eyePos->uniform = true;
eyePos->constSortPos = cspPass;
}
meta->addStatement(new GenOp(" @.rgb *= @.rgb;\r\n", ibl, ambient));
meta->addStatement(new GenOp(" @.rgb = @.rgb;\r\n", curColor, ibl));
output = meta;

View file

@ -12,6 +12,7 @@ uniform sampler2D colorBuffer;
uniform sampler2D matInfoBuffer;
uniform sampler2D BRDFTexture;
uniform vec3 ambientColor;
uniform vec4 rtParams0;
uniform vec4 vsFarPlane;
uniform mat4 cameraToWorld;
@ -202,6 +203,6 @@ void main()
#if CAPTURING == 1
OUT_col = vec4(mix(surface.baseColor.rgb,(irradiance + specular* horizon) ,surface.metalness/2),0);
#else
OUT_col = vec4((irradiance + specular* horizon) , 0);//alpha writes disabled
OUT_col = vec4((irradiance + specular* horizon)*ambientColor, 0);//alpha writes disabled
#endif
}

View file

@ -8,7 +8,7 @@ TORQUE_UNIFORM_SAMPLER2D(deferredBuffer, 0);
TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 1);
TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 2);
TORQUE_UNIFORM_SAMPLER2D(BRDFTexture, 3);
uniform float3 ambientColor;
uniform float4 rtParams0;
uniform float4 vsFarPlane;
uniform float4x4 cameraToWorld;
@ -190,6 +190,6 @@ float4 main(PFXVertToPix IN) : SV_TARGET
#if CAPTURING == 1
return float4(lerp(surface.baseColor.rgb,(irradiance + specular* horizon) ,surface.metalness/2),0);
#else
return float4((irradiance + specular* horizon) , 0);//alpha writes disabled
return float4((irradiance + specular* horizon)*ambientColor, 0);//alpha writes disabled
#endif
}