shift pbrconfig to ORM

This commit is contained in:
AzaezelX 2020-09-30 13:51:12 -05:00
parent 22b0785c73
commit 0c7811bd1a
54 changed files with 879 additions and 680 deletions

View file

@ -841,8 +841,8 @@ Var* ShaderFeatureGLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
Var* diffuseColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
Var* pbrConfig = (Var*)LangElement::find("PBRConfig");
if (!pbrConfig)
Var* ormConfig = (Var*)LangElement::find("ORMConfig");
if (!ormConfig)
{
Var* metalness = (Var*)LangElement::find("metalness");
if (!metalness)
@ -852,17 +852,17 @@ Var* ShaderFeatureGLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
metalness->constSortPos = cspPotentialPrimitive;
}
Var* smoothness = (Var*)LangElement::find("smoothness");
if (!smoothness)
Var* roughness = (Var*)LangElement::find("roughness");
if (!roughness)
{
smoothness = new Var("smoothness", "float");
smoothness->uniform = true;
smoothness->constSortPos = cspPotentialPrimitive;
roughness = new Var("roughness", "float");
roughness->uniform = true;
roughness->constSortPos = cspPotentialPrimitive;
}
pbrConfig = new Var("PBRConfig", "vec4");
LangElement* colorDecl = new DecOp(pbrConfig);
meta->addStatement(new GenOp(" @ = vec4(0.0,1.0,@,@);\r\n", colorDecl, smoothness, metalness)); //reconstruct pbrConfig, no ao darkening
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* wsNormal = (Var*)LangElement::find("wsNormal");
@ -899,7 +899,7 @@ Var* ShaderFeatureGLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
if (!surface)
{
surface = new Var("surface", "Surface");
meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, normal, pbrConfig,
meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, normal, ormConfig,
wsPosition, wsEyePos, wsView));
}
@ -1922,9 +1922,9 @@ void ReflectCubeFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
LangElement *texCube = NULL;
Var* matinfo = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
Var *smoothness = (Var*)LangElement::find("smoothness");
if (smoothness) //try to grab smoothness directly
texCube = new GenOp("textureLod( @, @, min((1.0 - @)*@ + 1.0, @))", cubeMap, reflectVec, smoothness, cubeMips, cubeMips);
Var *roughness = (Var*)LangElement::find("roughness");
if (roughness) //try to grab roughness directly
texCube = new GenOp("textureLod( @, @, min((1.0 - @)*@ + 1.0, @))", cubeMap, reflectVec, roughness, cubeMips, cubeMips);
else if (glossColor) //failing that, try and find color data
texCube = new GenOp("textureLod( @, @, min((1.0 - @.b)*@ + 1.0, @))", cubeMap, reflectVec, glossColor, cubeMips, cubeMips);
else //failing *that*, just draw the cubemap
@ -2219,7 +2219,7 @@ void RTLightingFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
Con::errorf("ShaderGen::RTLightingFeatGLSL() - failed to generate surface!");
return;
}
Var *smoothness = (Var*)LangElement::find("smoothness");
Var *roughness = (Var*)LangElement::find("roughness");
Var *metalness = (Var*)LangElement::find("metalness");

View file

