Hyperbolic Voxel Sphere
Haaf » Devlog
I was trying to upload the voxel world to the gpu, and it worked (kinda) but meanwhile I found that the voxel world was not rendering correctly. Somewhere in my raytracer the rays are being bent, causing hyperbolic rendering instead of normal spatial rendering. This is extremely evident in the videos listed below:
I question why and how this bug exists but I will only understand once it is fixed.
Thanks for listening.
Haaf
A micro voxel fishing game where the sea-floor's the limit.
Status | In development |
Author | MountainLabs |
Genre | Survival |
Tags | Fishing, Voxel |
More posts
- Devlog 001 "Anticipation"15 days ago
- Bevy and Path Traced lighting soon enough!!Oct 02, 2024
Comments
Log in with itch.io to leave a comment.
Stating perhaps the obvious: It looks to me like the ray origins and directions are not being calculated correctly.
Here are code snippets from my voxel ray march compute shader that calculate ray origins and directions (format is a little "wonky" pasted here in a code block) :
P.S. I have my Vulkan pipeline's coordinates system y-flipped so positive y is up in world space. Hence the "1 - (((fragCoord.y + 0.5) / resolution.y) * 2)" in ndcFragCoord().
Firstly, positive y should be up, anything else is heresy, and what is a projection matrix? I see everybody using one, but I don't use one myself. How do they work?
Google's AI describes it better than I can: "A projection matrix is a square matrix in linear algebra that, when multiplied with a vector, outputs the projection of that vector onto a specific subspace; essentially, it "flattens" the vector onto a lower-dimensional space while maintaining its relative position within that subspace."
I use perspective projection matrices for all things 3D in my voxel engine (calculations of ray origins and directions, rasterized lines and triangles). Rasterizing pipelines in 3D graphics use the matrices to flatten projected 3D coordinates onto 2D screen space coordinates in order to rasterize in 2D.
It is also strange that you say you think it is the ray origins and diretions that are not calculated correctly, (although you could very possibly be right, I wouldn't doubt it) But it is strange, because if I do a basic ray box intersection using the same ray directions and origins there is no warping at all. The warping exists entirely within the DDA algorithm I have. Here it is:
The code is too complicated for me to easily see where the calculations are incorrect. Perhaps a test case in 2D would be easier to (visually) debug.
P.S. the bug is most prevalent at the poles of the sphere.
(this sphere has 6 poles where each face on a cube would be)