Fixed textureLod with Vulkan and tweaked IBL to use r_lightScale

This commit is contained in:
Robert Beckebans 2020-05-01 21:11:13 +02:00
parent 6037889a85
commit 3f9b85d434
5 changed files with 2124 additions and 1704 deletions

View file

@ -31,14 +31,14 @@ If you have questions concerning this license or the applicable additional terms
#include "BRDF.inc.hlsl"
// *INDENT-OFF*
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 samp0 : register(s0); // texture 0 is the per-surface normal map
uniform sampler2D samp1 : register(s1); // texture 1 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 BRDF LUT
uniform sampler2D samp4 : register(s4); // texture 5 is SSAO
uniform sampler2D samp3 : register(s3); // texture 3 is the BRDF LUT
uniform sampler2D samp4 : register(s4); // texture 4 is SSAO
uniform samplerCUBE samp7 : register(s7); // texture 6 is the irradiance cube map
uniform samplerCUBE samp8 : register(s8); // texture 7 is the radiance cube map
uniform samplerCUBE samp7 : register(s7); // texture 7 is the irradiance cube map
uniform samplerCUBE samp8 : register(s8); // texture 8 is the radiance cube map
struct PS_IN
{
@ -169,13 +169,14 @@ void main( PS_IN fragment, out PS_OUT result )
// evaluate diffuse IBL
float3 irradiance = texCUBE( samp7, globalNormal ).rgb;
float3 diffuseLight = ( kD * irradiance * diffuseColor ) * ao * ( rpDiffuseModifier.xyz * 3.0 );
float3 diffuseLight = ( kD * irradiance * diffuseColor ) * ao * ( rpDiffuseModifier.xyz * 1.0 );
// evaluate specular IBL
// should be 4.0
// should be 8 = numMips - 1, 256^2 = 9 mips
const float MAX_REFLECTION_LOD = 10.0;
float mip = clamp( ( roughness * MAX_REFLECTION_LOD ) + 0.0, 0.0, 10.0 );
float mip = clamp( ( roughness * MAX_REFLECTION_LOD ), 0.0, MAX_REFLECTION_LOD );
//float mip = 0.0;
float3 radiance = textureLod( samp8, reflectionVector, mip ).rgb;
float2 envBRDF = texture( samp3, float2( max( vDotN, 0.0 ), roughness ) ).rg;
@ -187,7 +188,7 @@ void main( PS_IN fragment, out PS_OUT result )
#endif
float specAO = ComputeSpecularAO( vDotN, ao, roughness );
float3 specularLight = radiance * ( kS * envBRDF.x + float3( envBRDF.y ) ) * specAO * ( rpSpecularModifier.xyz * 0.75 );
float3 specularLight = radiance * ( kS * envBRDF.x + float3( envBRDF.y ) ) * specAO * ( rpSpecularModifier.xyz * 0.5 );
#if 0
// Marmoset Horizon Fade trick

View file

@ -2129,7 +2129,7 @@ void idRenderBackend::AmbientPass( const drawSurf_t* const* drawSurfs, int numDr
GL_Color( colorWhite );
const float lightScale = 1.0f; //r_lightScale.GetFloat();
const float lightScale = r_useHDR.GetBool() ? r_lightScale.GetFloat() * 0.666f : r_lightScale.GetFloat();
const idVec4 lightColor = colorWhite * lightScale;
// apply the world-global overbright and the 2x factor for specular

File diff suppressed because it is too large Load diff

View file

@ -282,9 +282,9 @@ idCVar r_ldrContrastOffset( "r_ldrContrastOffset", "3", CVAR_RENDERER | CVAR_FLO
idCVar r_useFilmicPostProcessEffects( "r_useFilmicPostProcessEffects", "1", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL, "apply several post process effects to mimic a filmic look" );
#if defined( USE_VULKAN )
idCVar r_forceAmbient( "r_forceAmbient", "0.2", CVAR_RENDERER | CVAR_FLOAT, "render additional ambient pass to make the game less dark", 0.0f, 0.4f );
idCVar r_forceAmbient( "r_forceAmbient", "0.2", CVAR_RENDERER | CVAR_FLOAT, "render additional ambient pass to make the game less dark", 0.0f, 0.75f );
#else
idCVar r_forceAmbient( "r_forceAmbient", "0.3", CVAR_RENDERER | CVAR_FLOAT, "render additional ambient pass to make the game less dark", 0.0f, 0.4f );
idCVar r_forceAmbient( "r_forceAmbient", "0.3", CVAR_RENDERER | CVAR_FLOAT, "render additional ambient pass to make the game less dark", 0.0f, 0.75f );
#endif
idCVar r_useSSGI( "r_useSSGI", "0", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL, "use screen space global illumination and reflections" );

View file

@ -236,6 +236,10 @@ void idImage::CreateSampler()
createInfo.compareEnable = ( opts.format == FMT_DEPTH );
createInfo.compareOp = ( opts.format == FMT_DEPTH ) ? VK_COMPARE_OP_LESS_OR_EQUAL : VK_COMPARE_OP_NEVER;
// RB: support textureLod
createInfo.minLod = 0.0f;
createInfo.maxLod = opts.numLevels;
switch( filter )
{
case TF_DEFAULT: