mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-15 07:00:58 +00:00
r_useSRGB fixes
This commit is contained in:
parent
395ef525b1
commit
96aff1e923
7 changed files with 51 additions and 14 deletions
|
@ -180,6 +180,24 @@ float rand( float2 co ) {
|
|||
|
||||
#define DEG2RAD( a ) ( ( a ) * PI / 180.0f )
|
||||
#define RAD2DEG( a ) ( ( a ) * 180.0f / PI )
|
||||
|
||||
half3 sRGBToLinearRGB( half3 rgb )
|
||||
{
|
||||
#if defined(USE_SRGB)
|
||||
return pow( rgb, half3( 2.2 ) );
|
||||
#else
|
||||
return rgb;
|
||||
#endif
|
||||
}
|
||||
|
||||
half4 sRGBAToLinearRGBA( half4 rgba )
|
||||
{
|
||||
#if defined(USE_SRGB)
|
||||
return pow( rgba, half4( 2.2 ) );
|
||||
#else
|
||||
return rgba;
|
||||
#endif
|
||||
}
|
||||
// RB end
|
||||
|
||||
#define _half2( x ) half2( x )
|
||||
|
|
|
@ -54,5 +54,5 @@ void main( PS_IN fragment, out PS_OUT result ) {
|
|||
screenTexCoord = saturate( screenTexCoord );
|
||||
|
||||
// load the screen render
|
||||
result.color = tex2D( samp0, screenTexCoord.xy );
|
||||
result.color = sRGBAToLinearRGBA( tex2D( samp0, screenTexCoord.xy ) );
|
||||
}
|
|
@ -53,13 +53,13 @@ struct PS_OUT {
|
|||
|
||||
void main( PS_IN fragment, out PS_OUT result ) {
|
||||
half4 bumpMap = tex2D( samp0, fragment.texcoord1.xy );
|
||||
half4 lightFalloff = idtex2Dproj( samp1, fragment.texcoord2 );
|
||||
half4 lightProj = idtex2Dproj( samp2, fragment.texcoord3 );
|
||||
half4 lightFalloff = sRGBAToLinearRGBA( idtex2Dproj( samp1, fragment.texcoord2 ) );
|
||||
half4 lightProj = sRGBAToLinearRGBA( idtex2Dproj( samp2, fragment.texcoord3 ) );
|
||||
half4 YCoCG = tex2D( samp3, fragment.texcoord4.xy );
|
||||
half4 specMap = tex2D( samp4, fragment.texcoord5.xy );
|
||||
half4 specMap = sRGBAToLinearRGBA( tex2D( samp4, fragment.texcoord5.xy ) );
|
||||
|
||||
half3 lightVector = normalize( fragment.texcoord0.xyz );
|
||||
half3 diffuseMap = ConvertYCoCgToRGB( YCoCG );
|
||||
half3 diffuseMap = sRGBToLinearRGB( ConvertYCoCgToRGB( YCoCG ) );
|
||||
|
||||
half3 localNormal;
|
||||
// RB begin
|
||||
|
|
|
@ -63,13 +63,13 @@ struct PS_OUT
|
|||
void main( PS_IN fragment, out PS_OUT result )
|
||||
{
|
||||
half4 bumpMap = tex2D( samp0, fragment.texcoord1.xy );
|
||||
half4 lightFalloff = idtex2Dproj( samp1, fragment.texcoord2 );
|
||||
half4 lightProj = idtex2Dproj( samp2, fragment.texcoord3 );
|
||||
half4 lightFalloff = sRGBAToLinearRGBA( idtex2Dproj( samp1, fragment.texcoord2 ) );
|
||||
half4 lightProj = sRGBAToLinearRGBA( idtex2Dproj( samp2, fragment.texcoord3 ) );
|
||||
half4 YCoCG = tex2D( samp3, fragment.texcoord4.xy );
|
||||
half4 specMap = tex2D( samp4, fragment.texcoord5.xy );
|
||||
half4 specMap = sRGBAToLinearRGBA( tex2D( samp4, fragment.texcoord5.xy ) );
|
||||
|
||||
half3 lightVector = normalize( fragment.texcoord0.xyz );
|
||||
half3 diffuseMap = ConvertYCoCgToRGB( YCoCG );
|
||||
half3 diffuseMap = sRGBToLinearRGB( ConvertYCoCgToRGB( YCoCG ) );
|
||||
|
||||
half3 localNormal;
|
||||
// RB begin
|
||||
|
|
|
@ -354,27 +354,38 @@ void idImage::AllocImage()
|
|||
GL_CheckErrors();
|
||||
PurgeImage();
|
||||
|
||||
int sRGB = r_useSRGB.GetInteger();
|
||||
|
||||
switch( opts.format )
|
||||
{
|
||||
case FMT_RGBA8:
|
||||
internalFormat = GL_RGBA8;
|
||||
internalFormat = ( glConfig.sRGBFramebufferAvailable && ( sRGB == 1 || sRGB == 3 ) ) ? GL_SRGB8_ALPHA8 : GL_RGBA8;
|
||||
dataFormat = GL_RGBA;
|
||||
dataType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
case FMT_XRGB8:
|
||||
internalFormat = GL_RGB;
|
||||
internalFormat = ( glConfig.sRGBFramebufferAvailable && ( sRGB == 1 || sRGB == 3 ) ) ? GL_SRGB : GL_RGB;
|
||||
dataFormat = GL_RGBA;
|
||||
dataType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
case FMT_RGB565:
|
||||
//internalFormat = ( glConfig.sRGBFramebufferAvailable && ( sRGB == 1 || sRGB == 3 ) ) ? GL_SRGB : GL_RGB;
|
||||
internalFormat = GL_RGB;
|
||||
dataFormat = GL_RGB;
|
||||
dataType = GL_UNSIGNED_SHORT_5_6_5;
|
||||
break;
|
||||
case FMT_ALPHA:
|
||||
#if defined( USE_CORE_PROFILE )
|
||||
internalFormat = GL_R8;
|
||||
dataFormat = GL_RED;
|
||||
if( ( glConfig.sRGBFramebufferAvailable && ( sRGB == 1 || sRGB == 3 ) ) )
|
||||
{
|
||||
internalFormat = GL_SRGB8_ALPHA8;
|
||||
dataFormat = GL_ALPHA;
|
||||
}
|
||||
else
|
||||
{
|
||||
internalFormat = GL_R8;
|
||||
dataFormat = GL_RED;
|
||||
}
|
||||
#else
|
||||
internalFormat = GL_ALPHA8;
|
||||
dataFormat = GL_ALPHA;
|
||||
|
@ -412,11 +423,13 @@ void idImage::AllocImage()
|
|||
dataType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
case FMT_DXT1:
|
||||
internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
||||
//internalFormat = ( glConfig.sRGBFramebufferAvailable && ( sRGB == 1 || sRGB == 3 ) ) ? GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT : GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
||||
internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
||||
dataFormat = GL_RGBA;
|
||||
dataType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
case FMT_DXT5:
|
||||
//internalFormat = ( glConfig.sRGBFramebufferAvailable && ( sRGB == 1 || sRGB == 3 ) ) ? GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT : GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
||||
internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
||||
dataFormat = GL_RGBA;
|
||||
dataType = GL_UNSIGNED_BYTE;
|
||||
|
|
|
@ -552,6 +552,11 @@ idStr StripDeadCode( const idStr& in, const char* name, const idStrList& compile
|
|||
{
|
||||
src.AddDefine( "USE_HALF_LAMBERT" );
|
||||
}
|
||||
|
||||
if( r_useSRGB.GetBool() )
|
||||
{
|
||||
src.AddDefine( "USE_SRGB" );
|
||||
}
|
||||
|
||||
idList< idCGBlock > blocks;
|
||||
|
||||
|
|
|
@ -959,6 +959,7 @@ extern idCVar r_useShadowDepthBounds; // use depth bounds test on individual sh
|
|||
// RB begin
|
||||
extern idCVar r_useShadowMapping; // use shadow mapping instead of stencil shadows
|
||||
extern idCVar r_useHalfLambertLighting; // use Half-Lambert lighting instead of classic Lambert
|
||||
extern idCVar r_useSRGB;
|
||||
// RB end
|
||||
|
||||
extern idCVar r_skipStaticInteractions; // skip interactions created at level load
|
||||
|
|
Loading…
Reference in a new issue