Misc linear RGB experiments

This commit is contained in:
Robert Beckebans 2015-12-21 14:12:03 +01:00
parent b3dc4c99fb
commit f7fc5b59ab
6 changed files with 139 additions and 584 deletions

View file

@ -102,7 +102,7 @@ void main( PS_IN fragment, out PS_OUT result )
half3 diffuseColor = diffuseMap * sRGBToLinearRGB( rpDiffuseModifier.xyz );
half3 specularColor = specMap.xyz * specularContribution * sRGBToLinearRGB( rpSpecularModifier.xyz * 1.0 );
half3 lightColor = lightProj.xyz * lightFalloff.xyz;
half3 lightColor = sRGBToLinearRGB( lightProj.xyz * lightFalloff.xyz );
half rim = 1.0f - saturate( hDotN );
half rimPower = 16.0f;
@ -281,5 +281,6 @@ void main( PS_IN fragment, out PS_OUT result )
#endif
result.color.xyz = ( diffuseColor + specularColor ) * lambert * lightColor * fragment.color.rgb * shadow;// + rimColor;
//result.color.xyz = lightColor * lambert * fragment.color.rgb * shadow;// + rimColor;
result.color.w = 1.0;
}

View file

@ -70,10 +70,11 @@ void main( PS_IN fragment, out PS_OUT result )
// get the luminance of the current pixel
float Y = dot( LUMINANCE_VECTOR, color );
#if 1
// convert from sRGB to linear RGB
const float hdrGamma = 2.2;
float gamma = hdrGamma;
#if 0
// convert from sRGB to linear RGB
color.r = pow( color.r, gamma );
color.g = pow( color.g, gamma );
color.b = pow( color.b, gamma );

View file

@ -596,7 +596,7 @@ void RB_ExecuteBackEndCommands( const emptyCommand_t* cmds )
}
break;
case RC_SET_BUFFER:
RB_SetBuffer( cmds );
//RB_SetBuffer( cmds );
c_setBuffers++;
break;
case RC_COPY_RENDER:

View file

@ -555,7 +555,7 @@ idStr StripDeadCode( const idStr& in, const char* name, const idStrList& compile
src.AddDefine( "USE_HALF_LAMBERT" );
}
if( r_useSRGB.GetBool() )
if( r_useSRGB.GetBool() || r_useHDR.GetBool() )
{
src.AddDefine( "USE_SRGB" );
}

View file

