Commit graph

13730 commits

Author SHA1 Message Date
Bill Currie
d9c6db8865 [vulkan] Create a window for selected entities
Now the mouse-picking is starting to get useful. The window for an
entity shows its attached components (and their data if a function is
available).
2023-08-08 17:12:39 +09:00
Bill Currie
102a0d591b [ecs] Add a ui function pointer to components
This allows components to display themselves in the UI. Because the
component meta-data is copied into the registry, the function pointer
can be updated by systems (eg, the renderers) to display system-specific
interpretations of the component.
2023-08-08 17:02:53 +09:00
Bill Currie
44c1ef5968 [vulkan] Correct the size of cone splats
I really don't know what I was thinking when I wrote that code. Maybe I
was trying for a half angle. Now the rendered "cone" matches up with a
hard-clipped cone light (soft edges stick out a bit).
2023-08-08 16:00:24 +09:00
Bill Currie
c99a49a958 [vulkan] Save the current scene in the scene context
Now this I really don't know why I didn't do when I first created the
context.
2023-08-08 12:00:03 +09:00
Bill Currie
ff5d4d8de1 [vulkan] Move Vulkan_NewScene into vulkan_scene
It probably should have been there all along, and with this
vulkan_main/qf_main goes away.
2023-08-08 11:52:31 +09:00
Bill Currie
9ede227da4 [ui] Edge detect all mouse buttons
And return mouse button info in the io struct.
2023-08-07 22:20:34 +09:00
Bill Currie
1745d3bccc [vulkan] Implement mouse-picking for light entities
Currently, only light entities get drawn to the entid buffer, and the
ids are simply displayed in a window for now (not very useful yet).
2023-08-07 17:47:49 +09:00
Bill Currie
95b660d7fd [ui] Add a function to get current mouse position
And hot/active ids.
2023-08-07 17:42:59 +09:00
Bill Currie
35e2ffb4ab [console] Release the mouse when showing the mouse
This makes mouse grabbing much less painful.
2023-08-06 12:57:22 +09:00
Bill Currie
be5ab7b864 [renderer] Add a comment about the start map issue
I spent way too long tracking down the easy teleporter disappearing only
to realize it might be the watervised map. After moving it out of the
way and using id's maps, it works just fine.
2023-08-06 02:32:11 +09:00
Bill Currie
42ce1f1a86 [renderer] Fix a silly double set test
No wonder the final changes didn't make as much difference as I
expected.
2023-08-06 00:21:54 +09:00
Bill Currie
bf951c3ba2 [vulkan] Get debug light objects working again
And also get them working for infinite radius lights.
2023-08-06 00:20:25 +09:00
Bill Currie
452459297d [vulkan] Remove hard-coded shadow bias
It didn't really work all that well and isn't necessary with the
front-face culling. One less op per pixel.
2023-08-05 19:59:53 +09:00
Bill Currie
5a6d3ec3c9 [nq] Add a cvar to control player shadows
cl_player_shadows defaults to 1 thus giving a nice (for the resolution)
shadow of the player (and disables the weapon shadow).
2023-08-05 19:58:37 +09:00
Bill Currie
6892dc1422 [scene] Add flags for finer rendering control
This takes care of rockets and lava balls casting shadows when they
shouldn't (rockets more because the shadow doesn't look that nice, lava
balls because they glow and thus shouldn't cast shadows). Same for
flames, though the small torches lost their cool sconce shadows (need to
split up the model into flame and sconce parts and mark each
separately).
2023-08-05 18:09:20 +09:00
Bill Currie
1cc65179b5 [nq] Pass correct time to Light_DecayLights
The old R_DecayLights used r_data->realtime, which came from cl.time,
not realtime like I thought, thus causing dynamic lights to not decay
properly during a timedemo as realtime in the client is just that:
realtime.
2023-08-05 17:19:11 +09:00
Bill Currie
f436806006 [scene] Remove full_transform from renderer_t
I've wanted to do this for a long while, but I finally got the
motivation to clean up the two uses in gl and glsl. Removes 64 bytes
from the struct.
2023-08-05 15:56:01 +09:00
Bill Currie
f77ad8a676 [vulkan] Use front-face culling for shadow passes
This clears up the shadow acne, but does cause problems with lights
inside models. However, this can be fixed by setting the models to not
cast shadows.
2023-08-05 13:22:29 +09:00
Bill Currie
15d7222ebb [model] Remove Mod_LeafPVS in favor of mix/set
The use of a static set makes Mod_LeafPVS not thread safe and also means
that the set is not usable with the set iterators after going to a
smaller map from a larger map.
2023-08-05 11:51:01 +09:00
Bill Currie
7294a77356 [client] Put dynamic lights on separate entities
Dynamic lights can't go directly on visible entities as one or the other
will fail to be queued. In addition, the number of lights on an entity
needs to be limited. For now, one general purpose light for various
effects (eg, quad damage etc) and one for the muzzle flash.
2023-08-05 01:42:15 +09:00
Bill Currie
fb818d15d9 [scene] Support extra component systems
I've finally come across the need for "client" (hah) code to have
additional components on scene entities.
2023-08-05 01:35:09 +09:00
Bill Currie
0d4ffb02bc [vulkan] Avoid drawing too many dynamic lights
Trying to draw too many dynamic lights results in various crashes due to
the resources being preallocated.
2023-08-05 01:25:26 +09:00
Bill Currie
9328c90a74 [vulkan] Implement shadows for dynamic lights
This also fixes the segfault in the previous commit.

