mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-24 20:51:35 +00:00
[vulkan] Use OIT to visualize the light hulls
Using the translucency pass made it easy to have depth-tested translucent "solid" light volumes instead of always visible lines (which are still an option as that's useful too). Most importantly, being able to see the surfaces helped no end in figuring out that my hulls were created with counter-clockwise windings instead of quake's usual clockwise windings and thus my hulls were being rendered inside-out in the occlusion pass.
This commit is contained in:
parent
187c48bde3
commit
8890e14208
5 changed files with 58 additions and 1 deletions
|
@ -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) \
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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) },
|
||||
|
|
16
libs/video/renderer/vulkan/shader/light_oit.frag
Normal file
16
libs/video/renderer/vulkan/shader/light_oit.frag
Normal file
|
@ -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);
|
||||
}
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue