Commit graph

345 commits

Author SHA1 Message Date
Ian Curtis 57ead6037d Better opengl resource allocation. Fixes going fullscreen and back. 2022-12-17 23:46:02 +00:00
Ian Curtis 153c510009 Fix uniform location. 2022-11-26 12:58:07 +00:00
Ian Curtis 5f30614c4c FIx shaders failing to build on apple h/w 2022-11-09 18:56:15 +00:00
Ian Curtis 40c8259130 Rewrite the whole project for GL4+. I figured if we removed the limitation of a legacy rendering API we could improve things a bit. With GL4+ we can do unsigned integer math in the shaders. This allows us to upload a direct copy of the real3d texture sheet, and texture directly from this memory given the x/y pos and type. This massively simplifies the binding and invalidation code. Also the crazy corner cases will work because it essentially works the same way as the original hardware.
The standard triangle render requires gl 4.1 core, so should work on mac. The quad renderer runs on 4.5 core. The legacy renderer should still work, and when enabled a regular opengl context will be created, which allows functions marked depreciated in the core profiles to still work. This will only work in windows/linux I think. Apple doesn't support this.

A GL 4.1 GPU is now the min required spec. Sorry if you have an OLDER gpu. GL 4.1 is over 12 years old now.

This is a big update so I apologise in advance if I accidently broke something :]
2022-11-07 21:33:01 +00:00
Ian Curtis b2e5a200da Fix build for linux (just missing header) 2022-10-17 09:34:11 +01:00
Ian Curtis f0872cc998 Upgrade the glsl shader class a bit. Add a const char* comparitor so we can use a map with a simple "string" key. Fine to use when performance is not critical. 2022-10-16 21:03:41 +01:00
Ian Curtis 6fbf938335 Add a proper git ignore file .. And fix the legacy renderer to build with new visual studio (2019) 2022-10-16 20:45:40 +01:00
toxieainc e644751f01 after clarifications, minor cleanup 2022-10-10 16:35:02 -07:00
toxieainc 75771b3d14 remove 2 dupe function calls, where ProcessLos should actually be rather costly 2022-10-10 16:35:02 -07:00
Fernando Casas Schössow 412e9232d7 Fix new 3D engine texture2DLod function missing error on Linux/MESA. MESA requires needed extensions to be explicitly declared in code otherwise it will not enable them. 2022-10-10 16:30:09 -07:00
toxieainc aae58edd62 change one more place with potential aliasing issue 2022-10-03 17:59:59 -07:00
toxieainc 5f97e5af6c address review 2022-10-03 17:59:59 -07:00
toxieainc 519d695f57 address review and move bit casts to new header 2022-10-03 17:59:59 -07:00
toxieainc 1b0e3be8dc use correct slash 2022-10-03 17:59:59 -07:00
toxieainc 22ffb5cc19 Harmless math warning fixes. map->unordered_map in CNew3D::CacheModel. Avoid general aliasing problems (using bit_cast or the recommended/optimized-away memcpy). 2022-10-03 17:59:59 -07:00
toxieainc d7041a83c9 fix missing version GLSL compiler warnings on startup
happens (at least) on Intel drivers
2022-08-19 08:41:22 -07:00
toxieainc 6c24bf7c8f Optimize quad rendering by replacing the double computations for the area computation with the equivalent shoelace algorithm along with kahans algorithm to compute the cross products. In addition pull out the /w to the end, which increases precision even more.
Thus making the result similar to the fp64 version, tested e.g. with harleys first person mode (all artifacts still gone as before).

