326 Commits

Author SHA1 Message Date
IntegratedQuantum
0008d7f1fa Test how well a sparse 3d texture would work for storing and interpolating light data. 2023-11-20 13:03:28 +01:00
IntegratedQuantum
0adfbbc79e We don't need 64 bits for timer queries.
32 bits is enough as long as the time is less than 4 seconds, and 64 bit isn't supported everywhere.
2023-11-20 10:38:24 +01:00
IntegratedQuantum
80a6a53170 Don't crash on thread renaming errors.
These happen sometimes, like name too long and on mac you can only rename a thread from within.
And since the thread name is really only used for debugging, there is no need to crash the game in that case.
2023-11-19 22:49:31 +01:00
IntegratedQuantum
35b436f26c Don't use tabs in comments. 2023-11-19 19:39:58 +01:00
IntegratedQuantum
55034b769e Return to the game when pressing escape while the mouse isn't grabbed.
This seems to be more intuitive than clicking on the background.
Fixes #179
2023-11-17 20:12:57 +01:00
IntegratedQuantum
e1c5a30a0d Only do the infinite GPU loop detection on Linux, as it generates false positives on Windows.
Fixes #178
2023-11-17 11:57:25 +01:00
IntegratedQuantum
df075aa7df Prevent signed integer modulo in the animation frame calculation.
fixes #176
This created negative values when the time was negative, resulting in wrong animation frames.
2023-11-17 11:39:37 +01:00
IntegratedQuantum
7a640132ff Set the timout for poll on windows to zero to prevent blocking the render and other threads.
Why does windows always have to make things complicated?

Fixes #154
2023-11-16 23:46:43 +01:00
IntegratedQuantum
d348946939 Explicitly disable multisampling.
Fixes #177
2023-11-16 22:49:57 +01:00
IntegratedQuantum
4d25e9820b Don't generate framebuffers with size 0.
Should fix #142
2023-11-16 22:04:02 +01:00
IntegratedQuantum
bcf5ecf3c8 Base the larger gpu buffer off of one specific type.
This improves alignment, so memcpy should be slightly faster.
Additionally this simplifies the code that uses this buffer.
And only allowing one type prevents future accidents from mixed alignment.
Now it also supports buffers that are (slightly) bigger than the i32 integer limit.
2023-11-16 18:20:50 +01:00
IntegratedQuantum
919d7d5a9d Dynamically resize the GPU buffer if needed.
It does create some lag, but that should only happen once.
Maybe in the future I should investigate some alternatives to the copying.
2023-11-16 17:49:45 +01:00
IntegratedQuantum
6fd5c4d896 Use a persistent buffer for the large chunk mesh buffer.
This is should be faster than glBufferSubData, since I know better what to synchronize than the driver.
Additionally on some drivers this should avoid stalls, fixing #137
2023-11-15 21:44:08 +01:00
IntegratedQuantum
d6ab3d587b Use glBufferStorage to tell the driver that certain buffers are only uploaded once and never changed.
Should fix #144
2023-11-15 17:42:07 +01:00
IntegratedQuantum
bfb6466f7e Improve OpenGL debug output and print it in release as well. 2023-11-14 22:11:38 +01:00
IntegratedQuantum
2b30454042 Fix italic text
fixes #147
2023-11-14 19:40:29 +01:00
IntegratedQuantum
f6c2d17940 Make the parallax raymarching more efficient, by limiting the step-width to 1 and using some optimizations.
Also make the gpu code more resilient against infinite loops, allowing the removal of the iteration count.
2023-11-13 20:02:39 +01:00
IntegratedQuantum
fd776fa83f Remove the LODFactor setting.
This was useful in the java version, since there the LOD chunks were faster to render due to having no light/transparency.
Since this is not true anymore and since the settings created a lot of confusion for players(and myself), I decided to remove it.
Fixes #166
The proposed solution in #166 top use a seperate slider for the max lod distance doesn't make much sense either since changing only the lod0 render distance separately wouldn't actually improve performance significantly. It's better to switch to different LOD byond that.
2023-11-12 21:45:35 +01:00
IntegratedQuantum
fe9c001fd8 Simplify some code using vector operations. 2023-11-10 20:25:07 +01:00
IntegratedQuantum
b8b30363d7 Transpose all matrices.
This just makes more sense. And matrix-vector multiplication should also be faster.
2023-11-10 19:38:40 +01:00
IntegratedQuantum
19e3353be8 Fix item textures.
Fixes #167
2023-11-09 22:22:06 +01:00
IntegratedQuantum
e7823fe805 Improve data access patterns when getting the light values for a face.
Still not optimal. Debug performance is pretty bad.
2023-11-08 17:36:20 +01:00
IntegratedQuantum
026e855eaa Merge the functionality of the bloom upscale shader into the final post processing shader.
Increases performance by ~300 µs per frame.
Fixes #97
2023-11-08 11:19:33 +01:00
IntegratedQuantum
0152b1363a Delay mesh updated on neighbor removal.
Fixes #165
Also introducing reference counting for chunk meshes, with delayed freeing(at the end of the frame)
2023-11-07 21:06:58 +01:00
IntegratedQuantum
5db903020a Don't reset the visibilityMask for every mesh, instead it's only reset for the meshes that get rendered.
This improved frame time by some 300 µs at default render distance.
2023-11-06 16:06:25 +01:00
IntegratedQuantum
fc70d99323 Prepare the meshing and shaders for light rendering, currently demonstrating just ambient occlusion.
Starts work on #61
2023-11-05 22:52:49 +01:00
IntegratedQuantum
123b2755c3 Remove the white spot from the stone texture. 2023-11-05 22:15:47 +01:00
IntegratedQuantum
d0512f8586 Update zig 2023-11-03 16:56:42 +01:00
IntegratedQuantum
ed196c70e5 Sort biomes by their id to avoid indeterminism from wrong ordering.
Fixes part of #158. There still seem to be some problems left.
2023-11-03 15:57:54 +01:00
IntegratedQuantum
aef0740aa3 Handle the case that a biome has no music(empty string).
Fixes #159
2023-11-03 15:38:53 +01:00
IntegratedQuantum
d7f0796abd Fix lag spikes when moving after all the terrain has loaded.
The solution was simply to cache the side data of chunk meshes instead of regenerating all sides on update.
This probably makes first-time loading a bit slower due to requiring making more copies of the mesh data, but it's not a big deal.

Fixes the remaining half of #94.
2023-11-03 14:25:30 +01:00
IntegratedQuantum
94e4fc5269 Speed up the function that checks which chunks need to be added or removed from the RenderStructure.
Now it only checks the surface chunks, meaning it's now O(r²) instead of O(r³), where r is the render distance. There might be an even better way, but I don't see it yet.

Sadly the performance stays constant due to updating the visibilityMask each frame. But if I find a better solution for it then there should be some great improvements here.
2023-10-29 20:48:21 +01:00
IntegratedQuantum
9e45e0e662 Remove some dead code and leftover things from my last commit.
Now there is only one mutex left inside the process for updating and rendering chunks on the client-side.
This is a bit of a step back here. A lot of processes are now locked to the render thread.
Once I implemented lighing #61 I will need to look for better options.
2023-10-28 17:10:55 +02:00
IntegratedQuantum
021f762c01 Remove locking from the mesh loading code.
This makes it easier to work with.
2023-10-27 16:15:03 +02:00
IntegratedQuantum
49179d0891 Fix #151
It seems that this was caused by setting the `pos` to undefined, but all my code assumed that it was `.{0, 0}`.
2023-10-25 11:40:51 +02:00
IntegratedQuantum
420f727683 Fix some data races found by the thread sanitizer. 2023-10-25 11:14:24 +02:00
Samuel Meenzen
8aaa9f585c
Add run_release script (#152)
* Add run_release script

* Update README to use the run_release scripts
2023-10-24 15:43:17 +02:00
IntegratedQuantum
d2a6fc3c42
Use the GPL-3 LICENSE 2023-10-23 23:23:02 +02:00
IntegratedQuantum
78b3fa0d10 Fix the ValueNoise number distribution. It is now symmetrical.
Working towards #91
2023-10-23 23:18:16 +02:00
IntegratedQuantum
e398824cab Refactoring: Use const instead of var where possible.
When I started to use zig, I mostly used `var`. But over time I adapted to using `const` where possible which is more readable and the compiler is currently optimizing it better.
2023-10-22 21:12:45 +02:00
IntegratedQuantum
c2a955f86c Scale textures and models in LOD terrain to match their true scale.
This also adds some support for rendering larger volumes of voxel models at once. That might allow greeding meshing for voxel models.
Fixes #146
2023-10-22 19:34:03 +02:00
IntegratedQuantum
9978fd2025 Move all the C files to a seperate repo. Also use precompiled binaries to reduce first-time compile-time.
Resolves #110
Resolves #117 (I did however decide to use static linking, I had some issues with dynamic linking)
Also getting closer to #118

Additionally this avoids the problem caused by https://github.com/ziglang/zig/issues/17652 since harfbuzz is precompiled.
2023-10-21 15:00:16 +02:00
IntegratedQuantum
0c2d309f2a Ditch mach-freetype: now building freetype and harfbuzz directly.
Having zig bindings was certainly nice to have, but overall the code isn't too different really.
One nice advantage of building freetype and harfbuzz directly is that we can get rid of some unnecessary dependencies, like brotli.
Also, since that was the only zig dependency outside the standard library, this finally gives me the freedom to update zig whenever I want.
This is a necessary step for #117.

Resolves #139
2023-10-21 10:35:39 +02:00
IntegratedQuantum
2f6d2ada2c Prevent near-plane clipping using GL_DEPTH_CLAMP
Fixes #65
2023-10-20 10:12:55 +02:00
IntegratedQuantum
6619d98e6e Some refactoring using some better suited functionality in the voxel model shader. 2023-10-19 19:18:36 +02:00
IntegratedQuantum
cc85c8af1d Update zig. 2023-10-17 17:34:54 +02:00
IntegratedQuantum
e48cf8f763 Check for ANSI color support, falling back to "[level]: msg" style when not present.
Fixes #143
2023-10-17 10:51:15 +02:00
IntegratedQuantum
91bd0b031c Compile all the C files into a static lib first.
Fixes #125

The workaround was taken from here: https://github.com/ziglang/zig/issues/17091#issuecomment-1710907659
2023-10-16 22:30:20 +02:00
person-person
345bb0e419
Exit crash (#140)
* Fixes crash on exit

* Shorter comment

---------

Co-authored-by: Person Person <firestarscree123@gmail.com>
2023-10-16 10:57:39 +02:00
IntegratedQuantum
277bcfe48e Convert windows path seperators to / when generating resource ids.
Fixes #123
2023-10-15 22:49:58 +02:00