mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-02-27 22:21:28 +00:00
Added cvar r_useHalfLambertLighting to make it optional, it requires reloadShaders
This commit is contained in:
parent
42874cfd05
commit
e13fc0f4e9
6 changed files with 72 additions and 29 deletions
|
@ -62,18 +62,29 @@ void main( PS_IN fragment, out PS_OUT result ) {
|
||||||
half3 diffuseMap = ConvertYCoCgToRGB( YCoCG );
|
half3 diffuseMap = ConvertYCoCgToRGB( YCoCG );
|
||||||
|
|
||||||
half3 localNormal;
|
half3 localNormal;
|
||||||
|
// RB begin
|
||||||
|
#if defined(USE_NORMAL_FMT_RGB8)
|
||||||
|
localNormal.xy = bumpMap.rg - 0.5;
|
||||||
|
#else
|
||||||
localNormal.xy = bumpMap.wy - 0.5;
|
localNormal.xy = bumpMap.wy - 0.5;
|
||||||
|
#endif
|
||||||
|
// RB end
|
||||||
localNormal.z = sqrt( abs( dot( localNormal.xy, localNormal.xy ) - 0.25 ) );
|
localNormal.z = sqrt( abs( dot( localNormal.xy, localNormal.xy ) - 0.25 ) );
|
||||||
localNormal = normalize( localNormal );
|
localNormal = normalize( localNormal );
|
||||||
|
|
||||||
// RB: http://developer.valvesoftware.com/wiki/Half_Lambert
|
|
||||||
float halfLdotN = dot3( localNormal, lightVector ) * 0.5 + 0.5;
|
|
||||||
halfLdotN *= halfLdotN;
|
|
||||||
|
|
||||||
// traditional very dark Lambert light model used in Doom 3
|
// traditional very dark Lambert light model used in Doom 3
|
||||||
//float ldotN = clamp( dot3( localNormal, lightVector ), 0.0, 1.0 );
|
half ldotN = dot3( localNormal, lightVector );
|
||||||
float ldotN = dot3( localNormal, lightVector );
|
|
||||||
|
|
||||||
|
#if defined(USE_HALF_LAMBERT)
|
||||||
|
// RB: http://developer.valvesoftware.com/wiki/Half_Lambert
|
||||||
|
half halfLdotN = dot3( localNormal, lightVector ) * 0.5 + 0.5;
|
||||||
|
halfLdotN *= halfLdotN;
|
||||||
|
|
||||||
|
half lambert = halfLdotN;
|
||||||
|
#else
|
||||||
|
half lambert = ldotN;
|
||||||
|
#endif
|
||||||
|
|
||||||
const half specularPower = 10.0f;
|
const half specularPower = 10.0f;
|
||||||
half hDotN = dot3( normalize( fragment.texcoord6.xyz ), localNormal );
|
half hDotN = dot3( normalize( fragment.texcoord6.xyz ), localNormal );
|
||||||
// RB: added abs
|
// RB: added abs
|
||||||
|
@ -87,6 +98,6 @@ void main( PS_IN fragment, out PS_OUT result ) {
|
||||||
half rimPower = 16.0f;
|
half rimPower = 16.0f;
|
||||||
half3 rimColor = diffuseColor * lightProj.xyz * lightFalloff.xyz * 1.0f * pow( rim, rimPower ) * fragment.color.rgb;// * halfLdotN;
|
half3 rimColor = diffuseColor * lightProj.xyz * lightFalloff.xyz * 1.0f * pow( rim, rimPower ) * fragment.color.rgb;// * halfLdotN;
|
||||||
|
|
||||||
result.color.xyz = ( diffuseColor + specularColor ) * halfLdotN * lightColor * fragment.color.rgb;// + rimColor;
|
result.color.xyz = ( diffuseColor + specularColor ) * lambert * lightColor * fragment.color.rgb;// + rimColor;
|
||||||
result.color.w = 1.0;
|
result.color.w = 1.0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
||||||
|
|
||||||
half3 localNormal;
|
half3 localNormal;
|
||||||
// RB begin
|
// RB begin
|
||||||
#if defined(GLES2)
|
#if defined(USE_NORMAL_FMT_RGB8)
|
||||||
localNormal.xy = bumpMap.rg - 0.5;
|
localNormal.xy = bumpMap.rg - 0.5;
|
||||||
#else
|
#else
|
||||||
localNormal.xy = bumpMap.wy - 0.5;
|
localNormal.xy = bumpMap.wy - 0.5;
|
||||||
|
@ -82,13 +82,19 @@ void main( PS_IN fragment, out PS_OUT result )
|
||||||
localNormal.z = sqrt( abs( dot( localNormal.xy, localNormal.xy ) - 0.25 ) );
|
localNormal.z = sqrt( abs( dot( localNormal.xy, localNormal.xy ) - 0.25 ) );
|
||||||
localNormal = normalize( localNormal );
|
localNormal = normalize( localNormal );
|
||||||
|
|
||||||
// RB: http://developer.valvesoftware.com/wiki/Half_Lambert
|
|
||||||
float halfLdotN = dot3( localNormal, lightVector ) * 0.5 + 0.5;
|
|
||||||
halfLdotN *= halfLdotN;
|
|
||||||
|
|
||||||
// traditional very dark Lambert light model used in Doom 3
|
// traditional very dark Lambert light model used in Doom 3
|
||||||
float ldotN = dot3( localNormal, lightVector );
|
half ldotN = dot3( localNormal, lightVector );
|
||||||
|
|
||||||
|
#if defined(USE_HALF_LAMBERT)
|
||||||
|
// RB: http://developer.valvesoftware.com/wiki/Half_Lambert
|
||||||
|
half halfLdotN = dot3( localNormal, lightVector ) * 0.5 + 0.5;
|
||||||
|
halfLdotN *= halfLdotN;
|
||||||
|
|
||||||
|
half lambert = halfLdotN;
|
||||||
|
#else
|
||||||
|
half lambert = ldotN;
|
||||||
|
#endif
|
||||||
|
|
||||||
const half specularPower = 10.0f;
|
const half specularPower = 10.0f;
|
||||||
half hDotN = dot3( normalize( fragment.texcoord6.xyz ), localNormal );
|
half hDotN = dot3( normalize( fragment.texcoord6.xyz ), localNormal );
|
||||||
// RB: added abs
|
// RB: added abs
|
||||||
|
@ -228,6 +234,6 @@ void main( PS_IN fragment, out PS_OUT result )
|
||||||
float shadow = texture( samp5, shadowTexcoord.xywz );
|
float shadow = texture( samp5, shadowTexcoord.xywz );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
result.color.xyz = ( diffuseColor + specularColor ) * halfLdotN * lightColor * fragment.color.rgb * shadow;// + rimColor;
|
result.color.xyz = ( diffuseColor + specularColor ) * lambert * lightColor * fragment.color.rgb * shadow;// + rimColor;
|
||||||
result.color.w = 1.0;
|
result.color.w = 1.0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -534,7 +534,7 @@ idStr StripDeadCode( const idStr& in, const char* name, const idStrList& compile
|
||||||
{
|
{
|
||||||
case GLDRV_OPENGL_ES2:
|
case GLDRV_OPENGL_ES2:
|
||||||
case GLDRV_OPENGL_ES3:
|
case GLDRV_OPENGL_ES3:
|
||||||
src.AddDefine( "GLES2" );
|
//src.AddDefine( "GLES2" );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -548,6 +548,11 @@ idStr StripDeadCode( const idStr& in, const char* name, const idStrList& compile
|
||||||
src.AddDefine( "USE_UNIFORM_ARRAYS" );
|
src.AddDefine( "USE_UNIFORM_ARRAYS" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( r_useHalfLambertLighting.GetBool() )
|
||||||
|
{
|
||||||
|
src.AddDefine( "USE_HALF_LAMBERT" );
|
||||||
|
}
|
||||||
|
|
||||||
idList< idCGBlock > blocks;
|
idList< idCGBlock > blocks;
|
||||||
|
|
||||||
blocks.SetNum( 100 );
|
blocks.SetNum( 100 );
|
||||||
|
|
|
@ -3925,18 +3925,29 @@ static const cgShaderDef_t cg_renderprogs[] =
|
||||||
" half3 diffuseMap = ConvertYCoCgToRGB( YCoCG );\n"
|
" half3 diffuseMap = ConvertYCoCgToRGB( YCoCG );\n"
|
||||||
"\n"
|
"\n"
|
||||||
" half3 localNormal;\n"
|
" half3 localNormal;\n"
|
||||||
|
" // RB begin\n"
|
||||||
|
"#if defined(USE_NORMAL_FMT_RGB8)\n"
|
||||||
|
" localNormal.xy = bumpMap.rg - 0.5;\n"
|
||||||
|
"#else\n"
|
||||||
" localNormal.xy = bumpMap.wy - 0.5;\n"
|
" localNormal.xy = bumpMap.wy - 0.5;\n"
|
||||||
|
"#endif\n"
|
||||||
|
" // RB end\n"
|
||||||
" localNormal.z = sqrt( abs( dot( localNormal.xy, localNormal.xy ) - 0.25 ) );\n"
|
" localNormal.z = sqrt( abs( dot( localNormal.xy, localNormal.xy ) - 0.25 ) );\n"
|
||||||
" localNormal = normalize( localNormal );\n"
|
" localNormal = normalize( localNormal );\n"
|
||||||
" \n"
|
" \n"
|
||||||
" // RB: http://developer.valvesoftware.com/wiki/Half_Lambert\n"
|
|
||||||
" float halfLdotN = dot3( localNormal, lightVector ) * 0.5 + 0.5;\n"
|
|
||||||
" halfLdotN *= halfLdotN;\n"
|
|
||||||
" \n"
|
|
||||||
" // traditional very dark Lambert light model used in Doom 3\n"
|
" // traditional very dark Lambert light model used in Doom 3\n"
|
||||||
" //float ldotN = clamp( dot3( localNormal, lightVector ), 0.0, 1.0 );\n"
|
" half ldotN = dot3( localNormal, lightVector );\n"
|
||||||
" float ldotN = dot3( localNormal, lightVector );\n"
|
|
||||||
"\n"
|
"\n"
|
||||||
|
"#if defined(USE_HALF_LAMBERT)\n"
|
||||||
|
" // RB: http://developer.valvesoftware.com/wiki/Half_Lambert\n"
|
||||||
|
" half halfLdotN = dot3( localNormal, lightVector ) * 0.5 + 0.5;\n"
|
||||||
|
" halfLdotN *= halfLdotN;\n"
|
||||||
|
"\n"
|
||||||
|
" half lambert = halfLdotN;\n"
|
||||||
|
"#else\n"
|
||||||
|
" half lambert = ldotN;\n"
|
||||||
|
"#endif\n"
|
||||||
|
" \n"
|
||||||
" const half specularPower = 10.0f;\n"
|
" const half specularPower = 10.0f;\n"
|
||||||
" half hDotN = dot3( normalize( fragment.texcoord6.xyz ), localNormal );\n"
|
" half hDotN = dot3( normalize( fragment.texcoord6.xyz ), localNormal );\n"
|
||||||
" // RB: added abs\n"
|
" // RB: added abs\n"
|
||||||
|
@ -3950,7 +3961,7 @@ static const cgShaderDef_t cg_renderprogs[] =
|
||||||
" half rimPower = 16.0f;\n"
|
" half rimPower = 16.0f;\n"
|
||||||
" half3 rimColor = diffuseColor * lightProj.xyz * lightFalloff.xyz * 1.0f * pow( rim, rimPower ) * fragment.color.rgb;// * halfLdotN;\n"
|
" half3 rimColor = diffuseColor * lightProj.xyz * lightFalloff.xyz * 1.0f * pow( rim, rimPower ) * fragment.color.rgb;// * halfLdotN;\n"
|
||||||
"\n"
|
"\n"
|
||||||
" result.color.xyz = ( diffuseColor + specularColor ) * halfLdotN * lightColor * fragment.color.rgb;// + rimColor;\n"
|
" result.color.xyz = ( diffuseColor + specularColor ) * lambert * lightColor * fragment.color.rgb;// + rimColor;\n"
|
||||||
" result.color.w = 1.0;\n"
|
" result.color.w = 1.0;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
@ -4237,7 +4248,7 @@ static const cgShaderDef_t cg_renderprogs[] =
|
||||||
"\n"
|
"\n"
|
||||||
" half3 localNormal;\n"
|
" half3 localNormal;\n"
|
||||||
" // RB begin\n"
|
" // RB begin\n"
|
||||||
"#if defined(GLES2)\n"
|
"#if defined(USE_NORMAL_FMT_RGB8)\n"
|
||||||
" localNormal.xy = bumpMap.rg - 0.5;\n"
|
" localNormal.xy = bumpMap.rg - 0.5;\n"
|
||||||
"#else\n"
|
"#else\n"
|
||||||
" localNormal.xy = bumpMap.wy - 0.5;\n"
|
" localNormal.xy = bumpMap.wy - 0.5;\n"
|
||||||
|
@ -4246,13 +4257,19 @@ static const cgShaderDef_t cg_renderprogs[] =
|
||||||
" localNormal.z = sqrt( abs( dot( localNormal.xy, localNormal.xy ) - 0.25 ) );\n"
|
" localNormal.z = sqrt( abs( dot( localNormal.xy, localNormal.xy ) - 0.25 ) );\n"
|
||||||
" localNormal = normalize( localNormal );\n"
|
" localNormal = normalize( localNormal );\n"
|
||||||
" \n"
|
" \n"
|
||||||
" // RB: http://developer.valvesoftware.com/wiki/Half_Lambert\n"
|
|
||||||
" float halfLdotN = dot3( localNormal, lightVector ) * 0.5 + 0.5;\n"
|
|
||||||
" halfLdotN *= halfLdotN;\n"
|
|
||||||
" \n"
|
|
||||||
" // traditional very dark Lambert light model used in Doom 3\n"
|
" // traditional very dark Lambert light model used in Doom 3\n"
|
||||||
" float ldotN = dot3( localNormal, lightVector );\n"
|
" half ldotN = dot3( localNormal, lightVector );\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
"#if defined(USE_HALF_LAMBERT)\n"
|
||||||
|
" // RB: http://developer.valvesoftware.com/wiki/Half_Lambert\n"
|
||||||
|
" half halfLdotN = dot3( localNormal, lightVector ) * 0.5 + 0.5;\n"
|
||||||
|
" halfLdotN *= halfLdotN;\n"
|
||||||
|
"\n"
|
||||||
|
" half lambert = halfLdotN;\n"
|
||||||
|
"#else\n"
|
||||||
|
" half lambert = ldotN;\n"
|
||||||
|
"#endif\n"
|
||||||
|
" \n"
|
||||||
" const half specularPower = 10.0f;\n"
|
" const half specularPower = 10.0f;\n"
|
||||||
" half hDotN = dot3( normalize( fragment.texcoord6.xyz ), localNormal );\n"
|
" half hDotN = dot3( normalize( fragment.texcoord6.xyz ), localNormal );\n"
|
||||||
" // RB: added abs\n"
|
" // RB: added abs\n"
|
||||||
|
@ -4392,7 +4409,7 @@ static const cgShaderDef_t cg_renderprogs[] =
|
||||||
" float shadow = texture( samp5, shadowTexcoord.xywz );\n"
|
" float shadow = texture( samp5, shadowTexcoord.xywz );\n"
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
"\n"
|
"\n"
|
||||||
" result.color.xyz = ( diffuseColor + specularColor ) * halfLdotN * lightColor * fragment.color.rgb * shadow;// + rimColor;\n"
|
" result.color.xyz = ( diffuseColor + specularColor ) * lambert * lightColor * fragment.color.rgb * shadow;// + rimColor;\n"
|
||||||
" result.color.w = 1.0;\n"
|
" result.color.w = 1.0;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
|
|
@ -146,6 +146,9 @@ idCVar r_skipPrelightShadows( "r_skipPrelightShadows", "0", CVAR_RENDERER | CVAR
|
||||||
idCVar r_useScissor( "r_useScissor", "1", CVAR_RENDERER | CVAR_BOOL, "scissor clip as portals and lights are processed" );
|
idCVar r_useScissor( "r_useScissor", "1", CVAR_RENDERER | CVAR_BOOL, "scissor clip as portals and lights are processed" );
|
||||||
idCVar r_useLightDepthBounds( "r_useLightDepthBounds", "1", CVAR_RENDERER | CVAR_BOOL, "use depth bounds test on lights to reduce both shadow and interaction fill" );
|
idCVar r_useLightDepthBounds( "r_useLightDepthBounds", "1", CVAR_RENDERER | CVAR_BOOL, "use depth bounds test on lights to reduce both shadow and interaction fill" );
|
||||||
idCVar r_useShadowDepthBounds( "r_useShadowDepthBounds", "1", CVAR_RENDERER | CVAR_BOOL, "use depth bounds test on individual shadow volumes to reduce shadow fill" );
|
idCVar r_useShadowDepthBounds( "r_useShadowDepthBounds", "1", CVAR_RENDERER | CVAR_BOOL, "use depth bounds test on individual shadow volumes to reduce shadow fill" );
|
||||||
|
// RB begin
|
||||||
|
idCVar r_useHalfLambertLighting( "r_useHalfLambertLighting", "1", CVAR_RENDERER | CVAR_BOOL | CVAR_ARCHIVE, "use Half-Lambert lighting instead of classic Lambert, requires reloadShaders" );
|
||||||
|
// RB end
|
||||||
|
|
||||||
idCVar r_screenFraction( "r_screenFraction", "100", CVAR_RENDERER | CVAR_INTEGER, "for testing fill rate, the resolution of the entire screen can be changed" );
|
idCVar r_screenFraction( "r_screenFraction", "100", CVAR_RENDERER | CVAR_INTEGER, "for testing fill rate, the resolution of the entire screen can be changed" );
|
||||||
idCVar r_usePortals( "r_usePortals", "1", CVAR_RENDERER | CVAR_BOOL, " 1 = use portals to perform area culling, otherwise draw everything" );
|
idCVar r_usePortals( "r_usePortals", "1", CVAR_RENDERER | CVAR_BOOL, " 1 = use portals to perform area culling, otherwise draw everything" );
|
||||||
|
|
|
@ -958,6 +958,7 @@ extern idCVar r_useLightDepthBounds; // use depth bounds test on lights to redu
|
||||||
extern idCVar r_useShadowDepthBounds; // use depth bounds test on individual shadows to reduce shadow fill
|
extern idCVar r_useShadowDepthBounds; // use depth bounds test on individual shadows to reduce shadow fill
|
||||||
// RB begin
|
// RB begin
|
||||||
extern idCVar r_useShadowMapping; // use shadow mapping instead of stencil shadows
|
extern idCVar r_useShadowMapping; // use shadow mapping instead of stencil shadows
|
||||||
|
extern idCVar r_useHalfLambertLighting; // use Half-Lambert lighting instead of classic Lambert
|
||||||
// RB end
|
// RB end
|
||||||
|
|
||||||
extern idCVar r_skipStaticInteractions; // skip interactions created at level load
|
extern idCVar r_skipStaticInteractions; // skip interactions created at level load
|
||||||
|
|
Loading…
Reference in a new issue