Renamed r_useIBL to r_usePBR and fixed r_pbrDebug rendering

This commit is contained in:
Robert Beckebans 2020-04-26 10:38:28 +02:00
parent c87e9e1711
commit 605944924a
7 changed files with 37 additions and 31 deletions

View file

@ -124,14 +124,14 @@ void main( PS_IN fragment, out PS_OUT result )
half3 diffuseColor = baseColor * ( 1.0 - metallic );
half3 specularColor = lerp( dielectricColor, baseColor, metallic );
float3 kS = Fresnel_SchlickRoughness( specularColor, vDotN, roughness );
float3 kD = ( float3( 1.0, 1.0, 1.0 ) - kS ) * ( 1.0 - metallic );
#if defined( DEBUG_PBR )
diffuseColor = half3( 0.0, 0.0, 0.0 );
specularColor = half3( 0.0, 1.0, 0.0 );
#endif
float3 kS = Fresnel_SchlickRoughness( specularColor, vDotN, roughness );
float3 kD = ( float3( 1.0, 1.0, 1.0 ) - kS ) * ( 1.0 - metallic );
#else
// HACK calculate roughness from D3 gloss maps
float Y = dot( LUMINANCE_SRGB.rgb, specMapSRGB.rgb );
@ -144,16 +144,16 @@ void main( PS_IN fragment, out PS_OUT result )
half3 diffuseColor = diffuseMap;
half3 specularColor = specMap.rgb;
float3 kS = Fresnel_SchlickRoughness( specularColor, vDotN, roughness );
// metalness is missing
float3 kD = ( float3( 1.0, 1.0, 1.0 ) - kS );
#if defined( DEBUG_PBR )
diffuseColor = half3( 0.0, 0.0, 0.0 );
specularColor = half3( 1.0, 0.0, 0.0 );
#endif
float3 kS = Fresnel_SchlickRoughness( specularColor, vDotN, roughness );
// NOTE: metalness is missing
float3 kD = ( float3( 1.0, 1.0, 1.0 ) - kS );
#endif
//diffuseColor = half3( 1.0, 1.0, 1.0 );

View file

@ -200,7 +200,7 @@ static srfTriangles_t* R_CreateInteractionLightTris( const idRenderEntityLocal*
// it is debatable if non-shadowing lights should light back faces. we aren't at the moment
// RB: now we do with r_useHalfLambert, so don't cull back faces if we have smooth shadowing enabled
if( r_lightAllBackFaces.GetBool() || light->lightShader->LightEffectsBackSides()
|| shader->ReceivesLightingOnBackSides() || ent->parms.noSelfShadow || ent->parms.noShadow || r_useIBL.GetBool() || ( r_useHalfLambertLighting.GetInteger() && r_useShadowMapping.GetBool() ) )
|| shader->ReceivesLightingOnBackSides() || ent->parms.noSelfShadow || ent->parms.noShadow || r_usePBR.GetBool() || ( r_useHalfLambertLighting.GetInteger() && r_useShadowMapping.GetBool() ) )
{
includeBackFaces = true;
}

View file

@ -1491,7 +1491,10 @@ void idRenderBackend::CheckCVars()
}
}
if( r_useIBL.IsModified() || r_useHDR.IsModified() || r_useHalfLambertLighting.IsModified() )
if( r_useIBL.IsModified() ||
r_useHDR.IsModified() ||
r_useHalfLambertLighting.IsModified() ||
r_pbrDebug.IsModified() )
{
bool needShaderReload = false;
@ -1503,10 +1506,12 @@ void idRenderBackend::CheckCVars()
}
needShaderReload |= r_useHDR.IsModified();
needShaderReload |= r_pbrDebug.IsModified();
r_useIBL.ClearModified();
r_useHDR.ClearModified();
r_useHalfLambertLighting.ClearModified();
r_pbrDebug.ClearModified();
renderProgManager.KillAllShaders();
renderProgManager.LoadAllShaders();

View file

@ -1090,7 +1090,7 @@ extern idCVar r_ssaoDebug;
extern idCVar r_ssaoFiltering;
extern idCVar r_useHierarchicalDepthBuffer;
extern idCVar r_useIBL;
extern idCVar r_usePBR;
extern idCVar r_pbrDebug;
extern idCVar r_exposure;

View file

@ -252,7 +252,8 @@ void idRenderProgManager::Init()
r_useHalfLambertLighting.ClearModified();
r_useHDR.ClearModified();
r_useIBL.ClearModified();
r_usePBR.ClearModified();
r_pbrDebug.ClearModified();
uniforms.SetNum( RENDERPARM_TOTAL, vec4_zero );

View file

