Fixed way too bright ambient lights in HDR mode

This commit is contained in:
Robert Beckebans 2020-05-01 13:01:39 +02:00
parent d198ec5139
commit c40765ef24
3 changed files with 12 additions and 9 deletions

View file

@ -179,7 +179,7 @@ void main( PS_IN fragment, out PS_OUT result )
const half specularPower = 10.0f;
// RB: added abs
half3 specularContribution = _half3( pow( hdotN, specularPower ) );
half3 specularContribution = _half3( pow( abs( hDotN ), specularPower ) );
half3 diffuseColor = diffuseMap * sRGBToLinearRGB( rpDiffuseModifier.xyz );
half3 specularColor = specMap.xyz * specularContribution * sRGBToLinearRGB( rpSpecularModifier.xyz );

View file

@ -3,6 +3,7 @@
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2013-2020 Robert Beckebans
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
@ -57,7 +58,8 @@ void main( PS_IN fragment, out PS_OUT result )
half4 lightFalloff = idtex2Dproj( samp3, fragment.texcoord2 );
half4 lightProj = idtex2Dproj( samp4, fragment.texcoord3 );
half4 YCoCG = tex2D( samp2, fragment.texcoord4.xy );
half4 specMap = sRGBAToLinearRGBA( tex2D( samp1, fragment.texcoord5.xy ) );
half4 specMapSRGB = tex2D( samp1, fragment.texcoord5.xy );
half4 specMap = sRGBAToLinearRGBA( specMapSRGB );
const half3 ambientLightVector = half3( 0.5f, 9.5f - 0.385f, 0.8925f );
half3 lightVector = normalize( ambientLightVector );
@ -94,7 +96,7 @@ void main( PS_IN fragment, out PS_OUT result )
half3 diffuseColor = diffuseMap * sRGBToLinearRGB( rpDiffuseModifier.xyz );
half3 specularColor = specMap.xyz * specularContribution * sRGBToLinearRGB( rpSpecularModifier.xyz );
half3 lightColor = 1.0 * lightProj.xyz * lightFalloff.xyz;
half3 lightColor = sRGBToLinearRGB( lightProj.xyz * lightFalloff.xyz );
result.color.xyz = ( diffuseColor + specularColor ) * lightColor * fragment.color.xyz;
result.color.w = 1.0;

View file

@ -3,7 +3,7 @@
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2013 Robert Beckebans
Copyright (C) 2013-2020 Robert Beckebans
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
@ -58,11 +58,12 @@ void main( PS_IN fragment, out PS_OUT result )
half4 lightFalloff = idtex2Dproj( samp3, fragment.texcoord2 );
half4 lightProj = idtex2Dproj( samp4, fragment.texcoord3 );
half4 YCoCG = tex2D( samp2, fragment.texcoord4.xy );
half4 specMap = tex2D( samp1, fragment.texcoord5.xy );
half4 specMapSRGB = tex2D( samp1, fragment.texcoord5.xy );
half4 specMap = sRGBAToLinearRGBA( specMapSRGB );
const half3 ambientLightVector = half3( 0.5f, 9.5f - 0.385f, 0.8925f );
half3 lightVector = normalize( ambientLightVector );
half3 diffuseMap = ConvertYCoCgToRGB( YCoCG );
half3 diffuseMap = sRGBToLinearRGB( ConvertYCoCgToRGB( YCoCG ) );
half3 localNormal;
// RB begin
@ -93,9 +94,9 @@ void main( PS_IN fragment, out PS_OUT result )
// RB: added abs
half3 specularContribution = _half3( pow( abs( hDotN ), specularPower ) );
half3 diffuseColor = diffuseMap * rpDiffuseModifier.xyz;
half3 specularColor = specMap.xyz * specularContribution * rpSpecularModifier.xyz;
half3 lightColor = 1.0 * lightProj.xyz * lightFalloff.xyz;
half3 diffuseColor = diffuseMap * sRGBToLinearRGB( rpDiffuseModifier.xyz );
half3 specularColor = specMap.xyz * specularContribution * sRGBToLinearRGB( rpSpecularModifier.xyz );
half3 lightColor = sRGBToLinearRGB( lightProj.xyz * lightFalloff.xyz );
result.color.xyz = ( diffuseColor + specularColor ) * lightColor * fragment.color.xyz;
result.color.w = 1.0;