Commit Graph

1797 Commits

Author SHA1 Message Date
Bill Currie 12776e487a [gl] Implement screen warping for liquids
It's not the most efficient code (uses sin() directly), but at least it
works (and with about 75% cpu headroom at 72fps on my machine).
2022-03-26 18:13:37 +09:00
Bill Currie a0adca011f [gl] Get fisheye working with frame buffers
Of course, it's not as correct as glsl or sw due to using polygons and
uvs rather than a fragment shader (not that such is out of the question
since GL 3.0 is requested, but I don't feel like getting shaders going
just for a couple of post-processing effects in an obsolete renderer).
2022-03-26 12:51:31 +09:00
Bill Currie aa41259008 [gl] Clean out the last of the mirror code
Stragglers...
2022-03-26 10:27:16 +09:00
Bill Currie 303756b41b [gl] Remove the envmap command
It has never worked, but it should be easy enough to implement for all
renderers since fisheye does the same thing.
2022-03-26 10:27:16 +09:00
Bill Currie f2bc5b560f [renderer] Clean up post processing
While it's not where I want it to be, it at least now no longer messes
with frame buffer binding or the view ports. This involved switching
around buffers in D_WarpScreen so that the main buffer could be bound
before post-processing.
2022-03-26 00:42:43 +09:00
Bill Currie 286344c7b6 [glsl] Implement fisheye rendering
The code dealing with state is a bit of a mess, but everything is
working nicely. Get around 400fps when all 6 faces need to be rendered
(no surprise: it should be about 1/6 of that for normal rendering). The
messy state handling code did not come as a surprise as I suspected
there were various mistakes in my scene rendering "recipe", and fisheye
highlighted them nicely (I'm sure getting this stuff working in Vulkan
will highlight even more issues).
2022-03-25 12:22:16 +09:00
Bill Currie 18aae8205e [glsl] Implement screen warp when in liquids
Finally, after a decade :P Looks pretty good, too, and is (almost)
properly scaled to the resolution (almost because the effect is a little
squashed, but I think the sw renderer does the same).
2022-03-25 09:01:27 +09:00
Bill Currie 20a2e7e06f [renderer] Get sw fisheye working again
Again, gl/vulkan not working yet (on the assumption that sw would be
trickier).

Fisheye overrides water warp because updating the projection map every
frame is far too expensive.

I've added a post-process pass to the interface in order to hide the
implementation details, but I'm not sure I'm happy about how the
multi-pass rendering for cube maps is handled (or having the frame
buffers as exposed as they are), but mainly because Vulkan will make
implementation interesting.
2022-03-24 15:50:41 +09:00
Bill Currie 0c437492b4 [renderer] Move to using dynamic frame buffers
For now, OpenGL and Vulkan renderers are broken as I focused on getting
the software renderer working (which was quite tricky to get right).

This fixes a couple of issues: the segfault when warping the screen (due
to the scene rendering move invalidating the warp buffer), and warp
always having 320x200 resolution. There's still the problem of the
effect being too subtle at high resolution, but that's just a matter of
updating the tables and tweaking the code in D_WarpScreen.