Improves perf on low end boards (e.g. Intel) dramatically (10fps with harley before, now 70 on my laptop), and even on higher end (e.g. NVIDIA laptop, quads are now faster than tri pipeline on my laptop).
2022-08-16 21:34:31 -07:00
toxieainc 27e071dafb add comment 2022-07-18 21:43:13 +02:00
toxieainc abb1273aa0 slightly optimize DrawTileLine (less branches/logic) 2022-07-11 18:49:02 +02:00
toxieainc b2b8396947 missed 2 changed files with last commit 2022-07-11 18:27:44 +02:00
toxieainc 4961951a89 fix a real error (m68kdasm) and some harmless performance warnings and use modern headers 2022-07-11 18:10:41 +02:00
toxieainc e0053b3a46 fix some real errors (Model3,InputSystem), minor errors (SCSP,SDL/Main) and some performance warnings 2022-07-11 17:43:59 +02:00
Ian Curtis 83e7b5f45d njz3: Proper quadrophonic audio support. Need 4+ speakers to take advantage otherwise down mixed to stereo. 2022-06-09 21:10:39 +00:00
Ian Curtis 0ef90899e1 Double buffer the line of sight values. Should allow the correct values to be returned if GPU threading is enabled. 2022-01-02 12:48:09 +00:00
Matthew Daniels 9ffce8b92a Getting rid of most of the includes from Supermodel.h; each file now explicitly includes the header files it needs.
Making changes to a header file should no longer force the entire project to recompile.
2021-11-22 17:15:06 +00:00
Ian Curtis e3374256ff Just a few compile warnings 2021-02-20 22:19:16 +00:00
Ian Curtis 72c0c60c98 -wide-bg option to stretch the background tile layer when wide-screen mode is enabled - Daro Land 2020-12-20 18:17:34 +00:00
Ian Curtis 75f8ee61a3 fix missing polys with quad renderer 2020-09-14 20:01:52 +00:00
Ian Curtis 38c3ff61f9 Clip scroll fog to viewport, instead of filling entire screen. Fixes fog bug in Daytona credits. 2020-09-08 09:10:24 +00:00
Ian Curtis aaa26f678c Update scroll fog logic. Should fix the credits in virtua fighter and daytona that have fogging applied to the background layer and shouldn't. 2020-09-07 16:25:18 +00:00
Ian Curtis d77433b525 Remove some debug code 2020-08-01 09:02:04 +00:00
Ian Curtis ba917aca6d Update glew version 2020-07-31 19:18:51 +00:00
Ian Curtis 6f6c98c671 The translator map seems to work with paletted colour values too, and the result is not clamped. Colours are passed to the GPU as unsigned bytes to multiplying by 16 will overflow, so we do the logic in the shader. If we passed floats we could skip the shader logic. 2020-05-11 09:05:46 +00:00
Ian Curtis e2ad593e88 When the translator map is enabled the colour values seem to use 4 bits, 0-16. Why not 0-31 I don't know. Anyway virtua on is overflowing these values for some of the smoke effects. For us the numbers were wrapping around. Clamping is enough to fix this. (Thanks model123) 2020-05-07 19:34:22 +00:00
Ian Curtis 5ace960f14 tweak value so the map indicator still works at the start of spikeout 2020-01-04 18:15:30 +00:00
Ian Curtis 6b8a29105a Sutherland-Hodgeman clipping only works for planar primitives. Scud is rendering non planar quads and this breaks our algorithm a little when using the quad renderer. Stretching the near plane a few % is enough to fix it. 2020-01-04 13:48:14 +00:00
Ian Curtis d711afade1 Only need to clip against 4 planes for poly culling 2020-01-04 13:45:55 +00:00
Ian Curtis 605dad2c02 Fix the sky in harley in first person mode where pixels in the sky are culled when they shouldn't be with the quad renderer. Basically we were running out of precision in a rare corner case. Doing the maths with double precision and casting back to float was enough to fix the issue. 2019-12-27 21:36:46 +00:00
Ian Curtis a5858e635d To calculate the mipmap value the opengl needs to calculate the difference in the texture coordinates between adjacent pixels. If there are no adjacent pixels the hw may need to spawn invisible fragments outside of the visible polygon. Our algorithm was culling these out so the mipamp calculation failed for edge pixels. Anyway this fixes quad rendering looking broken with the latest nvidia drivers. 2019-12-10 11:40:39 +00:00
Ian Curtis 06688de5fc Really should cull against 5 frustum planes. 2019-11-15 20:00:25 +00:00
Ian Curtis 06b43c45b3 Ocean hunter in the middle of the game is passing a few matrices with FLT_MAX inside them, which blows apart our near/far calculation. The hardware must have some method to sanitize the near/far for instance if you render something extremely close to the origin you will also blow apart any near/far calc. 2019-11-02 20:11:48 +00:00
Ian Curtis 714f6a123a skip invalid culling nodes 2019-07-28 12:14:13 +00:00
Ian Curtis 17f4103123 A culling node must follow immediately after a viewport. 2019-07-26 16:39:58 +00:00
Ian Curtis f634d19fdc Fix shader. Why this worked on my nvidia card .. I'm not sure. 2019-01-24 19:11:26 +00:00
Ian Curtis 8094c2e2b7 Composite the alpha layers at the end of rendering. To do this we need to mask the alpha pixels with the opaque pixels from the next priority layer. Fixes some overlapping shadows in vf3tb that have different priority layers. I assume that was a game bug, but it works on the real h/w. 2019-01-21 14:30:42 +00:00
Ian Curtis 864bb36b5a Technically backface culling should cull polys when the dot product = 0, since when it equals 0 the polys is perpendicular to the camera and thus invisible. When you complete sega rally2 (if you can get that far lol) the champagne is invisible. The reason is because all the face normals are 0. So when multiplied by the model matrix they are still 0 and get culled. Tweaking the condition to only cull polys when greater than 0 fixes this, and allows these 'bad' polys to render as they do on the model3. 2019-01-16 01:07:56 +00:00
Ian Curtis 08eeb20033 clear scissored out areas 2018-12-08 19:55:26 +00:00
Ian Curtis 6075352868 Optimise depth calculation for quad shader. 2018-11-27 20:43:27 +00:00
Ian Curtis 538a714086 Fade out microtextures with higher textures LODs. Fixes incorrectly applied microtextures in LA machineguns. 2018-10-23 00:16:23 +00:00
Ian Curtis bf4d725970 Smooth texture repeat makes no sense for alpha/contour textures with pixel dilate. HW seems to treat them as non smooth anyway. Also implement some line of sight stuff, used by Scud. Really need to check the threading/synchronisation of the register reads but it basically works. 2018-10-19 20:59:46 +00:00