@ -133,6 +133,58 @@ static const cgShaderDef_t cg_renderprogs[] =
"static float dot4( float4 a, float4 b ) { return dot( a, b ); }\n"
"static float dot4( float2 a, float4 b ) { return dot( float4( a, 0, 1 ), b ); }\n"
"\n"
"// RB begin\n"
"#ifndef PI\n"
"#define PI 3.14159265358979323846\n"
"#endif\n"
"\n"
"#define DEG2RAD( a ) ( ( a ) * PI / 180.0f )\n"
"#define RAD2DEG( a ) ( ( a ) * 180.0f / PI )\n"
"\n"
"// ----------------------\n"
"// sRGB <-> Linear RGB Color Conversion\n"
"// ----------------------\n"
"\n"
"half3 sRGBToLinearRGB( half3 rgb )\n"
"{\n"
"#if defined(USE_SRGB)\n"
" return pow( rgb, half3( 2.2 ) );\n"
"#else\n"
" return rgb;\n"
"#endif\n"
"}\n"
"\n"
"half4 sRGBAToLinearRGBA( half4 rgba )\n"
"{\n"
"#if defined(USE_SRGB)\n"
" return pow( rgba, half4( 2.2 ) );\n"
"#else\n"
" return rgba;\n"
"#endif\n"
"}\n"
"\n"
"half3 LinearRGBToSRGB( half3 rgb )\n"
"{\n"
"#if defined(USE_SRGB)\n"
" return pow( rgb, half3( 1.0 ) / half3( 2.2 ) );\n"
"#else\n"
" return rgb;\n"
"#endif\n"
"}\n"
"\n"
"half4 LinearRGBToSRGB( half4 rgba )\n"
"{\n"
"#if defined(USE_SRGB)\n"
" rgba.rgb = pow( rgba.rgb, half3( 1.0 ) / half3( 2.2 ) );\n"
" return rgba; //pow( rgba, half4( 1.0 ) / half4( 2.2 ) );\n"
"#else\n"
" return rgba;\n"
"#endif\n"
"}\n"
"\n"
"\n"
"// RB end\n"
"\n"
"// ----------------------\n"
"// YCoCg Color Conversion\n"
"// ----------------------\n"
@ -187,17 +239,8 @@ static const cgShaderDef_t cg_renderprogs[] =
" return frac( sin( dot( co.xy, float2( 12.9898, 78.233 ) ) ) * 43758.5453 );\n"
"}\n"
"\n"
"// RB begin\n"
"#ifndef PI\n"
"#define PI 3.14159265358979323846\n"
"#endif\n"
"\n"
"#define DEG2RAD( a ) ( ( a ) * PI / 180.0f )\n"
"#define RAD2DEG( a ) ( ( a ) * 180.0f / PI )\n"
"\n"
"static const half4 LUMINANCE_VECTOR = half4( 0.2125, 0.7154, 0.0721, 0.0 );\n"
"// RB end\n"
"\n"
"#define _half2( x ) half2( x )\n"
"#define _half3( x ) half3( x )\n"
"#define _half4( x ) half4( x )\n"
@ -207,7 +250,10 @@ static const cgShaderDef_t cg_renderprogs[] =
"\n"
"#define VPOS WPOS\n"
"static float4 idtex2Dproj( sampler2D samp, float4 texCoords ) { return tex2Dproj( samp, texCoords.xyw ); }\n"
"static float4 swizzleColor( float4 c ) { return c; }\n"
"static float4 swizzleColor( float4 c )\n"
"{ \n"
" return sRGBAToLinearRGBA( c ); \n"
"}\n"
"static float2 vposToScreenPosTexCoord( float2 vpos ) { return vpos.xy * rpWindowCoord.xy; }\n"
"\n"
"#define BRANCH\n"
@ -546,7 +592,7 @@ static const cgShaderDef_t cg_renderprogs[] =
" result.position.w = dot4( vertex.position, rpMVPmatrixW );\n"
"\n"
" result.texcoord0.xy = vertex.texcoord.xy;\n"
" result.texcoord1 = ( swizzleColor( vertex.color2 ) * 2.0 ) - 1.0;\n"
" result.texcoord1 = ( ( vertex.color2 ) * 2.0 ) - 1.0;\n"
" result.color = swizzleColor( vertex.color );\n"
"}\n"
"\n"
@ -2323,7 +2369,7 @@ static const cgShaderDef_t cg_renderprogs[] =
" result.texcoord0 = toEye.xyz;\n"
" result.texcoord1 = vNormal.xyz;\n"
"\n"
" result.color = rpColor;\n"
" result.color = sRGBAToLinearRGBA( rpColor );\n"
"}\n"
"\n"
@ -2678,7 +2724,7 @@ static const cgShaderDef_t cg_renderprogs[] =
"};\n"
"\n"
"void main( PS_IN fragment, out PS_OUT result ) {\n"
" result.color = tex2D( samp0, fragment.texcoord0 ) * tex2D( samp1, fragment.texcoord1 ) * rpColor;\n"
" result.color = tex2D( samp0, fragment.texcoord0 ) * tex2D( samp1, fragment.texcoord1 ) * sRGBAToLinearRGBA( rpColor );\n"
"}\n"
"\n"
"\n"
@ -2793,7 +2839,7 @@ static const cgShaderDef_t cg_renderprogs[] =
"};\n"
"\n"
"void main( PS_IN fragment, out PS_OUT result ) {\n"
" result.color = tex2D( samp0, fragment.texcoord0 ) * tex2D( samp1, fragment.texcoord1 ) * rpColor;\n"
" result.color = tex2D( samp0, fragment.texcoord0 ) * tex2D( samp1, fragment.texcoord1 ) * sRGBAToLinearRGBA( rpColor );\n"
"}\n"
"\n"
"\n"
@ -3193,6 +3239,58 @@ static const cgShaderDef_t cg_renderprogs[] =
"static float dot4( float4 a, float4 b ) { return dot( a, b ); }\n"
"static float dot4( float2 a, float4 b ) { return dot( float4( a, 0, 1 ), b ); }\n"
"\n"
"// RB begin\n"
"#ifndef PI\n"
"#define PI 3.14159265358979323846\n"
"#endif\n"
"\n"
"#define DEG2RAD( a ) ( ( a ) * PI / 180.0f )\n"
"#define RAD2DEG( a ) ( ( a ) * 180.0f / PI )\n"
"\n"
"// ----------------------\n"
"// sRGB <-> Linear RGB Color Conversion\n"
"// ----------------------\n"
"\n"
"half3 sRGBToLinearRGB( half3 rgb )\n"
"{\n"
"#if defined(USE_SRGB)\n"
" return pow( rgb, half3( 2.2 ) );\n"
"#else\n"
" return rgb;\n"
"#endif\n"
"}\n"
"\n"
"half4 sRGBAToLinearRGBA( half4 rgba )\n"
"{\n"
"#if defined(USE_SRGB)\n"
" return pow( rgba, half4( 2.2 ) );\n"
"#else\n"
" return rgba;\n"
"#endif\n"
"}\n"
"\n"
"half3 LinearRGBToSRGB( half3 rgb )\n"
"{\n"
"#if defined(USE_SRGB)\n"
" return pow( rgb, half3( 1.0 ) / half3( 2.2 ) );\n"
"#else\n"
" return rgb;\n"
"#endif\n"
"}\n"
"\n"
"half4 LinearRGBToSRGB( half4 rgba )\n"
"{\n"
"#if defined(USE_SRGB)\n"
" rgba.rgb = pow( rgba.rgb, half3( 1.0 ) / half3( 2.2 ) );\n"
" return rgba; //pow( rgba, half4( 1.0 ) / half4( 2.2 ) );\n"
"#else\n"
" return rgba;\n"
"#endif\n"
"}\n"
"\n"
"\n"
"// RB end\n"
"\n"
"// ----------------------\n"
"// YCoCg Color Conversion\n"
"// ----------------------\n"
@ -3247,17 +3345,8 @@ static const cgShaderDef_t cg_renderprogs[] =
" return frac( sin( dot( co.xy, float2( 12.9898, 78.233 ) ) ) * 43758.5453 );\n"
"}\n"
"\n"
"// RB begin\n"
"#ifndef PI\n"
"#define PI 3.14159265358979323846\n"
"#endif\n"
"\n"
"#define DEG2RAD( a ) ( ( a ) * PI / 180.0f )\n"
"#define RAD2DEG( a ) ( ( a ) * 180.0f / PI )\n"
"\n"
"static const half4 LUMINANCE_VECTOR = half4( 0.2125, 0.7154, 0.0721, 0.0 );\n"
"// RB end\n"
"\n"
"#define _half2( x ) half2( x )\n"
"#define _half3( x ) half3( x )\n"
"#define _half4( x ) half4( x )\n"
@ -3267,7 +3356,10 @@ static const cgShaderDef_t cg_renderprogs[] =
"\n"
"#define VPOS WPOS\n"
"static float4 idtex2Dproj( sampler2D samp, float4 texCoords ) { return tex2Dproj( samp, texCoords.xyw ); }\n"
"static float4 swizzleColor( float4 c ) { return c; }\n"
"static float4 swizzleColor( float4 c )\n"
"{ \n"
" return sRGBAToLinearRGBA( c ); \n"
"}\n"
"static float2 vposToScreenPosTexCoord( float2 vpos ) { return vpos.xy * rpWindowCoord.xy; }\n"
"\n"
"#define BRANCH\n"
@ -3385,201 +3477,13 @@ static const cgShaderDef_t cg_renderprogs[] =
" result.position.w = dot4( vertex.position, rpMVPmatrixW );\n"
"\n"
" result.texcoord0.xy = vertex.texcoord.xy;\n"
" result.texcoord1 = ( swizzleColor( vertex.color2 ) * 2.0 ) - 1.0;\n"
" result.texcoord1 = ( ( vertex.color2 ) * 2.0 ) - 1.0;\n"
" result.color = swizzleColor( vertex.color );\n"
"}\n"
"\n"
},
{
"renderprogs/hdr_glare_chromatic.pixel",
"/*\n"
"===========================================================================\n"
"\n"
"Doom 3 BFG Edition GPL Source Code\n"
"Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. \n"
"Copyright (C) 2014 Robert Beckebans\n"
"\n"
"This file is part of the Doom 3 BFG Edition GPL Source Code (\"Doom 3 BFG Edition Source Code\"). \n"
"\n"
"Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify\n"
"it under the terms of the GNU General Public License as published by\n"
"the Free Software Foundation, either version 3 of the License, or\n"
"(at your option) any later version.\n"
"\n"
"Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,\n"
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
"GNU General Public License for more details.\n"
"\n"
"You should have received a copy of the GNU General Public License\n"
"along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.\n"
"\n"
"In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.\n"
"\n"
"If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.\n"
"\n"
"===========================================================================\n"
"*/\n"
"\n"
"#include \"renderprogs/global.inc\"\n"
"\n"
"uniform sampler2D samp0 : register(s0);\n"
"\n"
"struct PS_IN\n"
"{\n"
" float4 position : VPOS;\n"
" float2 texcoord0 : TEXCOORD0_centroid;\n"
"};\n"
"\n"
"struct PS_OUT\n"
"{\n"
" float4 color : COLOR;\n"
"};\n"
"\n"
"float linterp( float t )\n"
"{\n"
" return saturate( 1.0 - abs( 2.0 * t - 1.0 ) );\n"
"}\n"
"\n"
"float remap( float t, float a, float b )\n"
"{\n"
" return saturate( ( t - a ) / ( b - a ) );\n"
"}\n"
"\n"
"float3 spectrumoffset( float t )\n"
"{\n"
" float lo = step( t, 0.5 );\n"
" float hi = 1.0 - lo;\n"
" float w = linterp( remap( t, 1.0 / 6.0, 5.0 / 6.0 ) );\n"
" float3 ret = float3( lo, 1.0, hi ) * float3( 1.0 - w, w, 1.0 - w );\n"
"\n"
" return ret; //pow( ret, float3( 1.0 / 2.2 ) );\n"
"}\n"
"\n"
"void main( PS_IN fragment, out PS_OUT result )\n"
"{\n"
" float2 st = fragment.texcoord0;\n"
" \n"
" // base color with tone mapping and other post processing applied\n"
" float4 color = tex2D( samp0, st );\n"
" \n"
" const float gaussFact[9] = float[9](0.13298076, 0.12579441, 0.10648267, 0.08065691, 0.05467002, 0.03315905, 0.01799699, 0.00874063, 0.00379866);\n"
" \n"
" const float3 chromaticOffsets[9] = float3[](\n"
" float3(0.5, 0.5, 0.5),\n"
" float3(0.8, 0.3, 0.3 ),\n"
" float3(1.0, 0.2, 0.2),\n"
" float3(0.5, 0.2, 0.8),\n"
" float3(0.2, 0.2, 1.0),\n"
" float3(0.2, 0.3, 0.9),\n"
" float3(0.2, 0.9, 0.2),\n"
" float3(0.3, 0.5, 0.3),\n"
" float3(0.3, 0.5, 0.3) );\n"
" \n"
" float3 sumColor = float3( 0.0 );\n"
" float3 sumSpectrum = float3( 0.0 );\n"
"\n"
" const int tap = 4;\n"
" const int samples = 9;\n"
" \n"
" float scale = 13.0;\n"
" const float weightScale = 3.0;\n"
" \n"
" //for( int i = -tap; i < tap; i++ )\n"
" for( int i = 0; i < samples; i++ )\n"
" {\n"
" float t = ( ( float( 4 + ( i ) ) ) / ( float( samples ) - 1.0 ) );\n"
" //float t = log( float( i ) / ( float( samples ) - 1.0 ) );\n"
" \n"
" float3 so = spectrumoffset( t );\n"
" float4 color = tex2D( samp0, st + float2( float( i ), 0 ) * rpWindowCoord.xy * scale );\n"
" \n"
" float weight = gaussFact[ i ];\n"
" sumColor += color.rgb * ( so.rgb * weight * weightScale );\n"
" //sumSpectrum += so.xyz;\n"
" }\n"
" \n"
"#if 1\n"
" for( int i = 0; i < samples; i++ )\n"
" {\n"
" float t = ( ( float( 4 + ( i ) ) ) / ( float( samples ) - 1.0 ) );\n"
" \n"
" float3 so = spectrumoffset( t );\n"
" float4 color = tex2D( samp0, st + float2( float( -i ), 0 ) * rpWindowCoord.xy * scale );\n"
" \n"
" float weight = gaussFact[ i ];\n"
" sumColor += color.rgb * ( so.rgb * weight * weightScale );\n"
" //sumSpectrum += so.xyz;\n"
" }\n"
"#endif\n"
" \n"
" result.color = float4( sumColor, 1.0 );\n"
" //result.color = float4( sumColor / float(samples), 1.0 );\n"
" //result.color = float4( sumColor / sumSpectrum, 1.0 );\n"
"}\n"
"\n"
},
{
"renderprogs/hdr_glare_chromatic.vertex",
"/*\n"
"===========================================================================\n"
"\n"
"Doom 3 BFG Edition GPL Source Code\n"
"Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. \n"
"\n"
"This file is part of the Doom 3 BFG Edition GPL Source Code (\"Doom 3 BFG Edition Source Code\"). \n"
"\n"
"Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify\n"
"it under the terms of the GNU General Public License as published by\n"
"the Free Software Foundation, either version 3 of the License, or\n"
"(at your option) any later version.\n"
"\n"
"Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,\n"
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
"GNU General Public License for more details.\n"
"\n"
"You should have received a copy of the GNU General Public License\n"
"along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.\n"
"\n"
"In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.\n"
"\n"
"If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.\n"
"\n"
"===========================================================================\n"
"*/\n"
"\n"
"#include \"renderprogs/global.inc\"\n"
"\n"
"struct VS_IN {\n"
" float4 position : POSITION;\n"
" float2 texcoord : TEXCOORD0;\n"
" float4 normal : NORMAL;\n"
" float4 tangent : TANGENT;\n"
" float4 color : COLOR0;\n"
"};\n"
"\n"
"struct VS_OUT {\n"
" float4 position : POSITION;\n"
" float2 texcoord0 : TEXCOORD0;\n"
"};\n"
"\n"
"void main( VS_IN vertex, out VS_OUT result ) {\n"
" result.position = vertex.position;\n"
"\n"
" //result.position.x = vertex.position; //dot4( vertex.position, rpMVPmatrixX );\n"
" //result.position.y = dot4( vertex.position, rpMVPmatrixY );\n"
" //result.position.z = dot4( vertex.position, rpMVPmatrixZ );\n"
" //result.position.w = dot4( vertex.position, rpMVPmatrixW );\n"
" result.texcoord0 = vertex.texcoord;\n"
"}\n"
},
{
"renderprogs/heathaze.pixel",
"/*\n"
@ -3638,7 +3542,7 @@ static const cgShaderDef_t cg_renderprogs[] =
" screenTexCoord = saturate( screenTexCoord );\n"
"\n"
" // load the screen render\n"
" result.color = tex2D( samp0, screenTexCoord.xy );\n"
" result.color = sRGBAToLinearRGBA( tex2D( samp0, screenTexCoord.xy ) );\n"
"}\n"
},
@ -3801,7 +3705,7 @@ static const cgShaderDef_t cg_renderprogs[] =
" screenTexCoord += ( localNormal * fragment.texcoord2.xy );\n"
" screenTexCoord = saturate( screenTexCoord );\n"
"\n"
" result.color = tex2D( samp0, screenTexCoord );\n"
" result.color = sRGBAToLinearRGBA( tex2D( samp0, screenTexCoord ) );\n"
"}\n"
},
@ -3968,7 +3872,7 @@ static const cgShaderDef_t cg_renderprogs[] =
" screenTexCoord += ( localNormal * fragment.texcoord2.xy );\n"
" screenTexCoord = saturate( screenTexCoord );\n"
"\n"
" result.color = tex2D( samp0, screenTexCoord );\n"
" result.color = sRGBAToLinearRGBA( tex2D( samp0, screenTexCoord ) );\n"
"}\n"
},
@ -4126,13 +4030,13 @@ static const cgShaderDef_t cg_renderprogs[] =
"\n"
"void main( PS_IN fragment, out PS_OUT result ) {\n"
" half4 bumpMap = tex2D( samp0, fragment.texcoord1.xy );\n"
" half4 lightFalloff = idtex2Dproj( samp1, fragment.texcoord2 );\n"
" half4 lightProj = idtex2Dproj( samp2, fragment.texcoord3 );\n"
" half4 lightFalloff = ( idtex2Dproj( samp1, fragment.texcoord2 ) );\n"
" half4 lightProj = ( idtex2Dproj( samp2, fragment.texcoord3 ) );\n"
" half4 YCoCG = tex2D( samp3, fragment.texcoord4.xy );\n"
" half4 specMap = tex2D( samp4, fragment.texcoord5.xy );\n"
" half4 specMap = sRGBAToLinearRGBA( tex2D( samp4, fragment.texcoord5.xy ) );\n"
"\n"
" half3 lightVector = normalize( fragment.texcoord0.xyz );\n"
" half3 diffuseMap = ConvertYCoCgToRGB( YCoCG );\n"
" half3 diffuseMap = sRGBToLinearRGB( ConvertYCoCgToRGB( YCoCG ) );\n"
"\n"
" half3 localNormal;\n"
" // RB begin\n"
@ -4448,13 +4352,13 @@ static const cgShaderDef_t cg_renderprogs[] =
"void main( PS_IN fragment, out PS_OUT result )\n"
"{\n"
" half4 bumpMap = tex2D( samp0, fragment.texcoord1.xy );\n"
" half4 lightFalloff = idtex2Dproj( samp1, fragment.texcoord2 );\n"
" half4 lightProj = idtex2Dproj( samp2, fragment.texcoord3 );\n"
" half4 lightFalloff = ( idtex2Dproj( samp1, fragment.texcoord2 ) );\n"
" half4 lightProj = ( idtex2Dproj( samp2, fragment.texcoord3 ) );\n"
" half4 YCoCG = tex2D( samp3, fragment.texcoord4.xy );\n"
" half4 specMap = tex2D( samp4, fragment.texcoord5.xy );\n"
" half4 specMap = ( tex2D( samp4, fragment.texcoord5.xy ) );\n"
"\n"
" half3 lightVector = normalize( fragment.texcoord0.xyz );\n"
" half3 diffuseMap = ConvertYCoCgToRGB( YCoCG );\n"
" half3 diffuseMap = sRGBToLinearRGB( ConvertYCoCgToRGB( YCoCG ) );\n"
"\n"
" half3 localNormal;\n"
" // RB begin\n"
@ -4485,8 +4389,8 @@ static const cgShaderDef_t cg_renderprogs[] =
" // RB: added abs\n"
" half3 specularContribution = _half3( pow( abs( hDotN ), specularPower ) );\n"
"\n"
" half3 diffuseColor = diffuseMap * rpDiffuseModifier.xyz;\n"
" half3 specularColor = specMap.xyz * specularContribution * rpSpecularModifier.xyz;\n"
" half3 diffuseColor = diffuseMap * sRGBToLinearRGB( rpDiffuseModifier.xyz );\n"
" half3 specularColor = specMap.xyz * specularContribution * sRGBToLinearRGB( rpSpecularModifier.xyz * 1.0 );\n"
" half3 lightColor = lightProj.xyz * lightFalloff.xyz;\n"
" \n"
" half rim = 1.0f - saturate( hDotN );\n"
@ -5631,120 +5535,6 @@ static const cgShaderDef_t cg_renderprogs[] =
},
{
"renderprogs/screen.pixel",
"/*\n"
"===========================================================================\n"
"\n"
"Doom 3 BFG Edition GPL Source Code\n"
"Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. \n"
"Copyright (C) 2014 Robert Beckebans\n"
"\n"
"This file is part of the Doom 3 BFG Edition GPL Source Code (\"Doom 3 BFG Edition Source Code\"). \n"
"\n"
"Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify\n"
"it under the terms of the GNU General Public License as published by\n"
"the Free Software Foundation, either version 3 of the License, or\n"
"(at your option) any later version.\n"
"\n"
"Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,\n"
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
"GNU General Public License for more details.\n"
"\n"
"You should have received a copy of the GNU General Public License\n"
"along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.\n"
"\n"
"In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.\n"
"\n"
"If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.\n"
"\n"
"===========================================================================\n"
"*/\n"
"\n"
"#include \"renderprogs/global.inc\"\n"
"\n"
"uniform sampler2D samp0 : register(s0);\n"
"\n"
"struct PS_IN\n"
"{\n"
" float4 position : VPOS;\n"
" float2 texcoord0 : TEXCOORD0_centroid;\n"
"};\n"
"\n"
"struct PS_OUT\n"
"{\n"
" float4 color : COLOR;\n"
"};\n"
"\n"
"void main( PS_IN fragment, out PS_OUT result )\n"
"{\n"
" float2 tCoords = fragment.texcoord0;\n"
" \n"
" float4 color = tex2D( samp0, tCoords );\n"
" result.color = color;\n"
"}\n"
"\n"
},
{
"renderprogs/screen.vertex",
"/*\n"
"===========================================================================\n"
"\n"
"Doom 3 BFG Edition GPL Source Code\n"
"Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. \n"
"\n"
"This file is part of the Doom 3 BFG Edition GPL Source Code (\"Doom 3 BFG Edition Source Code\"). \n"
"\n"
"Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify\n"
"it under the terms of the GNU General Public License as published by\n"
"the Free Software Foundation, either version 3 of the License, or\n"
"(at your option) any later version.\n"
"\n"
"Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,\n"
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
"GNU General Public License for more details.\n"
"\n"
"You should have received a copy of the GNU General Public License\n"
"along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.\n"
"\n"
"In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.\n"
"\n"
"If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.\n"
"\n"
"===========================================================================\n"
"*/\n"
"\n"
"#include \"renderprogs/global.inc\"\n"
"\n"
"struct VS_IN {\n"
" float4 position : POSITION;\n"
" float2 texcoord : TEXCOORD0;\n"
" float4 normal : NORMAL;\n"
" float4 tangent : TANGENT;\n"
" float4 color : COLOR0;\n"
"};\n"
"\n"
"struct VS_OUT {\n"
" float4 position : POSITION;\n"
" float2 texcoord0 : TEXCOORD0;\n"
"};\n"
"\n"
"void main( VS_IN vertex, out VS_OUT result ) {\n"
" result.position = vertex.position;\n"
"\n"
" //result.position.x = vertex.position; //dot4( vertex.position, rpMVPmatrixX );\n"
" //result.position.y = dot4( vertex.position, rpMVPmatrixY );\n"
" //result.position.z = dot4( vertex.position, rpMVPmatrixZ );\n"
" //result.position.w = dot4( vertex.position, rpMVPmatrixW );\n"
" result.texcoord0 = vertex.texcoord;\n"
"}\n"
},
{
"renderprogs/shadow.pixel",
"/*\n"
@ -7386,243 +7176,6 @@ static const cgShaderDef_t cg_renderprogs[] =
},
{
"renderprogs/tonemap.pixel",
"/*\n"
"===========================================================================\n"
"\n"
"Doom 3 BFG Edition GPL Source Code\n"
"Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. \n"
"Copyright (C) 2009-2014 Robert Beckebans\n"
"\n"
"This file is part of the Doom 3 BFG Edition GPL Source Code (\"Doom 3 BFG Edition Source Code\"). \n"
"\n"
"Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify\n"
"it under the terms of the GNU General Public License as published by\n"
"the Free Software Foundation, either version 3 of the License, or\n"
"(at your option) any later version.\n"
"\n"
"Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,\n"
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
"GNU General Public License for more details.\n"
"\n"
"You should have received a copy of the GNU General Public License\n"
"along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.\n"
"\n"
"In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.\n"
"\n"
"If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.\n"
"\n"
"===========================================================================\n"
"*/\n"
"\n"
"#include \"renderprogs/global.inc\"\n"
"\n"
"uniform sampler2D samp0 : register(s0);\n"
"\n"
"struct PS_IN\n"
"{\n"
" float4 position : VPOS;\n"
" float2 texcoord0 : TEXCOORD0_centroid;\n"
"};\n"
"\n"
"struct PS_OUT\n"
"{\n"
" float4 color : COLOR;\n"
"};\n"
"\n"
"void main( PS_IN fragment, out PS_OUT result )\n"
"{\n"
" float2 tCoords = fragment.texcoord0;\n"
" \n"
"#if defined(BRIGHTPASS_FILTER)\n"
" // multiply with 4 because the FBO is only 1/4th of the screen resolution\n"
" tCoords *= float2( 4.0, 4.0 );\n"
"#endif\n"
" \n"
" float4 color = tex2D( samp0, tCoords );\n"
" \n"
"#if 0\n"
" const float hdrGamma = 2.2;\n"
" float gamma = 1.0 / hdrGamma;\n"
" color.r = pow( color.r, gamma );\n"
" color.g = pow( color.g, gamma );\n"
" color.b = pow( color.b, gamma );\n"
"#endif\n"
" \n"
" // see http://www.gamedev.net/reference/articles/article2208.asp\n"
" // for Mathematics of Reinhard's Photographic Tone Reproduction Operator\n"
" \n"
" // get the luminance of the current pixel\n"
" float Y = dot( LUMINANCE_VECTOR, color );\n"
"\n"
"#if defined(BRIGHTPASS)\n"
" if(Y < 0.1)\n"
" {\n"
" //discard;\n"
" result.color = float4( 0.0, 0.0, 0.0, 1.0 );\n"
" return;\n"
" }\n"
"#endif\n"
" \n"
" float hdrKey = rpScreenCorrectionFactor.x;\n"
" float hdrAverageLuminance = rpScreenCorrectionFactor.y;\n"
" float hdrMaxLuminance = rpScreenCorrectionFactor.z;\n"
" \n"
" // calculate the relative luminance\n"
" float Yr = hdrKey * Y / hdrAverageLuminance;\n"
"\n"
" float Ymax = hdrMaxLuminance;\n"
"\n"
" /*\n"
"#if 0\n"
" float L = Yr * ( 1.0 + Yr / ( Ymax * Ymax ) ) / ( 1.0 + Yr );\n"
"#else\n"
" float L = 1.0 - exp( -Yr );\n"
"#endif\n"
" \n"
" color.rgb *= L;\n"
" */\n"
" \n"
" // RGB -> XYZ conversion \n"
" const mat3 RGB2XYZ = mat3( 0.4124564, 0.3575761, 0.1804375, \n"
" 0.2126729, 0.7151522, 0.0721750, \n"
" 0.0193339, 0.1191920, 0.9503041); \n"
" \n"
" float3 XYZ = RGB2XYZ * color.rgb;\n"
" \n"
" // XYZ -> Yxy conversion \n"
" float3 Yxy; \n"
" \n"
" // Y = Y luminance\n"
" Yxy.r = XYZ.g;\n"
" \n"
" // x = X / (X + Y + Z)\n"
" Yxy.g = XYZ.r / ( XYZ.r + XYZ.g + XYZ.b );\n"
" \n"
" // y = Y / (X + Y + Z)\n"
" Yxy.b = XYZ.g / ( XYZ.r + XYZ.g + XYZ.b );\n"
" \n"
" // (Lp) map average luminance to the middlegrey zone by scaling pixel luminance \n"
" float Lp = Yxy.r * hdrKey / hdrAverageLuminance;\n"
" \n"
" // (Ld) scale all luminance within a displayable range of 0 to 1\n"
" \n"
"#if 1 //defined(r_HDRToneMappingOperator_1)\n"
" Yxy.r = ( Lp * ( 1.0 + Lp / ( Ymax * Ymax ) ) ) / ( 1.0 + Lp );\n"
"#else\n"
" Yxy.r = 1.0 - exp( -Lp );\n"
"#endif\n"
" \n"
" // Yxy -> XYZ conversion \n"
" \n"
" // X = Y * x / y\n"
" XYZ.r = Yxy.r * Yxy.g / Yxy.b;\n"
" \n"
" // Y = Y\n"
" XYZ.g = Yxy.r;\n"
" \n"
" // Z = Y * (1-x-y) / y or Z = (1 - x - y) * (Y / y)\n"
" XYZ.b = ( 1 - Yxy.g - Yxy.b ) * ( Yxy.r / Yxy.b );\n"
" \n"
" // XYZ -> RGB conversion\n"
" const mat3 XYZ2RGB = mat3( 3.2404542, -1.5371385, -0.4985314,\n"
" -0.9692660, 1.8760108, 0.0415560,\n"
" 0.0556434, -0.2040259, 1.0572252);\n"
" \n"
" color.rgb = clamp(XYZ2RGB * XYZ, 0.0, 1.0);\n"
" // color.rgb *= Yxy.r;\n"
" \n"
"#if defined(BRIGHTPASS)\n"
" // adjust contrast\n"
" // L = pow(L, 1.32);\n"
" \n"
" const half hdrContrastThreshold = rpOverbright.x;\n"
" const half hdrContrastOffset = rpOverbright.y;\n"
" \n"
" float T = max( Lp - hdrContrastThreshold, 0.0 );\n"
" // float T = max(1.0 - exp( -Yr ) - hdrContrastThreshold, 0.0);\n"
" float B = T > 0.0 ? T / (hdrContrastOffset + T) : T;\n"
" \n"
" color.rgb *= clamp( B, 0.0, 1.0 );\n"
"#endif\n"
" \n"
"#if 0\n"
" const float hdrGamma = 2.2;\n"
" float gamma = 1.0 / hdrGamma;\n"
" color.r = pow( color.r, gamma );\n"
" color.g = pow( color.g, gamma );\n"
" color.b = pow( color.b, gamma );\n"
"#endif\n"
" \n"
" result.color = color;\n"
" \n"
"#if 0\n"
" result.color = float4( Lp, Lp, Lp, 1.0 );\n"
"#endif\n"
"}\n"
"\n"
},
{
"renderprogs/tonemap.vertex",
"/*\n"
"===========================================================================\n"
"\n"
"Doom 3 BFG Edition GPL Source Code\n"
"Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. \n"
"\n"
"This file is part of the Doom 3 BFG Edition GPL Source Code (\"Doom 3 BFG Edition Source Code\"). \n"
"\n"
"Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify\n"
"it under the terms of the GNU General Public License as published by\n"
"the Free Software Foundation, either version 3 of the License, or\n"
"(at your option) any later version.\n"
"\n"
"Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,\n"
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
"GNU General Public License for more details.\n"
"\n"
"You should have received a copy of the GNU General Public License\n"
"along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.\n"
"\n"
"In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.\n"
"\n"
"If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.\n"
"\n"
"===========================================================================\n"
"*/\n"
"\n"
"#include \"renderprogs/global.inc\"\n"
"\n"
"struct VS_IN {\n"
" float4 position : POSITION;\n"
" float2 texcoord : TEXCOORD0;\n"
" float4 normal : NORMAL;\n"
" float4 tangent : TANGENT;\n"
" float4 color : COLOR0;\n"
"};\n"
"\n"
"struct VS_OUT {\n"
" float4 position : POSITION;\n"
" float2 texcoord0 : TEXCOORD0;\n"
"};\n"
"\n"
"void main( VS_IN vertex, out VS_OUT result ) {\n"
" result.position = vertex.position;\n"
"\n"
" //result.position.x = vertex.position; //dot4( vertex.position, rpMVPmatrixX );\n"
" //result.position.y = dot4( vertex.position, rpMVPmatrixY );\n"
" //result.position.z = dot4( vertex.position, rpMVPmatrixZ );\n"
" //result.position.w = dot4( vertex.position, rpMVPmatrixW );\n"
" result.texcoord0 = vertex.texcoord;\n"
"}\n"
},
{
"renderprogs/vertex_color.pixel",
"/*\n"
@ -7670,7 +7223,7 @@ static const cgShaderDef_t cg_renderprogs[] =
"\n"
"void main( PS_IN fragment, out PS_OUT result )\n"
"{\n"
" result.color = fragment.color;\n"
" result.color = sRGBAToLinearRGBA( fragment.color );\n"
"}\n"
},

View file

@ -284,7 +284,7 @@ static void R_CheckCvars()
r_useSRGB.ClearModified();
if( glConfig.sRGBFramebufferAvailable )
{
if( r_useSRGB.GetBool() )
if( r_useSRGB.GetBool() && r_useSRGB.GetInteger() != 3 )
{
glEnable( GL_FRAMEBUFFER_SRGB );
}