fenomas / noa

Experimental voxel game engine.
MIT License
611 stars 87 forks source link

Getting started template w/ react #150

Closed MCArth closed 3 years ago

MCArth commented 3 years ago

I had some issues getting your example repos running on node v14 (a webpack-dev-server dependency said it didn't work on v14+, but I didn't dig too deeply). Having react will be helpful for me anyway, so I ported the 'test' example over to CRA.

https://github.com/MCArth/noa-cra-example

Not sure if you think it would be useful for others - if so feel free to add it to the readme! (I left most CRA boilerplate intact, can take it out if it'd be helpful, though to me it makes it feel more dual use)

Great engine by the way! I noticed you mentioned chunks knowing about adjacent blocks in the changelog - where would be the easiest place to get started on implementing the following aesthetic: image

Also as I couldn't spot it from my glance at the source, are you using greedy meshing? Are there any chances of t-junctions? (though I know hardware has come a way since minecraft's release!)

fenomas commented 3 years ago

Hi, thanks for the comments and posting the repo! Personally I run with current node 14+ and webpack 4.x, as webpack 5+ had some bugs that completely broke my project. But it probably varies a lot based on what other tools one uses (TS, react, etc). I will add a link to the example repo.

For your questions, about meshing this library uses the greedy algorithm that was blogged about on 0fps.net by @mikolalysenko. As such it does create T-junctions, but I'm not aware of any issues caused by this (see the note to that effect in the linked article). My offhand guess is that T-junctions would create very noticeable artifacts if any kind of rounding error was present, but this library rebases the coordinates frequently to avoid that. Do post an issue if you see problems though.

About chunks and neighbors, the story there is that initially this library duplicated two voxels of padding at chunk edges, so that each chunk could be fully meshed before neighboring chunks existed. But I abandoned that and now nothing is duplicated.

Finally about the rendering question: in the engine as it stands today, the only way to make an effect like that would be to have multiple versions of each block type with different textures - like voxel 1 is "grass block with no outlines", voxel 2 is "grass block with outline at the upper north edge" and so on. A real solution would mean custom shaders, but I haven't done any work in that direction, or done any thinking about what the engine could do for client apps that aren't using babylon's default shaders.

MCArth commented 3 years ago

Great, thanks for the info :)

Will let you know if I see any issues with t-junctions, but if no one else has found any, it seems unlikely I will!