Dynamic light shadow sizes are fixed, but can be controlled via the
dynlight_size cvar (defaults to 250).
2023-08-04 15:44:07 +09:00
Bill Currie
35ec2ebb4c [scene] Move dynamic lights into the scene ECS
While the insertion of dlights into the BSP might wind up being overly
expensive, the automatic management of the component pool cleans up the
various loops in the renderers.

Unfortunately, (current bug) lights on entities cause the entity to
disappear due to how the entity queue system works, and the doubled
efrag chain causes crashes when changing maps, meaning lights should be
on their own entities, not additional components on entities with
visible models.

Also, the vulkan renderer segfaults on dlights (fix incoming, along with
shadows for dlights).
2023-08-04 15:08:56 +09:00
Bill Currie
7537cb8d1c [vulkan] Correct OIT sorting
The reversed depth buffer is very nice, but it also reversed the OIT
blending. Too much demo watching not enough walking around in the maps
(especially start near the episode 4 gate).
2023-08-04 14:51:49 +09:00
Bill Currie
6fe127dd0b [vulkan] Render all the requested lights
Starting at start and ending at count doesn't end as well as one might
like.
2023-08-03 22:12:33 +09:00
Bill Currie
e4ed868023 [vulkan] Simplify cubemap frame conversion
Don't need a whole matrix multiply when a swizzle and single vector
multiply will do.
2023-08-03 11:56:01 +09:00
Bill Currie
71934b15f4 [vulkan] Avoid alias depth hack in shadow pass
This protects the view model from incorrect self-shadowing.
2023-08-03 09:55:53 +09:00
Bill Currie
19a5cb562c [vulkan] Avoid bsp back-face cull in shadow pass
When rendering shadow maps, all the faces are needed, not just those
facing the pseudo-camera (due to the null-point of the shadow pass
view).
2023-08-03 09:22:54 +09:00
Bill Currie
2fbe44a72e [vulkan] Get point light shadows working
Other than the rather bad shadow acne, this is actually quake itself
working nicely. Still need to get directional lights working for
community maps, and all sorts of other little things (hide view model,
show player, fix brush backfaces, etc).
2023-08-03 00:15:42 +09:00
Bill Currie
1fe0f5ffd5 [vulkan] Get spotlight shadows working
They currently have a hard-coded bias of 0.5 pixels (if I'm doing my
math correctly) to combat the shadow acne, but look pretty good.
2023-08-02 19:34:37 +09:00
Bill Currie
a626dc7ca8 [vulkan] Split the lighting pass into per-type passes
This takes care of the type punning issue by each pass using the correct
sampler type with the correct view types bound. Also, point light and
spot light shadow maps are now guaranteed to be separated (it was just
luck that they were before) and spot light maps may be significantly
smaller as their cone angle is taken into account. Lighting is quite
borked, but at least the engine is running again.
2023-08-02 19:34:26 +09:00
Bill Currie
39bb433498 [vulkan] Add an undefined to shader-ro barrier
I guess it's kind of UB, but it's handy for images that will be
conditionally written by the GPU but need to be in shader-read-only for
draw calls and the validation layers can't tell that the layers won't be
used.
2023-08-02 17:51:04 +09:00
Bill Currie
00040c8900 [vulkan] Hook up all the shadow resources
This gets everything but the actual shadow map bindings working: the
validation layers don't like my type punning (which may well be the
right thing) and specialization constants don't help (yet, anyway) but I
want to get things into git.
2023-08-01 23:34:08 +09:00
Bill Currie
7487a00b36 [renderer] Return number of nearby dynamic lights
It allows for a minor optimization when allocating resources for those
lights.
2023-08-01 23:28:24 +09:00
Bill Currie
a50bc1c6ef [scene] Make light style unsigned
Not that it really matters for only 64 styles, but it feels more
consistent.
2023-08-01 23:26:26 +09:00
Bill Currie
2d7f671da8 [vulkan] Remove depth buffer from lighting pass
It's not needed and exceeds the minimum maximum input attachments.
2023-08-01 14:35:23 +09:00
Bill Currie
4ccd4ba3c7 [vulkan] Clean up some bitrot int the forward renderer
The recent changes for planes and shadows broke the forward renderer
pipeline spec.
2023-07-30 13:47:47 +09:00
Bill Currie
ffb113fa65 [vulkan] Fix some typos 2023-07-30 13:06:37 +09:00
Bill Currie
14c94711fd [vulkan] Compute correct matrices for spots and points
Directional lights don't get correct matrices yet as I need to study the
math involved for cascaded shadow maps (and id maps don't have
directional lights).

