Improved r_hdrDebug which shows F-stops like in Filament

This commit is contained in:
Robert Beckebans 2020-04-20 20:48:13 +02:00
parent c8250b184b
commit 16f4188e2b
4 changed files with 37 additions and 7 deletions

View file

@ -2,7 +2,7 @@
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 2014 Robert Beckebans
Copyright (C) 2014-2020 Robert Beckebans
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").

View file

@ -33,11 +33,11 @@ If you have questions concerning this license or the applicable additional terms
uniform sampler2D samp0 : register(s0); // texture 1 is the per-surface normal map
uniform sampler2D samp1 : register(s1); // texture 3 is the per-surface specular or roughness/metallic/AO mixer map
uniform sampler2D samp2 : register(s2); // texture 2 is the per-surface baseColor map
uniform sampler2D samp3 : register(s3); // texture 4 is the light falloff texture
uniform sampler2D samp4 : register(s4); // texture 5 is the light projection texture
uniform sampler2D samp3 : register(s3); // texture 4 is the BRDF LUT
uniform sampler2D samp4 : register(s4); // texture 5 is unused
uniform samplerCUBE samp7 : register(s7); // texture 0 is the cube map
uniform samplerCUBE samp8 : register(s8); // texture 0 is the cube map
uniform samplerCUBE samp7 : register(s7); // texture 6 is the irradiance cube map
uniform samplerCUBE samp8 : register(s8); // texture 7 is the radiance cube map
struct PS_IN {
half4 position : VPOS;

View file

@ -222,6 +222,7 @@ void main( PS_IN fragment, out PS_OUT result )
}
shadow *= stepSize;
#elif 1
const float2 poissonDisk[12] = float2[](

View file

@ -208,8 +208,37 @@ void main( PS_IN fragment, out PS_OUT result )
#endif
#if defined(HDR_DEBUG)
//color = tex2D( samp1, float2( L, 0.0 ) );
color = tex2D( samp1, float2( dot( LUMINANCE_SRGB, color ), 0.0 ) );
// https://google.github.io/filament/Filament.md.html#figure_luminanceviz
const float3 debugColors[16] = float3[](
float3(0.0, 0.0, 0.0), // black
float3(0.0, 0.0, 0.1647), // darkest blue
float3(0.0, 0.0, 0.3647), // darker blue
float3(0.0, 0.0, 0.6647), // dark blue
float3(0.0, 0.0, 0.9647), // blue
float3(0.0, 0.9255, 0.9255), // cyan
float3(0.0, 0.5647, 0.0), // dark green
float3(0.0, 0.7843, 0.0), // green
float3(1.0, 1.0, 0.0), // yellow
float3(0.90588, 0.75294, 0.0), // yellow-orange
float3(1.0, 0.5647, 0.0), // orange
float3(1.0, 0.0, 0.0), // bright red
float3(0.8392, 0.0, 0.0), // red
float3(1.0, 0.0, 1.0), // magenta
float3(0.6, 0.3333, 0.7882), // purple
float3(1.0, 1.0, 1.0) // white
);
// The 5th color in the array (cyan) represents middle gray (18%)
// Every stop above or below middle gray causes a color shift
float v = log2( Y / 0.18 );
v = clamp( v + 5.0, 0.0, 15.0 );
int index = int( floor( v ) );
color.rgb = lerp( debugColors[index], debugColors[ min(15, index + 1) ], fract( v ) );
//color = tex2D( samp1, float2( L, 0.0 ) );
//color = tex2D( samp1, float2( dot( LUMINANCE_SRGB, color ), 0.0 ) );
#endif
result.color = color;