From 3153a83621e610c591eb75f3f0b712f0082a904b Mon Sep 17 00:00:00 2001 From: Ivan 'provod' Avdeev Date: Thu, 11 Jan 2024 11:56:23 -0500 Subject: [PATCH] vk: rt: add material debug display mode Also add debug display modes info --- ref/vk/shaders/denoiser.comp | 5 ++++- ref/vk/shaders/ray_interop.h | 1 + ref/vk/vk_rtx.c | 35 ++++++++++++++++++----------------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/ref/vk/shaders/denoiser.comp b/ref/vk/shaders/denoiser.comp index d6a8cc0b..de1bfc73 100644 --- a/ref/vk/shaders/denoiser.comp +++ b/ref/vk/shaders/denoiser.comp @@ -234,6 +234,9 @@ void main() { } else if (ubo.ubo.debug_display_only == DEBUG_DISPLAY_EMISSIVE) { imageStore(out_dest, pix, vec4(LINEARtoSRGB(imageLoad(emissive, pix).rgb), 0.)); return; return; + } else if (ubo.ubo.debug_display_only == DEBUG_DISPLAY_MATERIAL) { + imageStore(out_dest, pix, vec4(imageLoad(material_rmxx, pix).rg, 0., 0.)); return; + return; } else if (ubo.ubo.debug_display_only == DEBUG_DISPLAY_NSHADE) { vec3 geometry_normal, shading_normal; readNormals(pix, geometry_normal, shading_normal); @@ -377,7 +380,7 @@ void main() { colour = LINEARtoSRGB(colour); // See issue https://github.com/w23/xash3d-fwgs/issues/668, map test_blendmode_additive_alpha. -// Adding emissive_blend to the final color in the *incorrect* sRGB-γ space. It makes +// Adding emissive_blend to the final color in the *incorrect* sRGB-¿ space. It makes // it look much more like the original. Adding emissive in the *correct* linear space differs // from the original a lot, and looks perceptively worse. colour += legacy_blend.rgb; diff --git a/ref/vk/shaders/ray_interop.h b/ref/vk/shaders/ray_interop.h index fbb21db9..eba7cf81 100644 --- a/ref/vk/shaders/ray_interop.h +++ b/ref/vk/shaders/ray_interop.h @@ -184,6 +184,7 @@ struct LightCluster { #define DEBUG_DISPLAY_INDIRECT_DIFF 12 #define DEBUG_DISPLAY_INDIRECT_SPEC 13 #define DEBUG_DISPLAY_TRIHASH 14 +#define DEBUG_DISPLAY_MATERIAL 15 // add more when needed struct UniformBuffer { diff --git a/ref/vk/vk_rtx.c b/ref/vk/vk_rtx.c index 625e9f49..9a7da66a 100644 --- a/ref/vk/vk_rtx.c +++ b/ref/vk/vk_rtx.c @@ -153,22 +153,23 @@ static void parseDebugDisplayValue( void ) { const char *cvalue = g_rtx.debug.rt_debug_display_only->string; #define LIST_DISPLAYS(X) \ - X(BASECOLOR) \ - X(BASEALPHA) \ - X(EMISSIVE) \ - X(NSHADE) \ - X(NGEOM) \ - X(LIGHTING) \ - X(SURFHASH) \ - X(TRIHASH) \ - X(DIRECT) \ - X(DIRECT_DIFF) \ - X(DIRECT_SPEC) \ - X(INDIRECT) \ - X(INDIRECT_DIFF) \ - X(INDIRECT_SPEC) \ + X(BASECOLOR, "material base_color value") \ + X(BASEALPHA, "material alpha value") \ + X(EMISSIVE, "emissive color") \ + X(NSHADE, "shading normal") \ + X(NGEOM, "geometry normal") \ + X(LIGHTING, "all lighting, direct and indirect, w/o base_color") \ + X(SURFHASH, "each surface has random color") \ + X(DIRECT, "direct lighting only, both diffuse and specular") \ + X(DIRECT_DIFF, "direct diffuse lighting only") \ + X(DIRECT_SPEC, "direct specular lighting only") \ + X(INDIRECT, "indirect lighting only (bounced), diffuse and specular together") \ + X(INDIRECT_DIFF, "indirect diffuse only") \ + X(INDIRECT_SPEC, "indirect specular only") \ + X(TRIHASH, "each triangle is drawn with random color") \ + X(MATERIAL, "red = roughness, green = metalness") \ -#define X(suffix) \ +#define X(suffix, info) \ if (0 == Q_stricmp(cvalue, #suffix)) { \ WARN("setting debug display to %s", "DEBUG_DISPLAY_"#suffix); \ g_rtx.debug.rt_debug_display_only_value = DEBUG_DISPLAY_##suffix; \ @@ -179,7 +180,7 @@ LIST_DISPLAYS(X) if (Q_strlen(cvalue) > 0) { gEngine.Con_Printf("Invalid rt_debug_display_only mode %s. Valid modes are:\n", cvalue); -#define X(suffix) gEngine.Con_Printf("\t%s\n", #suffix); +#define X(suffix, info) gEngine.Con_Printf("\t%s -- %s\n", #suffix, info); LIST_DISPLAYS(X) #undef X } @@ -760,7 +761,7 @@ qboolean VK_RayInit( void ) gEngine.Cmd_AddCommand("rt_debug_reload_pipelines", reloadPipeline, "Reload RT pipelines"); -#define X(name) #name ", " +#define X(name, info) #name ", " g_rtx.debug.rt_debug_display_only = gEngine.Cvar_Get("rt_debug_display_only", "", FCVAR_GLCONFIG, "Display only the specified channel (" LIST_DISPLAYS(X) "etc)"); #undef X