Another issue is the Draw functions should probably write directly to
the main frame buffer or even one passed in as a parameter. This would
remove the need for binding the main buffer at the beginning and end of
the frame.
2022-03-24 12:56:29 +09:00
Bill Currie 0f30f0a133 [mathlib] Remove suspicious IS_NAN
The implementation looks wrong (more like infinity). Where it was used
is currently disabled, but the usages were replaced with C99's isnan.
2022-03-19 12:50:08 +09:00
Bill Currie 65af7fb4a4 [mathlib] Remove frustum global
It should never have been there and is now in the refdef (not its final
home: it should probably be part of the camera).
2022-03-19 12:33:12 +09:00
Bill Currie b912c2a667 [renderer] Clean up R_SetFrustum
The only global it touches now is frustum, and that needs fixing in
mathlib (good grief, we (probably I) did some weird things when merging
the code).
2022-03-19 10:06:38 +09:00
Bill Currie c3f38e1c79 [renderer] Remove player_entity field
This was a hold-over from the gl mirror code.
2022-03-19 09:46:53 +09:00
Bill Currie ee51d06aa3 [renderer] Clean up a lot of recalc_refdef use
I think the widespread use of recalc_refdef (and force_fullscreen) was
the result of a rushed merge of the renderer and video code (I do seem
to remember sprinkling them around). This cleans the two out of the
client code.
2022-03-19 00:56:30 +09:00
Bill Currie 2b72506868 [renderer] Handle transparent surfaces
Other than the view model (undecided on the approach) this has
R_RenderView pretty much pulled out of the low level renderers. With
this, I'll be able to focus on scene handling for a bit then getting
shadows and fisheye working (again for fisheye).
2022-03-18 01:08:19 +09:00
Bill Currie c05476f94b [renderer] Move most of the scene rendering into r_screen
r_screen isn't really the right place, but it gets the scene rendering
out of the low-level renderers and will make it easier to sort out
later, and hopefully easier to figure out a good design for vulkan.
2022-03-17 17:57:50 +09:00
Bill Currie d8a4c8dbe9 [renderer] Clean up r_bsp a little
Move r_pcurrentvertbase into the sw renderer, cleaning up gl's use of
(not really needed there). Not ready to move r_bsp into the main bin yet
as there are linking issues since only the low-level code references any
of its symbols.
2022-03-17 13:09:20 +09:00
Bill Currie 91d7a80dff [renderer] Get timegraph and zgraph working
Only for sw and gl right now, but this sorts out the issues that
prevented the graphs working at all.
2022-03-15 15:42:43 +09:00
Bill Currie 5a57280aa9 [gl] Use glGenTextures to allocate texture numbers
While the scheme of using our own allocated did work just fine, fisheye
rendering uses glGenTextures which caused a texture id clash and thus
invalid operations (the cube map texture happened to be the same as the
console background texture). Sure, I could have just "fixed" the fisheye
init code, but this brings gl closer in line with glsl (which makes
extensive use of glGenTextures and glDeleteTextures). This doesn't fix
any texture leaks gl has (plenty, I imagine), but it's a step in the
right direction.
2022-03-15 13:29:05 +09:00
Bill Currie 7402fcfd0c [renderer] move r_worldentity and r_viewleaf into refdef
More cleanup of globals that seem to be quake specific.
2022-03-14 15:27:43 +09:00
Bill Currie 56c39c34ba [renderer] Remove namehack.h
Finally. I never liked it (felt bad adding it in the first place), and
it has caused confusion with function and global variable names, but it
did let me get the render plugins working.
2022-03-14 14:31:23 +09:00
Bill Currie bce7d5b832 [renderer] Clean up use of vup/vright/vpn
This moves the common camera setup code out of the individual drivers,
and completely removes vup/vright/vpn from the non-software renderers.
This has highlighted the craziness around AngleVectors with it putting
+X forward, -Y right and +Z up. The main issue with this is it requires
a 90 degree pre-rotation about the Z axis to get the camera pointing in
the right direction, and that's for the native sw renderer (vulkan needs
a 90 degree pre-rotation about X, and gl and glsl need to invert an
axis, too), though at least it's just a matrix swizzle and vector
negation. However, it does mean the camera matrices can't be used
directly.

