mirror of
https://github.com/w23/xash3d-fwgs
synced 2024-12-12 12:10:20 +01:00
vk: rt: enable white furnace via new rt_debug_flags
This commit is contained in:
parent
6d58ad8df0
commit
579b9e00ac
@ -193,7 +193,7 @@ void computeLighting(vec3 P, vec3 N, vec3 view_dir, MaterialProperties material,
|
||||
diffuse = specular = vec3(0.);
|
||||
|
||||
// No direct lighting for white furnace mode. The only light sources is no-hit|SURF_SKY bounce indirect light.
|
||||
if (ubo.ubo.debug_display_only == DEBUG_DISPLAY_WHITE_FURNACE) {
|
||||
if ((ubo.ubo.debug_flags & DEBUG_FLAG_WHITE_FURNACE) != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -187,9 +187,10 @@ struct LightCluster {
|
||||
#define DEBUG_DISPLAY_INDIRECT_SPEC 13
|
||||
#define DEBUG_DISPLAY_TRIHASH 14
|
||||
#define DEBUG_DISPLAY_MATERIAL 15
|
||||
#define DEBUG_DISPLAY_WHITE_FURNACE 16
|
||||
// add more when needed
|
||||
|
||||
#define DEBUG_FLAG_WHITE_FURNACE (1<<0)
|
||||
|
||||
struct UniformBuffer {
|
||||
mat4 inv_proj, inv_view;
|
||||
mat4 prev_inv_proj, prev_inv_view;
|
||||
@ -200,6 +201,7 @@ struct UniformBuffer {
|
||||
float skybox_exposure;
|
||||
|
||||
uint debug_display_only;
|
||||
uint debug_flags;
|
||||
};
|
||||
|
||||
#undef PAD
|
||||
|
@ -136,13 +136,15 @@ void primaryRayHit(rayQueryEXT rq, inout RayPayloadPrimary payload) {
|
||||
if (model.mode != MATERIAL_MODE_TRANSLUCENT)
|
||||
payload.base_color_a.a = 1.;
|
||||
|
||||
if (ubo.ubo.debug_display_only == DEBUG_DISPLAY_DISABLED) {
|
||||
// Nop
|
||||
} else if (ubo.ubo.debug_display_only == DEBUG_DISPLAY_WHITE_FURNACE) {
|
||||
if ((ubo.ubo.debug_flags & DEBUG_FLAG_WHITE_FURNACE) != 0) {
|
||||
// White furnace mode: everything is diffuse and white
|
||||
payload.base_color_a.rgb = vec3(1.);
|
||||
payload.emissive.rgb = vec3(0.);
|
||||
payload.material_rmxx.rg = vec2(1., 0.);
|
||||
}
|
||||
|
||||
if (ubo.ubo.debug_display_only == DEBUG_DISPLAY_DISABLED) {
|
||||
// Nop
|
||||
} else if (ubo.ubo.debug_display_only == DEBUG_DISPLAY_SURFHASH) {
|
||||
const uint hash = xxhash32(geom.kusok_index);
|
||||
payload.emissive.rgb = vec3(0xff & (hash>>16), 0xff & (hash>>8), 0xff & hash) / 255.;
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define SKYBOX_GLSL_INCLUDED
|
||||
|
||||
vec3 sampleSkybox(vec3 direction) {
|
||||
if (ubo.ubo.debug_display_only != DEBUG_DISPLAY_WHITE_FURNACE) {
|
||||
if ((ubo.ubo.debug_flags & DEBUG_FLAG_WHITE_FURNACE) == 0) {
|
||||
return texture(skybox, direction).rgb * ubo.ubo.skybox_exposure;
|
||||
} else {
|
||||
return vec3(1.);
|
||||
|
@ -86,6 +86,9 @@ static struct {
|
||||
cvar_t *rt_debug_display_only;
|
||||
uint32_t rt_debug_display_only_value;
|
||||
|
||||
cvar_t *rt_debug_flags;
|
||||
uint32_t rt_debug_flags_value;
|
||||
|
||||
cvar_t *rt_debug_fixed_random_seed;
|
||||
} debug;
|
||||
} g_rtx = {0};
|
||||
@ -168,7 +171,6 @@ static void parseDebugDisplayValue( void ) {
|
||||
X(INDIRECT_SPEC, "indirect specular only") \
|
||||
X(TRIHASH, "each triangle is drawn with random color") \
|
||||
X(MATERIAL, "red = roughness, green = metalness") \
|
||||
X(WHITE_FURNACE, "white furnace mode: diffuse white materials, diffuse sky light only") \
|
||||
|
||||
#define X(suffix, info) \
|
||||
if (0 == Q_stricmp(cvalue, #suffix)) { \
|
||||
@ -187,6 +189,35 @@ LIST_DISPLAYS(X)
|
||||
}
|
||||
|
||||
g_rtx.debug.rt_debug_display_only_value = DEBUG_DISPLAY_DISABLED;
|
||||
//#undef LIST_DISPLAYS
|
||||
}
|
||||
|
||||
static void parseDebugFlags( void ) {
|
||||
if (!(g_rtx.debug.rt_debug_flags->flags & FCVAR_CHANGED))
|
||||
return;
|
||||
|
||||
g_rtx.debug.rt_debug_flags->flags &= ~FCVAR_CHANGED;
|
||||
g_rtx.debug.rt_debug_flags_value = 0;
|
||||
|
||||
#define LIST_DEBUG_FLAGS(X) \
|
||||
X(WHITE_FURNACE, "white furnace mode: diffuse white materials, diffuse sky light only") \
|
||||
|
||||
const char *cvalue = g_rtx.debug.rt_debug_flags->string;
|
||||
#define X(suffix, info) \
|
||||
if (0 == Q_stricmp(cvalue, #suffix)) { \
|
||||
WARN("setting debug flags to %s", "DEBUG_FLAG_"#suffix); \
|
||||
g_rtx.debug.rt_debug_flags_value |= DEBUG_FLAG_##suffix; \
|
||||
} else
|
||||
LIST_DEBUG_FLAGS(X)
|
||||
#undef X
|
||||
/* else: no valid flags found */ {
|
||||
gEngine.Con_Printf("Invalid rt_debug_flags value %s. Valid flags are:\n", cvalue);
|
||||
#define X(suffix, info) gEngine.Con_Printf("\t%s -- %s\n", #suffix, info);
|
||||
LIST_DEBUG_FLAGS(X)
|
||||
#undef X
|
||||
}
|
||||
|
||||
//#undef LIST_DEBUG_FLAGS
|
||||
}
|
||||
|
||||
static uint32_t getRandomSeed( void ) {
|
||||
@ -227,6 +258,9 @@ static void prepareUniformBuffer( const vk_ray_frame_render_args_t *args, int fr
|
||||
ubo->debug_display_only = r_lightmap->value != 0 ? DEBUG_DISPLAY_LIGHTING : DEBUG_DISPLAY_DISABLED;
|
||||
}
|
||||
|
||||
parseDebugFlags();
|
||||
ubo->debug_flags = g_rtx.debug.rt_debug_flags_value;
|
||||
|
||||
ubo->random_seed = getRandomSeed();
|
||||
}
|
||||
|
||||
@ -765,6 +799,9 @@ qboolean VK_RayInit( void )
|
||||
#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)");
|
||||
|
||||
g_rtx.debug.rt_debug_flags = gEngine.Cvar_Get("rt_debug_flags", "", FCVAR_GLCONFIG,
|
||||
"Enable shader debug flags (" LIST_DEBUG_FLAGS(X) "etc)");
|
||||
#undef X
|
||||
|
||||
g_rtx.debug.rt_debug_fixed_random_seed = gEngine.Cvar_Get("rt_debug_fixed_random_seed", "", FCVAR_GLCONFIG,
|
||||
|
Loading…
Reference in New Issue
Block a user