diff --git a/libs/video/renderer/Makemodule.am b/libs/video/renderer/Makemodule.am index 2ec72a9f0..3292e794a 100644 --- a/libs/video/renderer/Makemodule.am +++ b/libs/video/renderer/Makemodule.am @@ -349,6 +349,8 @@ light_splatf_src = $(vkshaderpath)/light_splat.frag light_splatf_c = $(vkshaderpath)/light_splat.frag.spvc light_debug_src = $(vkshaderpath)/light_debug.frag light_debug_c = $(vkshaderpath)/light_debug.frag.spvc +light_oit_src = $(vkshaderpath)/light_oit.frag +light_oit_c = $(vkshaderpath)/light_oit.frag.spvc lighting_cascadef_src = $(vkshaderpath)/lighting_cascade.frag lighting_cascadef_c = $(vkshaderpath)/lighting_cascade.frag.spvc lighting_cubef_src = $(vkshaderpath)/lighting_cube.frag @@ -459,6 +461,8 @@ $(light_splatf_c): $(light_splatf_src) $(lighting_h) $(light_debug_c): $(light_debug_src) $(lighting_h) +$(light_oit_c): $(light_oit_src) $(lighting_h) + $(lighting_nonef_c): $(lighting_nonef_src) $(lighting_h) $(lighting_main) $(lighting_cascadef_c): $(lighting_cascadef_src) $(lighting_h) $(lighting_main) @@ -534,6 +538,7 @@ vkshader_c = \ $(light_splatv_c) \ $(light_splatf_c) \ $(light_debug_c) \ + $(light_oit_c) \ $(lighting_cascadef_c) \ $(lighting_cubef_c) \ $(lighting_nonef_c) \ @@ -630,6 +635,7 @@ EXTRA_DIST += \ $(light_splatv_src) \ $(light_splatf_src) \ $(light_debug_src) \ + $(light_oit_src) \ $(lighting_cascadef_src) \ $(lighting_cubef_src) \ $(lighting_main) \ diff --git a/libs/video/renderer/vulkan/rp_main_def.plist b/libs/video/renderer/vulkan/rp_main_def.plist index 11579b552..848728da3 100644 --- a/libs/video/renderer/vulkan/rp_main_def.plist +++ b/libs/video/renderer/vulkan/rp_main_def.plist @@ -666,6 +666,11 @@ properties = { name = main; module = $builtin/light_debug.frag; }; + debug_oit = { + stage = fragment; + name = main; + module = $builtin/light_oit.frag; + }; }; vertexInput_splat = { bindings = ( @@ -694,6 +699,9 @@ properties = { splat_layout = { descriptorSets = (matrix_set, lighting_lights); }; + splat_oit_layout = { + descriptorSets = (matrix_set, lighting_lights, oit_set); + }; layout = { descriptorSets = (shadowmat_set, lighting_lights, lighting_attach, lighting_shadow); @@ -1656,6 +1664,27 @@ renderpasses = { inputAssembly = $particle.inputAssembly; layout = $particle.layout.draw; }; + debug_lights = { + @inherit = $compose_base; + disabled = true; + + color = $color.lights; + tasks = ( + { func = lighting_bind_descriptors; + params = (hull, plane); }, + { func = lighting_draw_splats; }, + ); + + stages = ( + $lighting.shader.vertex_splat, + $lighting.shader.debug_oit, + ); + vertexInput = $lighting.vertexInput_splat; + inputAssembly = $lighting.inputAssembly; + layout = $lighting.splat_oit_layout; + rasterization = $counter_cw_cull_back; + depthStencil = $depth_test_only; + }; }; }; gbuffer = { diff --git a/libs/video/renderer/vulkan/shader.c b/libs/video/renderer/vulkan/shader.c index b24b51ad8..d4674db48 100644 --- a/libs/video/renderer/vulkan/shader.c +++ b/libs/video/renderer/vulkan/shader.c @@ -103,6 +103,8 @@ static static #include "libs/video/renderer/vulkan/shader/light_debug.frag.spvc" static +#include "libs/video/renderer/vulkan/shader/light_oit.frag.spvc" +static #include "libs/video/renderer/vulkan/shader/lighting_cascade.frag.spvc" static #include "libs/video/renderer/vulkan/shader/lighting_cube.frag.spvc" @@ -184,6 +186,7 @@ static shaderdata_t builtin_shaders[] = { { "light_splat.vert", light_splat_vert, sizeof (light_splat_vert) }, { "light_splat.frag", light_splat_frag, sizeof (light_splat_frag) }, { "light_debug.frag", light_debug_frag, sizeof (light_debug_frag) }, + { "light_oit.frag", light_oit_frag, sizeof (light_oit_frag) }, { "lighting_cascade.frag", lighting_cascade_frag, sizeof (lighting_cascade_frag) }, { "lighting_cube.frag", lighting_cube_frag, sizeof (lighting_cube_frag) }, diff --git a/libs/video/renderer/vulkan/shader/light_oit.frag b/libs/video/renderer/vulkan/shader/light_oit.frag new file mode 100644 index 000000000..836a8b3d0 --- /dev/null +++ b/libs/video/renderer/vulkan/shader/light_oit.frag @@ -0,0 +1,16 @@ +#version 450 +#extension GL_GOOGLE_include_directive : enable +#extension GL_EXT_multiview : enable + +#include "oit_store.finc" + +layout (location = 0) flat in uint light_index; + +layout(early_fragment_tests) in; + +void +main (void) +{ + vec4 c = !gl_FrontFacing ? vec4 (1, 0, 1, 0.05) : vec4 (0, 1, 1, 0.05); + StoreFrag (c, gl_FragCoord.z); +} diff --git a/libs/video/renderer/vulkan/vulkan_lighting.c b/libs/video/renderer/vulkan/vulkan_lighting.c index cc50cc4fb..b9469bbba 100644 --- a/libs/video/renderer/vulkan/vulkan_lighting.c +++ b/libs/video/renderer/vulkan/vulkan_lighting.c @@ -60,6 +60,7 @@ #include "QF/Vulkan/qf_lighting.h" #include "QF/Vulkan/qf_matrices.h" #include "QF/Vulkan/qf_texture.h" +#include "QF/Vulkan/qf_translucent.h" #include "QF/Vulkan/barrier.h" #include "QF/Vulkan/buffer.h" #include "QF/Vulkan/debug.h" @@ -979,12 +980,14 @@ lighting_bind_descriptors (const exprval_t **params, exprval_t *result, auto stage = *(int *) params[1]->value; if (stage == lighting_hull) { + bool planes = shadow_type == ST_PLANE; VkDescriptorSet sets[] = { Vulkan_Matrix_Descriptors (ctx, ctx->curFrame), lframe->lights_set, + planes ? Vulkan_Translucent_Descriptors (ctx, ctx->curFrame) : 0, }; dfunc->vkCmdBindDescriptorSets (cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, - layout, 0, 2, sets, 0, 0); + layout, 0, 2 + planes, sets, 0, 0); VkBuffer buffers[] = { lframe->id_buffer,