mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-13 22:22:05 +00:00
Added small metal detection hack for new PBR shader
This commit is contained in:
parent
f3fd486c60
commit
78bebe99ee
1 changed files with 11 additions and 1 deletions
|
@ -124,7 +124,8 @@ float EstimateLegacyRoughness( float3 specMapSRGB )
|
|||
void PBRFromSpecmap( float3 specMap, out float3 F0, out float roughness )
|
||||
{
|
||||
// desaturate specular
|
||||
float specLum = max( specMap.r, max( specMap.g, specMap.b ) );
|
||||
//float specLum = max( specMap.r, max( specMap.g, specMap.b ) );
|
||||
float specLum = dot( LUMINANCE_SRGB.rgb, specMap );
|
||||
|
||||
// fresnel base
|
||||
F0 = _float3( 0.04 );
|
||||
|
@ -146,6 +147,15 @@ void PBRFromSpecmap( float3 specMap, out float3 F0, out float roughness )
|
|||
// specular power to roughness
|
||||
roughness = sqrt( 2.0 / ( specPow + 2.0 ) );
|
||||
|
||||
#if 1
|
||||
// RB: try to distinct between dielectrics and metal materials
|
||||
float glossiness = saturate( 1.0 - roughness );
|
||||
float metallic = step( 0.7, glossiness );
|
||||
|
||||
float3 glossColor = Linear3( specMap.rgb );
|
||||
F0 = lerp( F0, glossColor, metallic );
|
||||
#endif
|
||||
|
||||
// RB: do another sqrt because PBR shader squares it
|
||||
roughness = sqrt( roughness );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue