499 Commits

Author SHA1 Message Date
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
IntegratedQuantum
f3a197f6d4 Default gui positions
Resolves #131
2023-10-15 22:26:02 +02:00
IntegratedQuantum
998fd96a7b Load the audio sample rate from the default audio device.
Fixes #128
2023-10-15 20:56:03 +02:00
IntegratedQuantum
30891a6efd Shorter thread name.
Prevents getting above the 15 character limit on Linux for cpus with more than 10 threads.
2023-10-15 13:00:03 +02:00
IntegratedQuantum
39f5111528 Fix the bat file. 2023-10-15 11:25:03 +02:00
IntegratedQuantum
e358832f2f Fix an oversight in the last commit that caused face duplication at chunk borders. 2023-10-09 23:02:54 +02:00
IntegratedQuantum
2f52e9923b Render voxel models using a separate shader.
This allows simplifying the regular shader, improving its performance by ~10%. #96
It does however increase the number of separate draw calls by a bit.
Additionally this opens up more opportunities for the future, in regards to drawing regular models. #134
2023-10-08 18:22:34 +02:00
IntegratedQuantum
4a4af0964e Fix shader compilation warning and work around weird shader miscompilation on my intel laptop. 2023-10-07 18:06:12 +02:00
IntegratedQuantum
546aad5090 Since there is no way to create world right now, I added a save folder to the git. This shall be removed later. 2023-10-07 17:07:47 +02:00
IntegratedQuantum
cc9a06ef29 Fix some TODOs. 2023-10-06 22:34:36 +02:00
IntegratedQuantum
24caa187be I was already using functionality from OpenGL 4.5 which broke on Windows.
I had to use `glTextureBarrier` to be able to read from the depth buffer in the transparent rendering step.

Fixes #124
2023-10-05 18:27:36 +02:00
IntegratedQuantum
c899f9cd65 Add run.bat script for windows that automatically updates and runs zig.
Resolves #104
2023-10-05 18:10:04 +02:00
IntegratedQuantum
d264518cde run.sh: Delete the tar archive after extracting. 2023-10-05 13:17:05 +02:00
IntegratedQuantum
66993820bb Cull transparent backfaces during transparency sorting.
It appears that the vertex shader cost is around 4 ms per 1 million faces, once again proving that #121 is important.
2023-10-05 12:59:14 +02:00
IntegratedQuantum
0b02654c59 Fix block selection outline. 2023-10-05 11:57:32 +02:00
IntegratedQuantum
766dd53d06 Update zig:
@abs (formerly @fabs) now supports integers.
2023-10-04 12:36:00 +02:00
IntegratedQuantum
045ba9c65a Precalculate animation data to avoid recalculating it a million times in the fragment shader.
Improves performance by about 1 ms in a test scene.
2023-10-02 23:49:24 +02:00
IntegratedQuantum
657aa8dc9d Small improvements to the transparent shader. 2023-10-02 22:52:35 +02:00
IntegratedQuantum
044ab3bb62 Rework the fog, so it doesn't need the alpha component anymore.
This also fixes #93 as a side effect
This could also theoretically improve performance due to using a smaller image format, but I couldn't measure a bit difference on my computer, it might be that my driver/hardware just pads the alpha component.
2023-09-29 17:28:38 +02:00
IntegratedQuantum
cc6fb4b55a Improve performance by not calling the raycasting code when the model is a full cube.
Only 0.5 ms, but better than nothing.
2023-09-28 17:12:46 +02:00
IntegratedQuantum
54337f17fd Add a run.sh file that automatically downloads or updates zig and runs the game.
This is a step towards #103
2023-09-26 22:06:35 +02:00
IntegratedQuantum
6c896e2e93 I found a perfect workaround to the compiler regression #17289 2023-09-26 21:21:48 +02:00
IntegratedQuantum
86ab8ef782 Remove portaudio submodule, getting it through the zig package manager instead.
Resolves #103
2023-09-26 17:42:54 +02:00
IntegratedQuantum
6e43ec3d40 Update zig version to 0.12.0-dev.596+2adb932ad
I also had to add some workarounds for a new regression in the zig compiler: https://github.com/ziglang/zig/issues/17289
2023-09-26 17:15:55 +02:00
IntegratedQuantum
257c7d7a3b
Update README.md with a note about required -dev packages on Linux 2023-09-24 11:09:09 +02:00
IntegratedQuantum
3c638017f9 Fix small mistake that messed up texturing. 2023-09-22 11:55:04 +02:00
IntegratedQuantum
3d19feae42 Add dithering when transitioning to raymarching lod. 2023-09-22 11:52:21 +02:00
IntegratedQuantum
f0b5ba3249 Improve the voxel raymarching bound detection.
Now it breaks at the true bound of the model instead of marching into the empty space beyond it.
2023-09-22 11:19:33 +02:00