提交 bca5b38e 编写于 作者: M Mr.doob

Material: Set alphaTest to null by default

上级 040d9297
......@@ -62,7 +62,7 @@ class Material extends EventDispatcher {
this.dithering = false;
this.alphaTest = 0;
this.alphaTest = null;
this.alphaToCoverage = false;
this.premultipliedAlpha = false;
......@@ -308,7 +308,7 @@ class Material extends EventDispatcher {
if ( this.dithering === true ) data.dithering = true;
if ( this.alphaTest > 0 ) data.alphaTest = this.alphaTest;
if ( this.alphaTest !== null ) data.alphaTest = this.alphaTest;
if ( this.alphaToCoverage === true ) data.alphaToCoverage = this.alphaToCoverage;
if ( this.premultipliedAlpha === true ) data.premultipliedAlpha = this.premultipliedAlpha;
......
export default /* glsl */`
#ifdef USE_ALPHATEST
if ( diffuseColor.a < alphaTest ) discard;
#endif
`;
export default /* glsl */`
#ifdef USE_ALPHATEST
uniform float alphaTest;
#endif
`;
......@@ -107,7 +107,6 @@ function WebGLMaterials( properties ) {
function refreshUniformsCommon( uniforms, material ) {
uniforms.alphaTest.value = material.alphaTest;
uniforms.opacity.value = material.opacity;
if ( material.color ) {
......@@ -134,6 +133,12 @@ function WebGLMaterials( properties ) {
}
if ( material.alphaTest !== null ) {
uniforms.alphaTest.value = material.alphaTest;
}
if ( material.specularMap ) {
uniforms.specularMap.value = material.specularMap;
......
......@@ -607,6 +607,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '',
parameters.metalnessMap ? '#define USE_METALNESSMAP' : '',
parameters.alphaMap ? '#define USE_ALPHAMAP' : '',
parameters.alphaTest ? '#define USE_ALPHATEST' : '',
parameters.sheen ? '#define USE_SHEEN' : '',
parameters.transmission ? '#define USE_TRANSMISSION' : '',
......
......@@ -38,7 +38,7 @@ function WebGLPrograms( renderer, cubemaps, extensions, capabilities, bindingSta
'map', 'mapEncoding', 'matcap', 'matcapEncoding', 'envMap', 'envMapMode', 'envMapEncoding', 'envMapCubeUV',
'lightMap', 'lightMapEncoding', 'aoMap', 'emissiveMap', 'emissiveMapEncoding', 'bumpMap', 'normalMap', 'objectSpaceNormalMap', 'tangentSpaceNormalMap', 'clearcoatMap', 'clearcoatRoughnessMap', 'clearcoatNormalMap', 'displacementMap', 'specularMap',
'roughnessMap', 'metalnessMap', 'gradientMap',
'alphaMap', 'combine', 'vertexColors', 'vertexAlphas', 'vertexTangents', 'vertexUvs', 'uvsVertexOnly', 'fog', 'useFog', 'fogExp2',
'alphaMap', 'alphaTest', 'combine', 'vertexColors', 'vertexAlphas', 'vertexTangents', 'vertexUvs', 'uvsVertexOnly', 'fog', 'useFog', 'fogExp2',
'flatShading', 'sizeAttenuation', 'logarithmicDepthBuffer', 'skinning',
'maxBones', 'useVertexTexture', 'morphTargets', 'morphNormals', 'premultipliedAlpha',
'numDirLights', 'numPointLights', 'numSpotLights', 'numHemiLights', 'numRectAreaLights',
......@@ -197,6 +197,7 @@ function WebGLPrograms( renderer, cubemaps, extensions, capabilities, bindingSta
metalnessMap: !! material.metalnessMap,
specularMap: !! material.specularMap,
alphaMap: !! material.alphaMap,
aphaTest: material.alphaTest !== null,
gradientMap: !! material.gradientMap,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册