diff --git a/ref/vk/TODO.md b/ref/vk/TODO.md index 52bd6b56..326aa255 100644 --- a/ref/vk/TODO.md +++ b/ref/vk/TODO.md @@ -1,6 +1,7 @@ # 2023-11-03 E324 - [x] add cvar for displaying only specified channel -- [ ] r_lightmap +- [x] r_lightmap +- [x] hightlight all surfaces with random colors - [ ] massage shaders: consolidate all bindings explicitly - [ ] skip sorting-by-texture when loading brush models ~~(=> geometry count explosion; i.e. kusochki count will explode too)~~ - [ ] kusochki-vs-materials structures diff --git a/ref/vk/shaders/ray_interop.h b/ref/vk/shaders/ray_interop.h index 4bfa2b9e..431a4fee 100644 --- a/ref/vk/shaders/ray_interop.h +++ b/ref/vk/shaders/ray_interop.h @@ -175,6 +175,7 @@ struct PushConstants { #define DEBUG_DISPLAY_NSHADE 4 #define DEBUG_DISPLAY_NGEOM 5 #define DEBUG_DISPLAY_LIGHTING 6 +#define DEBUG_DISPLAY_SURFHASH 7 // add more when needed struct UniformBuffer { diff --git a/ref/vk/shaders/ray_primary_hit.glsl b/ref/vk/shaders/ray_primary_hit.glsl index 0f6359d3..f0bc5f3e 100644 --- a/ref/vk/shaders/ray_primary_hit.glsl +++ b/ref/vk/shaders/ray_primary_hit.glsl @@ -8,6 +8,8 @@ #include "rt_geometry.glsl" #include "color_spaces.glsl" +#include "noise.glsl" // for DEBUG_DISPLAY_SURFHASH + layout(set = 0, binding = 6) uniform sampler2D textures[MAX_TEXTURES]; layout(set = 0, binding = 2) uniform UBO { UniformBuffer ubo; } ubo; layout(set = 0, binding = 7) uniform samplerCube skybox; @@ -103,6 +105,11 @@ void primaryRayHit(rayQueryEXT rq, inout RayPayloadPrimary payload) { payload.base_color_a *= color; payload.emissive.rgb *= color.rgb; + + 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.; + } } #endif // ifndef RAY_PRIMARY_HIT_GLSL_INCLUDED diff --git a/ref/vk/vk_rtx.c b/ref/vk/vk_rtx.c index 3d402fb1..00f83bb2 100644 --- a/ref/vk/vk_rtx.c +++ b/ref/vk/vk_rtx.c @@ -163,6 +163,7 @@ static void parseDebugDisplayValue( void ) { X(EMISSIVE) \ X(NSHADE) \ X(NGEOM) \ + X(SURFHASH) \ #define X(suffix) \ if (0 == Q_stricmp(cvalue, #suffix)) { \