未验证 提交 89c7c640 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #18785 from mrdoob/revert-18579-fixMask

Revert "Fix glTF mask"
......@@ -2109,12 +2109,6 @@ THREE.GLTFLoader = ( function () {
materialParams.alphaTest = materialDef.alphaCutoff !== undefined ? materialDef.alphaCutoff : 0.5;
} else {
// for ALPHA_MODES.OPAQUE, we use a negative alphaTest value to enable alphaTesting,
// causing the test to always be passed, but also replacing any alpha value with 1.0.
materialParams.alphaTest = - 0.5;
}
}
......
......@@ -2172,12 +2172,6 @@ var GLTFLoader = ( function () {
materialParams.alphaTest = materialDef.alphaCutoff !== undefined ? materialDef.alphaCutoff : 0.5;
} else {
// for ALPHA_MODES.OPAQUE, we use a negative alphaTest value to enable alphaTesting,
// causing the test to always be passed, but also replacing any alpha value with 1.0.
materialParams.alphaTest = - 0.5;
}
}
......
# Alpha Blend Mode Test
## Screenshot
![screenshot](screenshot/screenshot_large.jpg)
## Description
This model tests the various alpha modes available in glTF 2.0. There are three settings for `alphaMode`: `"OPAQUE"` (the default), `"BLEND"`, and `"MASK"`. Of these, `"MASK"` takes an additional `alphaCutoff` value that modifies it.
## `OPAQUE` vs `BLEND`
![screenshot](screenshot/OpaqueVsBlend.jpg)
The box on the far left uses the default alphaMode, `OPAQUE`. Although the texturemap supplies an alpha channel, the alpha values are intentionally ignored here.
The next box shows the effects of alpha blending. The texture contains a linear alpha ramp inside a black border, along with some labels. At the bottom there are green check marks and hidden red X's, that will show check marks only when the requested mode is correctly applied.
## Problem: Alpha Values Used in Opaque Mode
![screenshot](screenshot/OpaqueFail.jpg)
The above screenshot shows what typically happens if a rendering engine decides to process alpha values from a texturemap without blending being specifically requested. This is a test failure, and should be corrected in the engine.
Note that a red "X" mark has appeared next to `OPAQUE`, due to a green checkmark with zero alpha values being blended away.
# Problem: Lack of Alpha Blending
![screenshot](screenshot/BlendFail.jpg)
In the above screenshot, it appears that alpha blending is not available, or not enabled when a model requests it. This is also a test failure, and could be due to a missing feature or other issues in the rendering engine.
Note that a red "X" mark has appeared next to `BLEND`. This "X" has zero alpha values, and should be blended away, revealing a green checkmark behind it.
## `MASK` and `alphaCutoff`
![screenshot](screenshot/CutoffTests.jpg)
This model tests `MASK` mode with the default value, shown in the middle box of three in the above screenshot, surrounded by cutoff values of `0.25` and `0.75`.
Because the alpha values in the box are a smooth linear ramp, we can expect the contents to be cut off at the corresponding values, as indicated by the green triangles.
Note that alpha blending should not be applied here: Each texel is either fully opaque or discarded. Depth buffering with writes enabled may be used in `MASK` mode.
## Known Mipmapping Issues
![screenshot](screenshot/MissingBorder.png)
When a texture gets farther from the camera, a process called mipmapping may be used to blend texels (texturemap pixels) together. This particular test model has a very thin opaque border adjacent to a lot of transparent texels. When mipmapping blends these together, the resulting alpha values can land in the middle someplace. Setting a high alpha mask cutoff value can cause these blended texels to be discarded. This is not considered a failure for the purpose of this particular test. However, if you see this effect in your own models, you may wish to set a lower cutoff value or increase the thickness of the affected area.
## Problem: `alphaCutoff` Not Respected
![screenshot](screenshot/CutoffValueFail.jpg)
In the above screenshot, the requested `alphaCutoff` value is not being respected, and the default value of `0.5` appears to be applied regardless of the setting. This is a test failure.
## Problem: No Default Cutoff
![screenshot](screenshot/CutoffDefaultFail.jpg)
In this screenshot, it appears that the rendering engine is not using the value `0.5` for the default value of `alphaCutoff` when the model does not specify a particular value. The glTF specification [names `0.5` as the default](https://github.com/KhronosGroup/glTF/blob/0890b76c62cc762ce82d4010df9bfebb1634839b/specification/2.0/schema/material.schema.json#L68), so this is a test failure.
## License Information
Copyright 2018 Analytical Graphics, Inc.
CC-BY 4.0 https://creativecommons.org/licenses/by/4.0/
Model and textures by Ed Mackey.
# Monster
## Screenshot
![screenshot](screenshot/screenshot.gif)
## License Information
Model from: http://www.3drt.com/downloads.htm
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -14,7 +14,7 @@
<div id="description"></div>
</div>
<div id="container" style="background-color: white;"></div>
<div id="container"></div>
<script type="module">
......@@ -78,6 +78,21 @@
shadows: true,
extensions: [ 'glTF', 'glTF-Embedded', 'glTF-pbrSpecularGlossiness', 'glTF-Binary', 'glTF-Draco' ]
},
Monster: {
name: 'Monster',
url: './models/gltf/Monster/%s/Monster.gltf',
author: '3drt.com',
authorURL: 'http://www.3drt.com/downloads.htm',
cameraPos: new THREE.Vector3( 3, 1, 7 ),
objectScale: new THREE.Vector3( 0.04, 0.04, 0.04 ),
objectPosition: new THREE.Vector3( 0.2, 0.1, 0 ),
objectRotation: new THREE.Euler( 0, - 3 * Math.PI / 4, 0 ),
animationTime: 3,
addLights: true,
shadows: true,
addGround: true,
extensions: [ 'glTF', 'glTF-Embedded', 'glTF-Binary', 'glTF-Draco', 'glTF-lights' ]
},
'Cesium Man': {
name: 'Cesium Man',
url: './models/gltf/CesiumMan/%s/CesiumMan.gltf',
......@@ -113,15 +128,6 @@
shadows: true,
extensions: [ 'glTF' ]
},
'Alpha Blend Mode Test': {
name: 'Alpha Blend Mode Test',
url: './models/gltf/AlphaBlendModeTest/%s/AlphaBlendModeTest.gltf',
author: 'Analytical Graphics, Inc.',
authorURL: 'https://www.agi.com/home',
cameraPos: new THREE.Vector3( 0, 3, 10 ),
addEnvMap: true,
extensions: [ 'glTF', 'glTF-Embedded', 'glTF-Binary' ]
},
};
var state = {
......@@ -134,7 +140,7 @@
container = document.getElementById( 'container' );
renderer = new THREE.WebGLRenderer( { alpha: true, antialias: true } );
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.outputEncoding = THREE.sRGBEncoding;
......@@ -181,7 +187,7 @@
scene = new THREE.Scene();
scene.background = new THREE.Color( 0x222222 );
camera = new THREE.PerspectiveCamera( 45, container.offsetWidth / container.offsetHeight, 0.01, 100 );
camera = new THREE.PerspectiveCamera( 45, container.offsetWidth / container.offsetHeight, 0.001, 1000 );
scene.add( camera );
var spot1;
......
......@@ -2,7 +2,6 @@ export default /* glsl */`
#ifdef ALPHATEST
if ( diffuseColor.a < ALPHATEST ) discard;
diffuseColor.a = 1.0;
#endif
`;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册