put back stepping in translucent case

This commit is contained in:
HifiExperiments 2019-11-24 12:44:42 -08:00
parent 5371fd613a
commit f55c4b8b12
2 changed files with 9 additions and 4 deletions

View file

@ -223,10 +223,13 @@ vec3 fetchLightMap(vec2 uv) {
}
<@endfunc@>
<@func evalMaterialOpacity(fetchedOpacity, materialOpacity, opacity)@>
<@func evalMaterialOpacity(fetchedOpacity, materialOpacityCutoff, materialOpacity, matKey, opacity)@>
{
// This path only valid for transparent material
<$opacity$> = <$materialOpacity$> * <$fetchedOpacity$>;
<$opacity$> = mix(<$fetchedOpacity$>,
step(<$materialOpacityCutoff$>, <$fetchedOpacity$>),
float((<$matKey$> & OPACITY_MASK_MAP_BIT) != 0))
* <$materialOpacity$>;
}
<@endfunc@>

View file

@ -103,8 +103,9 @@ void main(void) {
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$>
<@if HIFI_USE_TRANSLUCENT@>
float cutoff = getMaterialOpacityCutoff(mat);
float opacity = getMaterialOpacity(mat) * _color.a;
<$evalMaterialOpacity(albedoTex.a, opacity, opacity)$>;
<$evalMaterialOpacity(albedoTex.a, cutoff, opacity, matKey, opacity)$>;
<$discardInvisible(opacity)$>;
<@else@>
float cutoff = getMaterialOpacityCutoff(mat);
@ -154,8 +155,9 @@ void main(void) {
<@endif@>
<@if HIFI_USE_TRANSLUCENT@>
float cutoff = getMaterialOpacityCutoff(mat);
float opacity = getMaterialOpacity(mat) * _color.a;
<$evalMaterialOpacity(albedoTex.a, opacity, opacity)$>;
<$evalMaterialOpacity(albedoTex.a, cutoff, opacity, matKey, opacity)$>;
<$discardInvisible(opacity)$>;
<@else@>
float cutoff = getMaterialOpacityCutoff(mat);