Commit graph

13640 commits

Author SHA1 Message Date
Bill Currie
558e11e9b7 [vulkan] Make near and far clip explicit parameters
This improves the projection API in that near clip is a parameter rather
than being taken directly from the cvar, and a far clip (ie, finite far
plane) version is available (necessary for cascaded shadow maps as it's
rather hard to fit a box to an infinite frustum).

Also, the orthographic projection matrix is now reversed as per the
perspective matrix (and the code tidied up a little), and a version that
takes min and max vectors is available.
2023-08-13 17:30:24 +09:00
Bill Currie
2b879af3e1 Fix most of the hacks for clang
gcc didn't like a couple of the changes (rightly so: one was actually
incorrect), and the fix for qfcc I didn't think to suggest while working
with Emily.

The general CFLAGS etc fixes mostly required just getting the order of
operations right: check for attributes after setting the warnings flags,
though those needed some care for gcc as it began warning about main
wanting the const attribute.

Fixing the imui link errors required moving the ui functions and setup
to vulkan_lighting.c, which is really the only place they're used.
2023-08-11 18:29:30 +09:00
Th3T3chn0G1t
3098b5d3f7 Implement clang support
Fixing a load of issues related to autoconf and some small source-level issues to re-add clang support.
autoconf feature detection probably needs some addressing - partially as -Werror is applied late.
2023-08-11 14:25:01 +09:00
Bill Currie
f21e1275b9 [nq] Fix a missing void params
Thanks to Emily for finding it.
2023-08-10 22:30:34 +09:00
Bill Currie
079e2c055a [vulkan] Add more light debug info
Lines are drawn for a light's leaf, the leafs visible to it, or those in
its efrags chain. Still no idea why lights are drawing when they
shouldn't. Deek suggest holes in the map, but I think if that was the
case, there'd be something visible. My suspicion is I'm doing something
wrong in with efrags.
2023-08-10 09:38:42 +09:00
Bill Currie
0bcfa961b3 [vulkan] Up the size of the bsp index buffers
With three independent passes, it's possible to use up to 3 times the
indices.
2023-08-10 09:37:07 +09:00
Bill Currie
481c12468e [vulkan] Show surfaces for selected light leaf
This has resulted in some rather interesting information: it seems the
surfaces (and thus, presumably bounding boxes) for leafs have little to
do with the actual leaf node's volume.
2023-08-09 02:01:47 +09:00
Bill Currie
5bc1924a25 [vulkan] Clean up some bsp pass name confusion
I had gotten stage and pass confused at some stage. Also, name the
passes in C (enum).
2023-08-08 19:23:30 +09:00
Bill Currie
a5fcc41d08 [vulkan] Rename bsp aux pass to shadow
Much better name.
2023-08-08 18:04:58 +09:00
Bill Currie
1319ed0e94 [scene] Implement simple UI functions for lights
Both dynamic lights and "static" lights display their values, but
currently no interaction.
2023-08-08 17:25:53 +09:00
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