Show HN: WebGL Voxel Engine
github.com
github.com
- [Lallassu/Qake: Qake voxel-engine demo](https://github.com/Lallassu/Qake)
I was really floored by how much functionality was possible with what seems like so little code.
Perhaps you have something to share, a demo/screenshots? :)
I had started an earlier version in Unity but I really dislike fighting what feels like a giant extraneous system. I was blown away by your demo; in particular the environmental damage. You 'sold' me on writing something similar. I'm probably yak shaving now but it feels so much more right to be programming instead of fighting Unity.
Thanks! This really is the best sentiment for personal passion projects. Tho an occasional sprint can be fun too!
This 'isn't my first rodeo'. I've been partially implementing ambitious software projects for years!
Thing I've struggled with is all the background. People talk about shaders and launch straight into the details, but I've barely been able to find any background information that sets the scene.
Last night I made a game with Unity, which was fun and pretty simple to start with and I'd like to understand more about it all.
Where does someone with plenty of comp and maths knowledge but no 3D experience (other than tinkering with the likes of Blender) go to learn about it quickly?
I still have no idea how to do “correct” perspectives. This is just something I hacked together until it looked good.
I can very much recommend doing a project like this. You will naturally figure out how 3D graphics work, and it’s simpler than it appears.
Relevant shaders link here: https://webglfundamentals.org/webgl/lessons/webgl-shaders-an...
Edit: I'd also add: I wouldn't bother learning much OpenGL/WebGL to begin with (except shader programming in GLSL, since there's no good alternative abstraction for that). If you end up liking working with 3D graphics, go back and learn some about it since it'll help you understand performance concerns better—but meanwhile, knowing it is just an optimization you don't need yet. It's true three.js is built on top of it, but the significant principles you need to use three.js effectively fall under real-time rendering, not OpenGL.
The programmable pipeline requires you to define some programs called "shaders" that run on the graphics card and replace the previous fixed pipeline functions.
Example: Say you feed a bunch of geometry information into the API (a list of vertices, faces that use those vertices, coordinates for textures, etc). The "vertex shader" receives 3D vertex coordinates (and possibly other values) and needs to output 2D screen coordinates. The hardware calculates which screen pixels will actually show which part of which face, and passes some coordinate information to a "pixel/fragment shader". The basic job of that shader is to read texture, color, and lighting information and decide what color should be output to the screen for a specific pixel (replacing the functionality of the lighting and texturing functions that were used in the fixed-function pipeline).
I think that three.js adds another level of abstraction on top of the actual graphics APIs.
Coming from a CS background, with a few years "in industry", I started by reading about the history of computer graphics, read some fixed-function 3D graphics tutorials, built a few toy programs, then moved to the shader pipeline, and built a few more toy programs with the things that I learned. Read theory, experiment to see how it maps to practice, refine your understanding, and then go back to reading, if necessary.
If I'm remembering correctly, I mostly ended up using http://www.opengl-tutorial.org/, liberally supplemented with Wikipedia articles and random mathematics articles, as necessary. (obviously, this isn't focused on WebGL and Three.js, but the core concepts apply. It might make more sense to go for tutorials in the ecosystem you'd like to learn, rather than learning one system, then having the time and cognitive overhead of learning to map the concepts to a new system).
What's the purpose of the node server in the code (as opposed to just opening the HTML document in a browser)? Do you have plans to use websockets or something to add multiplayer?
AZERTY layout: https://en.wikipedia.org/wiki/AZERTY#/media/File:KB_France.s...
Something like GVDB that runs in WebGL and can handle arbitrary dimensional volumes.
It's a very tall order!
The OpenGL and WebGL primitives aren't really suited for N-dimensional data since there are specific buffer types and intrinsics for 1D, 2D, and 3D texture handling. You can fake more than 4 channels using more than one texture. You can't really get around the per-axis size limits because these are points of portability and also directly related to resource allocation limits in practice, i.e. GPU RAM is consumed as the cube of 3D texture span.
You can abuse WebGL textures a little bit by turning off interpolation and using nearest sampling as if it were a basic array access. But then you still have to write your own array packer and N-dimensional array addressing arithmetic to map the ND coordinate into the 3D coordinate needed by the texture sampler. And you still have to live with such tiny texture size limits that it seems quite pointless except as an academic exercise. I've used this to fit larger 1D arrays into a 3D texture without exceeding a 1024 or 2048 per-axis limit.
Actual ND techniques are more feasible in a GPGPU language like OpenCL, where you have more basic memory access and SIMD intrinsics. But I think it will be quite some time before these capabilities are exposed in a web language and also with sufficiently high resource limits to do anything non-trivial.
If it's even possible, it'd be hard. I don't have the chops at the moment, and neither does chrome!
"But I think it will be quite some time before these capabilities are exposed in a web language and also with sufficiently high resource limits to do anything non-trivial."
Realistically, that's probably more what I'm actually waiting for.
And GVDB could be perfect, except for its super awkward licensing and platform lock. Ugh! I think there are some other realtime VDB projects out there, so I might check into those some time.
In the meanwhile, when I get around to it, I'll probably end up doing low poly ("low-simplex") stuff. A more realistic goal for the browser of today (and for my skillset) is something that can intersect lower dimensional manifolds with simplices embedded in higher dimensions. Dealing with normals will be mind bending. But I believe it can be done!
My project is to play with 4D (and higher) Moebius transformations of animated polygon scenes.
First, the animated polygons need to be converted into 4d polytopes. Using the intersection tool described above, the 4d scene can be "scrubbed" in a time-like way by transforming the intersecting manifold. Except that now it's possible to apply conformal transformations to the 4d polytopes before scrubbing through!
This is an old demo of 3d Moebius transformations applied to key-framed polygons: http://hyperspectives.wondering.xyz/moebius/hyperhorse.html
Except that now I'm wondering about what 4d Moebius transformations look like.
How do they deform animation? I'm pretty sure that under a 4d moebius transformation, all four of the horse's legs could be running at different rates without ever interfering with one another. Of course they'd all be different sizes too. Also, spatial dimensions of the horse geometry would melt into the time dimension, depending on what kind of manifold was doing the time-slicing. What would it look like??! I want to see!
I might actually be able to get away with using stereographic projection/rejection for time-slicing instead of intersections, but I need to think that through very, very hard. I think it'd probably result in some gnarly polygons.
By the way, another thing I'm really looking into is this: https://link.springer.com/chapter/10.1007/978-3-642-54382-1_...
I've managed to implement these clifford-bezier surface patches in Sage, haven't gotten around to OpenGL.
EDIT:
By the way, in case you're curious, the idea that the horse's legs could move at different frequencies without intersecting one another is very much related to "spacetime dilation" in the theory relativity. The principle that would keep the hyper-horse from self intersecting is conformal invariance, which is closely related to Lorentz invariance.