diff options
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl | 12 | ||||
-rw-r--r-- | indra/newview/lldrawpoolpbropaque.cpp | 10 | ||||
-rw-r--r-- | indra/newview/llmaterialeditor.cpp | 2 |
3 files changed, 21 insertions, 3 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl index b5c38bba04..b0becdbb5b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl @@ -76,17 +76,23 @@ VARYING vec2 vary_texcoord1; VARYING vec2 vary_texcoord2; #endif +uniform float minimum_alpha; // PBR alphaMode: MASK, See: mAlphaCutoff, setAlphaCutoff() + vec2 encode_normal(vec3 n); vec3 linear_to_srgb(vec3 c); -const float M_PI = 3.141592653589793; - void main() { // IF .mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; // vec3 col = vertex_color.rgb * diffuseLookup(vary_texcoord0.xy).rgb; // else - vec3 col = vertex_color.rgb * texture2D(diffuseMap, vary_texcoord0.xy).rgb; + vec4 albedo = texture2D(diffuseMap, vary_texcoord0.xy).rgba; + if (albedo.a < minimum_alpha) + { + discard; + } + + vec3 col = vertex_color.rgb * albedo.rgb; #ifdef HAS_NORMAL_MAP vec4 norm = texture2D(bumpMap, vary_texcoord1.xy); diff --git a/indra/newview/lldrawpoolpbropaque.cpp b/indra/newview/lldrawpoolpbropaque.cpp index 3930e11cf3..9fc3d51cad 100644 --- a/indra/newview/lldrawpoolpbropaque.cpp +++ b/indra/newview/lldrawpoolpbropaque.cpp @@ -95,6 +95,16 @@ void LLDrawPoolPBROpaque::renderDeferred(S32 pass) for (LLCullResult::drawinfo_iterator i = begin; i != end; ++i) { LLDrawInfo* pparams = *i; + LLGLTFMaterial *mat = pparams->mGLTFMaterial; + + // glTF 2.0 Specification 3.9.4. Alpha Coverage + // mAlphaCutoff is only valid for LLGLTFMaterial::ALPHA_MODE_MASK + F32 min_alpha = -1.0; + if (mat->mAlphaMode == LLGLTFMaterial::ALPHA_MODE_MASK) + { + min_alpha = mat->mAlphaCutoff; + } + shader->uniform1f(LLShaderMgr::MINIMUM_ALPHA, min_alpha); if (pparams->mTexture.notNull()) { diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 5acf0600b6..6461aa71a6 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -1574,6 +1574,7 @@ void LLMaterialEditor::getGLTFMaterial(LLGLTFMaterial* mat) mat->mDoubleSided = getDoubleSided(); mat->setAlphaMode(getAlphaMode()); + mat->mAlphaCutoff = getAlphaCutoff(); } void LLMaterialEditor::setFromGLTFMaterial(LLGLTFMaterial* mat) @@ -1591,6 +1592,7 @@ void LLMaterialEditor::setFromGLTFMaterial(LLGLTFMaterial* mat) setDoubleSided(mat->mDoubleSided); setAlphaMode(mat->getAlphaMode()); + setAlphaCutoff(mat->mAlphaCutoff); } void LLMaterialEditor::loadAsset() |