@ -2327,14 +2327,14 @@ static const cgShaderDef_t cg_renderprogs[] =
" half3 diffuseColor = baseColor * ( 1.0 - metallic );\n"
" half3 specularColor = lerp( dielectricColor, baseColor, metallic );\n"
"\n"
" float3 kS = Fresnel_SchlickRoughness( specularColor, vDotN, roughness );\n"
" float3 kD = ( float3( 1.0, 1.0, 1.0 ) - kS ) * ( 1.0 - metallic );\n"
"\n"
"#if defined( DEBUG_PBR )\n"
" diffuseColor = half3( 0.0, 0.0, 0.0 );\n"
" specularColor = half3( 0.0, 1.0, 0.0 );\n"
"#endif\n"
"\n"
" float3 kS = Fresnel_SchlickRoughness( specularColor, vDotN, roughness );\n"
" float3 kD = ( float3( 1.0, 1.0, 1.0 ) - kS ) * ( 1.0 - metallic );\n"
"\n"
"#else\n"
" // HACK calculate roughness from D3 gloss maps\n"
" float Y = dot( LUMINANCE_SRGB.rgb, specMapSRGB.rgb );\n"
@ -2347,27 +2347,27 @@ static const cgShaderDef_t cg_renderprogs[] =
" half3 diffuseColor = diffuseMap;\n"
" half3 specularColor = specMap.rgb;\n"
"\n"
" float3 kS = Fresnel_SchlickRoughness( specularColor, vDotN, roughness );\n"
"\n"
" // metalness is missing\n"
" float3 kD = ( float3( 1.0, 1.0, 1.0 ) - kS );\n"
"\n"
"#if defined( DEBUG_PBR )\n"
" diffuseColor = half3( 0.0, 0.0, 0.0 );\n"
" specularColor = half3( 1.0, 0.0, 0.0 );\n"
"#endif\n"
"\n"
" float3 kS = Fresnel_SchlickRoughness( specularColor, vDotN, roughness );\n"
"\n"
" // NOTE: metalness is missing\n"
" float3 kD = ( float3( 1.0, 1.0, 1.0 ) - kS );\n"
"\n"
"#endif\n"
"\n"
" //diffuseColor = half3( 1.0, 1.0, 1.0 );\n"
" //diffuseColor = half3( 0.0, 0.0, 0.0 );\n"
" \n"
" // calculate the screen texcoord in the 0.0 to 1.0 range\n"
" //diffuseColor = half3( 1.0, 1.0, 1.0 );\n"
" //diffuseColor = half3( 0.0, 0.0, 0.0 );\n"
"\n"
" // calculate the screen texcoord in the 0.0 to 1.0 range\n"
" //float2 screenTexCoord = vposToScreenPosTexCoord( fragment.position.xy );\n"
" float2 screenTexCoord = fragment.position.xy * rpScreenCorrectionFactor.xy;\n"
" \n"
" float2 screenTexCoord = fragment.position.xy * rpScreenCorrectionFactor.xy;\n"
"\n"
" float ao = tex2D( samp4, screenTexCoord ).r;\n"
" //diffuseColor.rgb *= ao;\n"
" //diffuseColor.rgb *= ao;\n"
"\n"
" // evaluate diffuse IBL\n"
"\n"
@ -2389,7 +2389,7 @@ static const cgShaderDef_t cg_renderprogs[] =
" return;\n"
"#endif\n"
"\n"
" float specAO = ComputeSpecularAO( vDotN, ao, roughness );\n"
" float specAO = ComputeSpecularAO( vDotN, ao, roughness );\n"
" float3 specularLight = radiance * ( kS * envBRDF.x + float3( envBRDF.y ) ) * specAO * ( rpSpecularModifier.xyz * 0.75 );\n"
"\n"
"#if 0\n"
@ -2409,7 +2409,7 @@ static const cgShaderDef_t cg_renderprogs[] =
" //result.color.rgb = localNormal.xyz * 0.5 + 0.5;\n"
" //result.color.xyz = ( ( diffuseColor + specularColor ) * halfLdotN * lightColor ) * fragment.color.rgb;\n"
" //result.color = ( ( diffuseColor + specularColor ) * halfLdotN * lightColor + rimColor ) * fragment.color.rgba;\n"
" //result.color.rgb = float3( ao );\n"
" //result.color.rgb = float3( ao );\n"
" result.color.w = fragment.color.a;\n"
"}\n"
"\n"

View file

@ -296,8 +296,8 @@ idCVar r_ssaoDebug( "r_ssaoDebug", "0", CVAR_RENDERER | CVAR_INTEGER, "" );
idCVar r_ssaoFiltering( "r_ssaoFiltering", "1", CVAR_RENDERER | CVAR_BOOL, "" );
idCVar r_useHierarchicalDepthBuffer( "r_useHierarchicalDepthBuffer", "1", CVAR_RENDERER | CVAR_BOOL, "" );
idCVar r_useIBL( "r_useIBL", "0", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL, "use Image Based Lighting for ambient lighting (PBR)" );
idCVar r_pbrDebug( "r_pbrDebug", "0", CVAR_RENDERER | CVAR_INTEGER, "show which materials have PBR support (green = PBR, red = oldschool D3), requires reloadShaders" );
idCVar r_usePBR( "r_usePBR", "1", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL, "use PBR and Image Based Lighting instead of old Quake 4 style ambient lighting" );
idCVar r_pbrDebug( "r_pbrDebug", "0", CVAR_RENDERER | CVAR_INTEGER, "show which materials have PBR support (green = PBR, red = oldschool D3)" );
idCVar r_exposure( "r_exposure", "0.5", CVAR_ARCHIVE | CVAR_RENDERER | CVAR_FLOAT, "HDR exposure or LDR brightness [0.0 .. 1.0]", 0.0f, 1.0f );
// RB end