Comments (5)
Okay, that explains it. Thank you very much!
from noa.
It seems this was worked on 3 years ago but was never really finished...
from noa.
Hi! Sorry - this is intended but I don't have any good docs explaining it. Here's the basic story.
The implementation I've settled on adds 1-voxel of padding to all chunks. This is done so that the edge blocks of each chunk can be built correctly, since the meshing and ambient occlusion for a given voxel depends on its neighbors. The alternative would to omit the padding but rebuild each chunk when its neighbors first get created - I experimented with that as you saw, but wound up sticking with the current behavior for now.
So, when you set chunk size to 16, and noa
wants the chunk for (0,0,0)
, it sends out an event with an (18, 18, 18)
size array for location [-1, -1, -1]
. So the correct way to handle it would look like:
noa.world.on('worldDataNeeded', function (id, array, x, y, z) {
var size = array.shape[0]
for (var i = 0; i < size; i++) {
for (var j = 0; j < size; j++) {
for (var k = 0; k < size; k++) {
var worldx = x + i
var worldy = y + j
var worldz = z + k
var block = decideBlockID(worldx, worldy, worldz)
array.set(i, j, k, block)
}
}
}
}
Hope this helps, let me know if it works!
from noa.
So should you or should you not write to the padding? In the example you gave, you are simply acting as if the chunk was 18x18x18; doesn't that mean you are writing twice but one of them is useless? (I know that you are using worldX, worldY, worldZ to allow terrain generation to know where it is, but it still seems pointless to write if you don't need it).
Right now, I'm simply ignoring the padding and not writing anything there, is that fine/recommended?
Will that mess up with block culling?
// Note: I'm ignoring the x,y,z passed by worldDataNeeded because I don't need them
noa.world.on('worldDataNeeded', function (id, data) {
for(let x = 1; x < data.shape[0] - 1; x++) {
for(let y = 1; y < data.shape[1] - 1; y++) {
for(let z = 1; z < data.shape[2] - 1; z++) {
if (y === 1) {
data.set(x, y, z, game.blocks.stone.id);
}
}
}
}
}
EDIT: Is this issue related? Should I add blocks in the padding area?
from noa.
Yes, you should fill in all the blocks in the data
array, including the padding.
The engine uses the padding blocks to figure out how to build the edges of each chunk - whether they need meshes on the boundary and whether the edge blocks need AO, so if you leave them out there should be issues at chunk borders.
For reference here's what the hello world
demo looks like if you omit the padding blocks - the light-colored bands on the ground are incorrect AO, and the terrain gaps are the same issue you saw in your video.
from noa.
Related Issues (20)
- Is there any way to use this as an es6 module? HOT 10
- Support gamepad input
- Outdated comment + note on blockMesh registration HOT 2
- Alpha blended mesh ordering issue HOT 2
- Terrain remeshing bug when block is neither solid nor opaque HOT 3
- Custom voxel occasionally leaves one side after removal. HOT 4
- UV offsets wrapping at edges of blocks HOT 2
- object meshing bug HOT 6
- Meshing with non-opaque blocks is incredibly slow + block textures with alpha dont work HOT 4
- custom renderMaterial performance (for animated textures) HOT 2
- Supporting noa HOT 2
- Does NOA support child meshes? HOT 3
- webgpu? HOT 2
- How to define new objects in NOA engine. HOT 5
- Optimal octreeBlockSize
- What is the best way to manually build worlds? HOT 2
- render all blocks even if covered HOT 1
- How to import an obj model?
- refresh the registry on the go HOT 2
- Making a set world.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from noa.