@ -64,7 +64,7 @@ void _initShaderGenGLSL( ShaderGen *shaderGen )
FEATUREMGR->registerFeature( MFT_DetailMap, new DetailFeatGLSL );
FEATUREMGR->registerFeature( MFT_StaticCubemap, new NamedFeatureGLSL( "Static Cubemap" ) );
FEATUREMGR->registerFeature( MFT_CubeMap, new ReflectCubeFeatGLSL );
FEATUREMGR->registerFeature( MFT_InvertSmoothness, new NamedFeatureGLSL("Roughest = 1.0"));
FEATUREMGR->registerFeature( MFT_InvertRoughness, new NamedFeatureGLSL("Roughest = 1.0"));
FEATUREMGR->registerFeature( MFT_AccuMap, new AccuTexFeatGLSL );
FEATUREMGR->registerFeature( MFT_IsTranslucent, new NamedFeatureGLSL( "Translucent" ) );
FEATUREMGR->registerFeature( MFT_IsTranslucentZWrite, new NamedFeatureGLSL( "Translucent ZWrite" ) );
@ -99,8 +99,8 @@ void _initShaderGenGLSL( ShaderGen *shaderGen )
// Deferred Shading
FEATUREMGR->registerFeature( MFT_isDeferred, new NamedFeatureGLSL( "Deferred Material" ) );
FEATUREMGR->registerFeature( MFT_PBRConfigMap, new PBRConfigMapGLSL );
FEATUREMGR->registerFeature( MFT_PBRConfigVars, new PBRConfigVarsGLSL );
FEATUREMGR->registerFeature( MFT_OrmMap, new DeferredOrmMapGLSL );
FEATUREMGR->registerFeature( MFT_ORMConfigVars, new ORMConfigVarsGLSL );
FEATUREMGR->registerFeature( MFT_MatInfoFlags, new MatInfoFlagsGLSL );
FEATUREMGR->registerFeature( MFT_GlowMap, new GlowMapGLSL);
FEATUREMGR->registerFeature( MFT_isBackground, new NamedFeatureGLSL("Background Object"));

View file