Getting spotlights working correctly was insanely frustrating: I just
couldn't get the entities into the view of the spotlight with any
sensible combination of inverses and the z_up matrix. It turned out it
was all due to an incorrect reference vector: it was +Z instead of +X.
2023-07-30 11:59:47 +09:00
Bill Currie
ff27da4a05 [vulkan] Use the shadow matrices when rendering maps
It turns out bsp faces are still back-face culled despite the null point
being on the front of every possible plane... or really, because it's on
the front of every possible plane: sometimes the back face is the front
face, and this breaks the face selection code (a separate traversal
function will be needed for non-culling rendering).

Despite that, other than having to deal with different pipelines,
getting the model renderers working went better than expected.
2023-07-30 11:52:13 +09:00
Bill Currie
aed1e7e077 [vulkan] Upload light matrices for shadow maps
This involved rewriting the descriptor update code too, but that now
feels cleaner.

The matrices are loaded into a storage buffer as it can get quite big at
6 matrices per light (and the current max lights is 768).
2023-07-30 11:35:07 +09:00
Bill Currie
aac6fca2c5 [vulkan] Pass a data parameter to QFV_RunRenderPass
The parameter will be passed on to the pipeline tasks in their task
context, allowing for communication between the subsystem calling
QFV_RunRenderPass and the pipeline tasks (for the case of lighting,
passing the current matrix base index).
2023-07-30 11:25:08 +09:00
Bill Currie
e83854a760 [vulkan] Make z_up and box_rotations public
They're now qfv_* and shared within the vulkan renderer. qfv_z_up cannot
be shared across renderers as they have their own ideas for the world
frame. qfv_box_rotations currently can't be shared across renderers
because if the Y-axis flip and the way it's handled, but sharing should
be achievable by modifying the other renderers to handle the sides
correctly (glsl and gl need to do lookups for the side enums, sw just
needs to be shown which way is up).
2023-07-30 11:13:48 +09:00
Bill Currie
931175b21d [vulkan] Run the shadow render passes
The shadow maps are rendered incorrectly because the matrices aren't set
correctly yet, but the dual-pass bsp rendering is working.
2023-07-29 01:17:53 +09:00
Bill Currie
3d4cca4393 [vulkan] Allow render passes to be run by processes
This lets the shadow step run its passes as needed.
2023-07-29 01:10:26 +09:00
Bill Currie
ad1b2d00d4 [nq,qw] Add a debug_debug cvar
Setting the cvar to > 0 causes demo playback to stop (via demo_speed 0)
when the read packet count reaches the specified value. Very useful for
debugging rendering glitches that are easily reproduced in a demo.
2023-07-28 19:19:13 +09:00
Bill Currie
fc946a604d [vulkan] Set default frames in flight to 2
Having 3 frames doesn't gain much of anything and costs 50% extra memory
as well as another frame of latency.
2023-07-27 16:16:33 +09:00
Bill Currie
3b0dcd2cdc [vulkan] Connect the shadow pass to the renderers
It's only partially complete, but R_VisitWorldNodes is now run for both
the main pass and the shadow auxiliary pass.
2023-07-27 16:09:33 +09:00
Bill Currie
123bf14784 [scene] Add a leaf component to lights
Regular leaf number for positional lights, 0 for directional, and ~0 for
ambient.
2023-07-27 15:50:53 +09:00