fenomas / noa

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

Z-order issues #112

Closed Roy-Ermers closed 3 years ago

Roy-Ermers commented 4 years ago

There are z-order issues with transparant blocks image

fenomas commented 4 years ago

Hi, will need a lot more info here. Overlapping transparent meshes in 3D is a thorny problem generally, and Babylon has various content types (particles, instances, etc) that AFAIK have a fixed compositing order (if using default shaders). What kind of meshes are these, and what kinds of materials are used, etc.?

NB: noa doesn't do anything magical here - it just merges like terrain faces or custom meshes into large per-chunk meshes, and when needed Babylon should apply Z-ordering to them based on their center. If that's not happening for you it may be a noa bug, but if it is and it's not rendering as expected then the scene will need to be constructed differently.

Roy-Ermers commented 4 years ago

Hey, the code that intializes these blocks is this.

        var mesh = Mesh.CreatePlane('cross', 1, this.renderer.getScene());
        mesh.material = material;
        mesh.rotation.x += Math.PI;
        mesh.rotation.y += Math.PI / 4;
        let offset = Matrix.Translation(0, -0.5, 0);
        mesh.bakeTransformIntoVertices(offset);
        let clone = mesh.clone();
        clone.rotation.y += Math.PI / 2;
        const result = Mesh.MergeMeshes([mesh, clone], true);

this uses the makeStandardMaterial method and the block is not solid and not opaque. Do you know a fix?

fenomas commented 4 years ago

Hi, sorry for the delay here. I can't reproduce this; when I make different custom blocks with hasAlpha on the texture, they seem to composite as expected.

Can you e.g. fork noa-examples and add code to show this happening, so I can reproduce?

Roy-Ermers commented 4 years ago

Maybe I could give you access to my codebase, because I can't reproduce the bug in the noa-examples repo?

fenomas commented 4 years ago

Hi, I'm guessing that will not help - you know your project better than I, so if you can't isolate the issue then I won't be able to!

When I get time I will try more to recreate this on my own..

fenomas commented 3 years ago

Closing this since static blocks (for grass etc) are now created differently than when it was filed, but please re-open if the issue is still as before.