mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-15 07:00:58 +00:00
Experimental changes to test PBR texture set
This commit is contained in:
parent
f97bfe3eb4
commit
0f8ee906da
4 changed files with 40 additions and 47 deletions
|
@ -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-2019 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").
|
||||
|
||||
|
@ -60,7 +60,8 @@ void main( PS_IN fragment, out PS_OUT result ) {
|
|||
// half4 lightFalloff = idtex2Dproj( samp1, fragment.texcoord2 );
|
||||
// half4 lightProj = idtex2Dproj( samp2, fragment.texcoord3 );
|
||||
half4 YCoCG = tex2D( samp2, fragment.texcoord1.xy );
|
||||
half4 specMap = tex2D( samp1, fragment.texcoord2.xy );
|
||||
half4 specMapSRGB = tex2D( samp1, fragment.texcoord2.xy );
|
||||
half4 specMap = sRGBAToLinearRGBA( specMapSRGB );
|
||||
|
||||
//half3 lightVector = normalize( fragment.texcoord0.xyz );
|
||||
half3 diffuseMap = sRGBToLinearRGB( ConvertYCoCgToRGB( YCoCG ) );
|
||||
|
@ -99,10 +100,11 @@ void main( PS_IN fragment, out PS_OUT result ) {
|
|||
float3 reflectionVector = globalNormal * dot3( globalEye, globalNormal );
|
||||
reflectionVector = ( reflectionVector * 2.0f ) - globalEye;
|
||||
|
||||
#if defined(USE_PBR)
|
||||
#if 1 //defined(USE_PBR)
|
||||
|
||||
const half metallic = specMap.g;
|
||||
const half roughness = specMap.r;
|
||||
#if 1 //defined(USE_METALNESS)
|
||||
const half metallic = specMapSRGB.g;
|
||||
const half roughness = specMapSRGB.r;
|
||||
const half glossiness = 1.0 - roughness;
|
||||
|
||||
// the vast majority of real-world materials (anything not metal or gems) have F(0°)
|
||||
|
@ -116,11 +118,21 @@ void main( PS_IN fragment, out PS_OUT result ) {
|
|||
|
||||
half3 diffuseColor = baseColor * ( 1.0 - metallic );
|
||||
half3 specularColor = lerp( dielectricColor, baseColor, metallic );
|
||||
#else
|
||||
// HACK calculate roughness from D3 gloss maps
|
||||
float Y = dot( LUMINANCE_SRGB.rgb, specMapSRGB.rgb );
|
||||
|
||||
//diffuseColor = half3( 1.0 );
|
||||
float3 diffuseLight = ( texCUBE( samp7, globalNormal ).rgb ) * diffuseColor * ( rpDiffuseModifier.xyz ) * 1.5f;
|
||||
//const float glossiness = clamp( 1.0 - specMapSRGB.r, 0.0, 0.98 );
|
||||
const float glossiness = clamp( pow( Y, 1.0 / 2.0 ), 0.0, 0.98 );
|
||||
|
||||
//specularColor = half3( 0.0 );
|
||||
const float roughness = 1.0 - glossiness;
|
||||
|
||||
half3 diffuseColor = diffuseMap;
|
||||
half3 specularColor = specMap.rgb;
|
||||
|
||||
#endif
|
||||
|
||||
float3 diffuseLight = ( texCUBE( samp7, globalNormal ).rgb ) * diffuseColor * ( rpDiffuseModifier.xyz ) * 3.5f;
|
||||
|
||||
float mip = clamp( ( roughness * 7.0 ) + 3.0, 0.0, 10.0 );
|
||||
float3 envColor = ( textureLod( samp8, reflectionVector, mip ).rgb ) * ( rpSpecularModifier.xyz ) * 1.0f;
|
||||
|
@ -129,11 +141,9 @@ void main( PS_IN fragment, out PS_OUT result ) {
|
|||
|
||||
#else
|
||||
|
||||
half4 specMapSRGB = specMap;
|
||||
specMap = sRGBAToLinearRGBA( specMap );
|
||||
|
||||
//float3 diffuseLight = sRGBToLinearRGB( texCUBE( samp7, globalNormal ).rgb ) * diffuseMap.rgb * ( rpDiffuseModifier.xyz ) * 3.5f;
|
||||
float3 diffuseLight = ( texCUBE( samp7, globalNormal ).rgb ) * diffuseMap.rgb * ( rpDiffuseModifier.xyz ) * 3.5f;
|
||||
// non PBR path
|
||||
|
||||
float3 diffuseLight = ( texCUBE( samp7, globalNormal ).rgb ) * diffuseMap.rgb * ( rpDiffuseModifier.xyz ) * 3.5f;
|
||||
//float3 diffuseLight = diffuseMap.rgb * ( rpDiffuseModifier.xyz ) * 1.5f;
|
||||
|
||||
// HACK calculate roughness from D3 gloss maps
|
||||
|
|
|
@ -98,7 +98,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
|
||||
#if 1 //defined(USE_PBR)
|
||||
|
||||
#if 0 //defined(USE_METALNESS)
|
||||
#if 1 //defined(USE_METALNESS)
|
||||
const half metallic = specMapSRGB.g;
|
||||
const half roughness = specMapSRGB.r;
|
||||
const half glossiness = 1.0 - roughness;
|
||||
|
@ -139,7 +139,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
half ldotH = clamp( dot3( lightVector, halfAngleVector ), 0.0, 1.0 );
|
||||
|
||||
// compensate r_lightScale 3 * 2
|
||||
half3 reflectColor = specMap.rgb * rpSpecularModifier.rgb * 1.0;// * 0.5;
|
||||
half3 reflectColor = specularColor * rpSpecularModifier.rgb * 1.0;// * 0.5;
|
||||
|
||||
// cheap approximation by ARM with only one division
|
||||
// http://community.arm.com/servlet/JiveServlet/download/96891546-19496/siggraph2015-mmg-renaldas-slides.pdf
|
||||
|
|
|
@ -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-2014 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").
|
||||
|
||||
|
@ -280,7 +280,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
|
||||
#if 1 //defined(USE_PBR)
|
||||
|
||||
#if 0 //defined(USE_METALNESS)
|
||||
#if 1 //defined(USE_METALNESS)
|
||||
const half metallic = specMapSRGB.g;
|
||||
const half roughness = specMapSRGB.r;
|
||||
const half glossiness = 1.0 - roughness;
|
||||
|
@ -321,7 +321,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
half ldotH = clamp( dot3( lightVector, halfAngleVector ), 0.0, 1.0 );
|
||||
|
||||
// compensate r_lightScale 3 * 2
|
||||
half3 reflectColor = specMap.rgb * rpSpecularModifier.rgb * 1.0;// * 0.5;
|
||||
half3 reflectColor = specularColor * rpSpecularModifier.rgb * 1.0;// * 0.5;
|
||||
|
||||
// cheap approximation by ARM with only one division
|
||||
// http://community.arm.com/servlet/JiveServlet/download/96891546-19496/siggraph2015-mmg-renaldas-slides.pdf
|
||||
|
|
|
@ -241,35 +241,6 @@ void idImage::AllocImage( const idImageOpts& imgOpts, textureFilter_t tf, textur
|
|||
}
|
||||
|
||||
/*
|
||||
|
||||
|
||||
// foresthale 2014-05-30: give a nice progress display when binarizing
|
||||
commonLocal.LoadPacifierBinarizeFilename( GetName() , "generated image" );
|
||||
if( opts.numLevels > 1 )
|
||||
{
|
||||
commonLocal.LoadPacifierBinarizeProgressTotal( opts.width * opts.height * 4 / 3 );
|
||||
}
|
||||
else
|
||||
{
|
||||
commonLocal.LoadPacifierBinarizeProgressTotal( opts.width * opts.height );
|
||||
}
|
||||
|
||||
commonLocal.LoadPacifierBinarizeEnd();
|
||||
|
||||
|
||||
// foresthale 2014-05-30: give a nice progress display when binarizing
|
||||
commonLocal.LoadPacifierBinarizeFilename( GetName(), "generated cube image" );
|
||||
if( opts.numLevels > 1 )
|
||||
{
|
||||
commonLocal.LoadPacifierBinarizeProgressTotal( opts.width * opts.width * 6 * 4 / 3 );
|
||||
}
|
||||
else
|
||||
{
|
||||
commonLocal.LoadPacifierBinarizeProgressTotal( opts.width * opts.width * 6 );
|
||||
}
|
||||
|
||||
commonLocal.LoadPacifierBinarizeEnd();
|
||||
|
||||
===============
|
||||
GetGeneratedName
|
||||
|
||||
|
@ -314,6 +285,12 @@ void idImage::ActuallyLoadImage( bool fromBackEnd )
|
|||
return;
|
||||
}
|
||||
|
||||
// RB: the following does not load the source images from disk because pic is NULL
|
||||
// but it tries to get the timestamp to see if we have a newer file than the one in the compressed .bimage
|
||||
|
||||
// TODO also check for alternative names like .png suffices or _rmao.png or even _rmaod.png files
|
||||
// to support the PBR code path
|
||||
|
||||
if( com_productionMode.GetInteger() != 0 )
|
||||
{
|
||||
sourceFileTime = FILE_NOT_FOUND_TIMESTAMP;
|
||||
|
@ -349,6 +326,7 @@ void idImage::ActuallyLoadImage( bool fromBackEnd )
|
|||
idStrStatic< MAX_OSPATH > generatedName = GetName();
|
||||
GetGeneratedName( generatedName, usage, cubeFiles );
|
||||
|
||||
// RB: try to load the .bimage and skip if sourceFileTime is newer
|
||||
idBinaryImage im( generatedName );
|
||||
binaryFileTime = im.LoadFromGeneratedFile( sourceFileTime );
|
||||
|
||||
|
@ -417,6 +395,8 @@ void idImage::ActuallyLoadImage( bool fromBackEnd )
|
|||
}
|
||||
else
|
||||
{
|
||||
// RB: try to read the source image from disk
|
||||
|
||||
idStr binarizeReason = "binarize: unknown reason";
|
||||
if( binaryFileTime == FILE_NOT_FOUND_TIMESTAMP )
|
||||
{
|
||||
|
@ -540,11 +520,14 @@ void idImage::ActuallyLoadImage( bool fromBackEnd )
|
|||
commonLocal.LoadPacifierBinarizeProgressTotal( opts.width * opts.width * 6 );
|
||||
}
|
||||
|
||||
// RB: convert to compressed DXT or whatever choosen target format
|
||||
im.Load2DFromMemory( opts.width, opts.height, pic, opts.numLevels, opts.format, opts.colorFormat, opts.gammaMips );
|
||||
commonLocal.LoadPacifierBinarizeEnd();
|
||||
|
||||
Mem_Free( pic );
|
||||
}
|
||||
|
||||
// RB: write the compressed .bimage which contains the optimized GPU format
|
||||
binaryFileTime = im.WriteGeneratedFile( sourceFileTime );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue