Revert some changes from diffuse-alpha-same

This commit is contained in:
Sean Lilley 2019-07-22 18:39:30 -04:00
parent 72f09e2b1e
commit 080f5debf7
2 changed files with 13 additions and 17 deletions

View File

@ -387,7 +387,7 @@ function createDiffuseAlphaTexture(diffuseTexture, alphaTexture, options) {
return diffuseTexture; return diffuseTexture;
} }
if (diffuseTexture.path === alphaTexture.path) { if (diffuseTexture === alphaTexture) {
return diffuseTexture; return diffuseTexture;
} }
@ -590,7 +590,7 @@ function createSpecularGlossinessMaterial(material, options) {
emissiveFactor = [1.0, 1.0, 1.0]; emissiveFactor = [1.0, 1.0, 1.0];
} }
if (defined(diffuseAlphaTexture)) { if (defined(diffuseTexture)) {
diffuseFactor = [1.0, 1.0, 1.0, 1.0]; diffuseFactor = [1.0, 1.0, 1.0, 1.0];
} }
@ -611,8 +611,8 @@ function createSpecularGlossinessMaterial(material, options) {
transparent = alpha < 1.0; transparent = alpha < 1.0;
} }
if (defined(diffuseAlphaTexture)) { if (defined(diffuseTexture)) {
transparent = transparent || diffuseAlphaTexture.transparent; transparent = transparent || diffuseTexture.transparent;
} }
const doubleSided = transparent; const doubleSided = transparent;
@ -662,7 +662,7 @@ function createMetallicRoughnessMaterial(material, options) {
emissiveFactor = [1.0, 1.0, 1.0]; emissiveFactor = [1.0, 1.0, 1.0];
} }
if (defined(diffuseAlphaTexture)) { if (defined(baseColorTexture)) {
baseColorFactor = [1.0, 1.0, 1.0, 1.0]; baseColorFactor = [1.0, 1.0, 1.0, 1.0];
} }
@ -683,8 +683,8 @@ function createMetallicRoughnessMaterial(material, options) {
transparent = alpha < 1.0; transparent = alpha < 1.0;
} }
if (defined(diffuseAlphaTexture)) { if (defined(baseColorTexture)) {
transparent = transparent || diffuseAlphaTexture.transparent; transparent = transparent || baseColorTexture.transparent;
} }
const doubleSided = transparent; const doubleSided = transparent;

View File

@ -322,18 +322,16 @@ describe('loadMtl', () => {
expect(material.doubleSided).toBe(true); expect(material.doubleSided).toBe(true);
}); });
it('uses diffuse texture if diffuse and alpha are the same', async () => { it('uses diffuse texture if diffuse and alpha are the same', () => {
options.metallicRoughness = true; options.metallicRoughness = true;
// The transparent property will be modified so make a copy
const diffuseTextureCopy = await loadTexture(diffuseTexturePath, decodeOptions);
const material = loadMtl._createMaterial({ const material = loadMtl._createMaterial({
diffuseTexture : diffuseTextureCopy, diffuseTexture : diffuseTexture,
alphaTexture : diffuseTexture alphaTexture : diffuseTexture
}, options); }, options);
const pbr = material.pbrMetallicRoughness; const pbr = material.pbrMetallicRoughness;
expect(pbr.baseColorTexture).toBe(diffuseTextureCopy); expect(pbr.baseColorTexture).toBe(diffuseTexture);
expect(material.alphaMode).toBe('BLEND'); expect(material.alphaMode).toBe('BLEND');
expect(material.doubleSided).toBe(true); expect(material.doubleSided).toBe(true);
}); });
@ -433,18 +431,16 @@ describe('loadMtl', () => {
expect(material.doubleSided).toBe(true); expect(material.doubleSided).toBe(true);
}); });
it('uses diffuse texture if diffuse and alpha are the same', async () => { it('uses diffuse texture if diffuse and alpha are the same', () => {
options.specularGlossiness = true; options.specularGlossiness = true;
// The transparent property will be modified so make a copy
const diffuseTextureCopy = await loadTexture(diffuseTexturePath, decodeOptions);
const material = loadMtl._createMaterial({ const material = loadMtl._createMaterial({
diffuseTexture : diffuseTextureCopy, diffuseTexture : diffuseTexture,
alphaTexture : diffuseTexture alphaTexture : diffuseTexture
}, options); }, options);
const pbr = material.extensions.KHR_materials_pbrSpecularGlossiness; const pbr = material.extensions.KHR_materials_pbrSpecularGlossiness;
expect(pbr.diffuseTexture).toEqual(diffuseTextureCopy); expect(pbr.diffuseTexture).toEqual(diffuseTexture);
expect(material.alphaMode).toBe('BLEND'); expect(material.alphaMode).toBe('BLEND');
expect(material.doubleSided).toBe(true); expect(material.doubleSided).toBe(true);
}); });