Also rename vpn to vfwd (still abbreviated, but fwd is much clearer in
meaning (to me, at least) than pn (plane normal, I guess, but which
way?)).
2022-03-14 09:45:27 +09:00
Bill Currie 64666cfa5b [renderer] Clean up most uses of currententity
Just some brush model related code in the software renderer remaining.
2022-03-11 15:07:38 +09:00
Bill Currie 3414eb12a3 [renderer] Move r_ambient and r_drawflat to client code
It makes more sense for these cvars to be under client control via
r_refdef. Completely disabled in qw, and currently ignored in nq.
2022-03-09 22:51:21 +09:00
Bill Currie cfe0455cce [screen] Move some flags into screen.h
And remove r_screen.h. Fixes windows builds due to missing
scr_skipupdate.
2022-03-09 09:31:22 +09:00
Bill Currie 075a0fe326 [renderer] Clean up r_origin and modelorg
So far, in gl and glsl, but viewposition is much clearer than r_origin
(despite being the same thing), and modelorg is just confusing (I think
it's the view position relative to the current model).
2022-03-08 03:47:36 +09:00
Bill Currie 48c225da89 [renderer] Merge the fog support code
GL still has its own functions for enabling and disabling fog while
rendering, but GLSL doesn't need such (thanks to the shaders), nor will
vulkan (and the software renderers don't support fog).
2022-03-08 02:28:19 +09:00
Bill Currie af0c66dff9 [renderer] Move frame rendering out a layer.
This is a step towards high-level unification of the renderers, as far
as possible keeping only actual low-level implementation details in the
individual renderers (some higher level stuff, eg shadows, is expected
to be per-renderer as some things are just not feasible to implement in
all renderers). However, the idea is to move the high-level
functionality into scene rendering.
2022-03-08 01:04:40 +09:00
Bill Currie ea2fd32228 [renderer] Merge screenshot code as much as possible
Only CaptureBGR is per-renderer as the rest of the screenshot code uses
it to do the actual capture (which is target dependent). Vulkan is
currently broken due to capture being an asynchronous process and the
rest of the code expecting capture to be synchronous (also, bgr vs rgb).

The best thing is all renderers now write the same format (currently
png).
2022-03-07 15:04:54 +09:00
Bill Currie 2eae2e5d74 [renderer] Move some functions from plugins to main lib
One step in cleaning up vid_render_funcs.
2022-03-07 13:40:04 +09:00
Bill Currie 71c1b4e0c4 [gl] Clean up some triple buffer and multi-texture cvar mess
Excess declarations for gl_multitexture_f, and move gl_triplebuffer into
a callback.
2022-03-07 08:38:38 +09:00
Bill Currie 1ea3a3807e [renderer] Clean up a pile of dead screen declarations
The declarations were either unused, or the functions empty stubs for
all renderers.
2022-03-06 13:47:41 +09:00
Bill Currie 45c3c6d7be [screen] Clean up some dead declarations 2022-03-05 14:35:56 +09:00
Bill Currie d69355f521 [renderer] Support multiple entity queues
While there's currently only the one still, this will allow the entities
to be multiply queued for multi-pass rendering (eg, shadows). As the
avoidance of putting an entity in the same queue more than once relies
on the entity id, all entities now come from the scene (which is stored
in cl_world in the client code for nq and qw), thus the extensive
changes in the clients.
2022-03-05 02:05:39 +09:00
Bill Currie 6ec8e29429 [scene] Track hierarchies instead of root transforms
The root transform of each hierarchy can be extracted from the first
transform of the list in the hierarchy, so no information is lost. The
main reason for the change is I discovered (obvious in hindsight) that
deleting root transforms was O(n) due to keeping them in an array, thus
the use of a linked list (I don't expect a hierarchy to be in more than
one such list), and I didn't want the transforms to be in a linked list.
2022-03-04 06:43:30 +09:00
Bill Currie ae6970a005 [renderer] Split entity queue into per-model-type
While I doubt the difference is all that significant, this should speed
up entity rendering because it cuts out a lot of branching, and
eliminates scanning the same list multiple times only to not do anything
for large chunks of the list.
2022-03-02 15:00:32 +09:00
Bill Currie ab91d73635 [scene] Use scene resources for the main hierarchy block
This will reduce the memory churn when creating hierarchies as
transforms switch between being root and child.
2022-03-02 10:49:41 +09:00
Bill Currie 57dd4494cc [renderer] Pass in a camera transform
More r_data cleanup. Things could be better still, but this is a start.
2022-02-28 16:59:38 +09:00
Bill Currie 2477a44d15 [client] Move cshift info from viddef to viewstate
It makes much more sense for cshift state to be in viewstate because it
is very much an effect rather than anything specific to a renderer.
2022-02-28 16:55:12 +09:00
Bill Currie 5ad7c0fbd6 [scene] Add a camera object
It holds the data for a basic 3d camera (transform, fov, near and far
clip). Not used yet as there is much work to be done in cleaning up the
client code.
2022-02-25 10:41:50 +09:00
Bill Currie 2615953e17 [scene] Move transform getters into inline functions 2022-02-21 08:33:41 +09:00
Bill Currie cd26073b6a [vulkan] Update the sky matrix
Regardless of whether the sky is spinning or not, the matrix needs to be
updated with the current origin in order to get the direction vector
right in the shader. Also, it's in the update that the required x-y
plane rotation gets in so the skies move in the correct direction.
2022-02-18 13:29:41 +09:00
Bill Currie 4f436e8245 [scene] Correct a comment
While the plethora of orientations for a reference frame is somewhat
annoying, having an incorrect description of the frame is much more
annoying.
2022-02-15 06:46:01 +09:00
Bill Currie 54f0af854b [ruamoko] Wrap the transform fuctions
Except for get/set name as I'm still pondering strings.
2022-02-15 00:06:39 +09:00
Bill Currie ba3879c6e0 [scene] Make transforms owned by the scene
This actually has at least two benefits: the transform id is managed by
the scene and thus does not need separate management by the Ruamoko
wrapper functions, and better memory handling of the transform objects.
Another benefit that isn't realized yet is that this is a step towards
breaking the renderers free of quake and quakeworld: although the
clients don't actually use the scene yet, it will be a good place to
store the rendering information (functions to run, etc).
2022-02-14 20:01:36 +09:00
Bill Currie 59044d3827 Fix a bunch of distcheck issues 2022-02-14 19:28:19 +09:00
Bill Currie f6ac614e09 [scene] Add functions for scene and entity create/delete
Scene creation was already there, but now can be deleted, as can
entities.
2022-02-14 16:41:38 +09:00
Bill Currie 4d491a444d [gamecode] Fix handling of undefined builtins
The setup of the function descriptor for undefined builtins was
incomplete and led to the progs running code at address 0. It didn't end
well.
2022-02-14 14:28:19 +09:00
Bill Currie db8cf68ef3 [gamecode] Pass registered data pointer to builtins
This is the bulk of the work for recording the resource pointer with
with builtin data. I don't know how much of a difference it makes for
most things, but it's probably pretty big for qwaq-curses due to the
very high number of calls to the curses builtins.

Closes #26
2022-02-14 12:28:38 +09:00
Bill Currie 7c6ef06dfb [gamecode] Make PF_VarString v6p-only
It's not enforced a this stage, and it would be easy enough to handle,
but it turns out all the standard quake and quakeworld progs never used
... for the print functions: the behavior of PF_VarString was
undocumented and so... tough :P.
2022-02-06 21:20:00 +09:00