Skip to content

Commit

Permalink
Do not compile different shader for opacity of 1 and diffuse tint of …
Browse files Browse the repository at this point in the history
…white (#6721)

Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
  • Loading branch information
mvaligursky and Martin Valigursky committed Jun 19, 2024
1 parent 6440d84 commit 1d09168
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/scene/materials/standard-material-options-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class StandardMaterialOptionsBuilder {
}

_updateMinOptions(options, stdMat, pass) {
options.opacityTint = stdMat.opacity !== 1 && (stdMat.blendType !== BLEND_NONE || stdMat.opacityShadowDither !== DITHER_NONE);
options.opacityTint = stdMat.blendType !== BLEND_NONE || stdMat.opacityShadowDither !== DITHER_NONE;

// pre-pass uses the same dither setting as forward pass, otherwise shadow dither
const isPrepass = pass === SHADER_PREPASS_VELOCITY;
Expand All @@ -194,8 +194,7 @@ class StandardMaterialOptionsBuilder {
}

_updateMaterialOptions(options, stdMat) {
const diffuseTint = (stdMat.diffuseTint || (!stdMat.diffuseMap && !stdMat.diffuseVertexColor)) &&
notWhite(stdMat.diffuse);
const diffuseTint = (stdMat.diffuseTint || (!stdMat.diffuseMap && !stdMat.diffuseVertexColor));

const useSpecular = !!(stdMat.useMetalness || stdMat.specularMap || stdMat.sphereMap || stdMat.cubeMap ||
notBlack(stdMat.specular) || (stdMat.specularityFactor > 0 && stdMat.useMetalness) ||
Expand All @@ -215,7 +214,7 @@ class StandardMaterialOptionsBuilder {

const isPackedNormalMap = stdMat.normalMap ? (stdMat.normalMap.format === PIXELFORMAT_DXT5 || stdMat.normalMap.type === TEXTURETYPE_SWIZZLEGGGR) : false;

options.opacityTint = (stdMat.opacity !== 1 && (stdMat.blendType !== BLEND_NONE || stdMat.alphaTest > 0 || stdMat.opacityDither !== DITHER_NONE)) ? 1 : 0;
options.opacityTint = (stdMat.blendType !== BLEND_NONE || stdMat.alphaTest > 0 || stdMat.opacityDither !== DITHER_NONE) ? 1 : 0;
options.ambientTint = stdMat.ambientTint;
options.diffuseTint = diffuseTint ? 2 : 0;
options.specularTint = specularTint ? 2 : 0;
Expand Down

0 comments on commit 1d09168

Please sign in to comment.