Giter VIP home page Giter VIP logo

Comments (7)

RemusMar avatar RemusMar commented on May 18, 2024 2

@am05mhz
To get much better results you can use this trick:

		loader.load( 'meshes/forest_house.glb', function ( gltf ) {
			gltf.scene.traverse(function (child) {
				if (child.isMesh) {
					if (child.material.transparent === true) {
						child.material.depthWrite = true;
						child.material.alphaTest = 0.5;
					}
				}
			});

Here is the result: https://necromanthus.com/Test/html5/forest_house.html

@donmccurdy

Realtime 3D engines typically can sort objects - not triangles or pixels - making this category of problem in alpha blending a known limitation.

Don, there is an uninspired (I don't want to say wrong) setting inside of the GLTF Loader:
materialParams.depthWrite = false;
That will generate an alpha sorting mess in 99% of the scenarios.
You should study this sample as well: https://necromanthus.com/Test/html5/head.html
Click on the stage to see the 3 cases.
cheers

from three.js.

donmccurdy avatar donmccurdy commented on May 18, 2024 1

Realtime 3D engines typically can sort objects - not triangles or pixels - making this category of problem in alpha blending a known limitation. Entire scenes should not use alpha blending without special care for the sort order, or other techniques like OIT or alpha hashing.

from three.js.

am05mhz avatar am05mhz commented on May 18, 2024 1

@am05mhz To get much better results you can use this trick:

		loader.load( 'meshes/forest_house.glb', function ( gltf ) {
			gltf.scene.traverse(function (child) {
				if (child.isMesh) {
					if (child.material.transparent === true) {
						child.material.depthWrite = true;
						child.material.alphaTest = 0.5;
					}
				}
			});

Here is the result: https://necromanthus.com/Test/html5/forest_house.html

@donmccurdy

Realtime 3D engines typically can sort objects - not triangles or pixels - making this category of problem in alpha blending a known limitation.

Don, there is an uninspired (I don't want to say wrong) setting inside of the GLTF Loader: materialParams.depthWrite = false; That will generate an alpha sorting mess in 99% of the scenarios. You should study this sample as well: https://necromanthus.com/Test/html5/head.html Click on the stage to see the 3 cases. cheers

thanks, this solves my problem

from three.js.

Mugen87 avatar Mugen87 commented on May 18, 2024

We actually use an updated version of the asset in https://threejs.org/examples/webgl_loader_gltf_avif

from three.js.

Mugen87 avatar Mugen87 commented on May 18, 2024

Closing. Considering this as a modeling issue.

from three.js.

RemusMar avatar RemusMar commented on May 18, 2024

Considering this as a modeling issue.

It's not Michael.
See my above result with that (not very well designed) sample.

from three.js.

RemusMar avatar RemusMar commented on May 18, 2024

@Mugen87

We actually use an updated version of the asset in https://threejs.org/examples/webgl_loader_gltf_avif

I get exactly that result (in fact mine is a bit better) using the initial asset and this runtime change:

			gltf.scene.traverse(function (child) {
				if (child.isMesh) {
					if (child.material.name === "TreeLeafs") {
						child.material.side = THREE.DoubleSide;
						child.material.depthWrite = true;
						child.material.depthTest = true;
						child.material.alphaTest = 0.4;
						child.material.transparent = false;
					}
				}
			});

https://necromanthus.com/Test/html5/forest_house.html
And you'll find a similar modified material in the "fixed" asset.
So Michael, it was a hack, not a real fix.
cheers

from three.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.