@ -155,9 +155,9 @@ void DebugVizHLSL::processPix(Vector<ShaderComponent*>& componentList,
Var* irradianceCubemapAR = (Var*)LangElement::find("irradianceCubemapAR");
Var* irradianceCubemapARTex = (Var*)LangElement::find("texture_irradianceCubemapAR");
Var* matinfo = (Var*)LangElement::find("PBRConfig");
Var* matinfo = (Var*)LangElement::find("ORMConfig");
Var* metalness = (Var*)LangElement::find("metalness");
Var* smoothness = (Var*)LangElement::find("smoothness");
Var* roughness = (Var*)LangElement::find("roughness");
Var* wsEyePos = (Var*)LangElement::find("eyePosWorld");

View file

@ -848,8 +848,8 @@ Var* ShaderFeatureHLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
Var* diffuseColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
Var* pbrConfig = (Var*)LangElement::find("PBRConfig");
if (!pbrConfig)
Var* ormConfig = (Var*)LangElement::find("ORMConfig");
if (!ormConfig)
{
Var* metalness = (Var*)LangElement::find("metalness");
if (!metalness)
@ -859,17 +859,17 @@ Var* ShaderFeatureHLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
metalness->constSortPos = cspPotentialPrimitive;
}
Var* smoothness = (Var*)LangElement::find("smoothness");
if (!smoothness)
Var* roughness = (Var*)LangElement::find("roughness");
if (!roughness)
{
smoothness = new Var("smoothness", "float");
smoothness->uniform = true;
smoothness->constSortPos = cspPotentialPrimitive;
roughness = new Var("roughness", "float");
roughness->uniform = true;
roughness->constSortPos = cspPotentialPrimitive;
}
pbrConfig = new Var("PBRConfig", "float4");
LangElement* colorDecl = new DecOp(pbrConfig);
meta->addStatement(new GenOp(" @ = float4(0.0,1.0,@,@);\r\n", colorDecl, smoothness, metalness)); //reconstruct matinfo, no ao darkening
ormConfig = new Var("ORMConfig", "float4");
LangElement* colorDecl = new DecOp(ormConfig);
meta->addStatement(new GenOp(" @ = float4(0.0,1.0,@,@);\r\n", colorDecl, roughness, metalness)); //reconstruct matinfo, no ao darkening
}
Var* normal = (Var*)LangElement::find("normal");
@ -902,7 +902,7 @@ Var* ShaderFeatureHLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
if (!surface)
{
surface = new Var("surface", "Surface");
meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, normal, pbrConfig,
meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, normal, ormConfig,
wsPosition, wsEyePos, wsView));
}
@ -1327,7 +1327,7 @@ void LightmapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
lightMapTex->texture = true;
lightMapTex->constNum = lightMap->constNum;
// argh, PBRConfigMap should prob use this too
// argh, ORMConfigMap should prob use this too
if( fd.features[MFT_NormalMap] )
{
Var *lmColor = new Var;
@ -1985,11 +1985,11 @@ void ReflectCubeFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
LangElement *texCube = NULL;
Var* matinfo = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
Var *smoothness = (Var*)LangElement::find("smoothness");
Var *roughness = (Var*)LangElement::find("roughness");
if (smoothness) //try to grab smoothness directly
if (roughness) //try to grab roughness directly
{
texCube = new GenOp("@.SampleLevel( @, float3(@).rgb, min((1.0 - @)*@ + 1.0, @))", cubeMapTex, cubeMap, reflectVec, smoothness, cubeMips, cubeMips);
texCube = new GenOp("@.SampleLevel( @, float3(@).rgb, min((1.0 - @)*@ + 1.0, @))", cubeMapTex, cubeMap, reflectVec, roughness, cubeMips, cubeMips);
}
else if (glossColor)//failing that, try and find color data
{
@ -2287,7 +2287,7 @@ void RTLightingFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
Con::errorf("ShaderGen::RTLightingFeatHLSL() - failed to generate surface!");
return;
}
Var *smoothness = (Var*)LangElement::find("smoothness");
Var *roughness = (Var*)LangElement::find("roughness");
Var *metalness = (Var*)LangElement::find("metalness");

View file

@ -65,7 +65,7 @@ void _initShaderGenHLSL( ShaderGen *shaderGen )
FEATUREMGR->registerFeature( MFT_StaticCubemap, new NamedFeatureHLSL( "Static Cubemap" ) );
FEATUREMGR->registerFeature( MFT_CubeMap, new ReflectCubeFeatHLSL );
FEATUREMGR->registerFeature( MFT_ReflectionProbes, new ReflectionProbeFeatHLSL);
FEATUREMGR->registerFeature( MFT_InvertSmoothness, new NamedFeatureHLSL( "Roughest = 1.0" ) );
FEATUREMGR->registerFeature( MFT_InvertRoughness, new NamedFeatureHLSL( "Roughest = 1.0" ) );
FEATUREMGR->registerFeature( MFT_IsTranslucent, new NamedFeatureHLSL( "Translucent" ) );
FEATUREMGR->registerFeature( MFT_IsTranslucentZWrite, new NamedFeatureHLSL( "Translucent ZWrite" ) );
FEATUREMGR->registerFeature( MFT_Visibility, new VisibilityFeatHLSL );
@ -102,8 +102,8 @@ void _initShaderGenHLSL( ShaderGen *shaderGen )
FEATUREMGR->registerFeature( MFT_ImposterVert, new ImposterVertFeatureHLSL );
FEATUREMGR->registerFeature( MFT_isDeferred, new NamedFeatureHLSL( "Deferred Material" ) );
FEATUREMGR->registerFeature( MFT_PBRConfigMap, new PBRConfigMapHLSL);
FEATUREMGR->registerFeature( MFT_PBRConfigVars, new PBRConfigVarsHLSL);
FEATUREMGR->registerFeature( MFT_OrmMap, new DeferredOrmMapHLSL);
FEATUREMGR->registerFeature( MFT_ORMConfigVars, new ORMConfigVarsHLSL);
FEATUREMGR->registerFeature( MFT_MatInfoFlags, new MatInfoFlagsHLSL );
FEATUREMGR->registerFeature( MFT_GlowMap, new GlowMapHLSL);
FEATUREMGR->registerFeature( MFT_isBackground, new NamedFeatureHLSL("Background Object"));

View file

@ -73,8 +73,8 @@ const String ShaderGenVars::vectorLightDirection("$vectorLightDirection");
const String ShaderGenVars::vectorLightColor("$vectorLightColor");
const String ShaderGenVars::vectorLightBrightness("$vectorLightBrightness");
const String ShaderGenVars::pbrConfig("$PBRConfig");
const String ShaderGenVars::smoothness("$smoothness");
const String ShaderGenVars::ormConfig("$ORMConfig");
const String ShaderGenVars::roughness("$roughness");
const String ShaderGenVars::metalness("$metalness");
const String ShaderGenVars::glowMul("$glowMul");

View file

@ -85,8 +85,8 @@ struct ShaderGenVars
const static String vectorLightColor;
const static String vectorLightBrightness;
const static String pbrConfig;
const static String smoothness;
const static String ormConfig;
const static String roughness;
const static String metalness;
const static String glowMul;