mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 10:07:58 +02:00
Trying to clen up the way the opacity final value comes to the fragment shader
This commit is contained in:
parent
f7847f6561
commit
227ddb12a6
10 changed files with 76 additions and 37 deletions
|
@ -51,7 +51,7 @@ void Material::setEmissive(const Color& emissive, bool isSRGB) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Material::setOpacity(float opacity) {
|
void Material::setOpacity(float opacity) {
|
||||||
_key.setTransparentFactor((opacity < 1.0f));
|
_key.setTranslucentFactor((opacity < 1.0f));
|
||||||
_schemaBuffer.edit<Schema>()._key = (uint32)_key._flags.to_ulong();
|
_schemaBuffer.edit<Schema>()._key = (uint32)_key._flags.to_ulong();
|
||||||
_schemaBuffer.edit<Schema>()._opacity = opacity;
|
_schemaBuffer.edit<Schema>()._opacity = opacity;
|
||||||
}
|
}
|
||||||
|
@ -94,10 +94,10 @@ void Material::setTextureMap(MapChannel channel, const TextureMapPointer& textur
|
||||||
// Texture has alpha, is nut just a mask or a true transparent channel
|
// Texture has alpha, is nut just a mask or a true transparent channel
|
||||||
if (!usage.isAlphaMask()) {
|
if (!usage.isAlphaMask()) {
|
||||||
_key.setOpacityMaskMap(true);
|
_key.setOpacityMaskMap(true);
|
||||||
_key.setTransparentMap(false);
|
_key.setTranslucentMap(false);
|
||||||
} else {
|
} else {
|
||||||
_key.setOpacityMaskMap(false);
|
_key.setOpacityMaskMap(false);
|
||||||
_key.setTransparentMap(true);
|
_key.setTranslucentMap(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ void Material::setTextureMap(MapChannel channel, const TextureMapPointer& textur
|
||||||
|
|
||||||
if (channel == MaterialKey::ALBEDO_MAP) {
|
if (channel == MaterialKey::ALBEDO_MAP) {
|
||||||
_key.setOpacityMaskMap(false);
|
_key.setOpacityMaskMap(false);
|
||||||
_key.setTransparentMap(false);
|
_key.setTranslucentMap(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
_schemaBuffer.edit<Schema>()._key = (uint32)_key._flags.to_ulong();
|
_schemaBuffer.edit<Schema>()._key = (uint32)_key._flags.to_ulong();
|
||||||
|
|
|
@ -76,14 +76,14 @@ public:
|
||||||
Builder& withAlbedo() { _flags.set(ALBEDO_VAL_BIT); return (*this); }
|
Builder& withAlbedo() { _flags.set(ALBEDO_VAL_BIT); return (*this); }
|
||||||
Builder& withMetallic() { _flags.set(METALLIC_VAL_BIT); return (*this); }
|
Builder& withMetallic() { _flags.set(METALLIC_VAL_BIT); return (*this); }
|
||||||
Builder& withGlossy() { _flags.set(GLOSSY_VAL_BIT); return (*this); }
|
Builder& withGlossy() { _flags.set(GLOSSY_VAL_BIT); return (*this); }
|
||||||
Builder& withOpacity() { _flags.set(OPACITY_VAL_BIT); return (*this); }
|
Builder& withTranslucentFactor() { _flags.set(OPACITY_VAL_BIT); return (*this); }
|
||||||
|
|
||||||
Builder& withEmissiveMap() { _flags.set(EMISSIVE_MAP_BIT); return (*this); }
|
Builder& withEmissiveMap() { _flags.set(EMISSIVE_MAP_BIT); return (*this); }
|
||||||
Builder& withAlbedoMap() { _flags.set(ALBEDO_MAP_BIT); return (*this); }
|
Builder& withAlbedoMap() { _flags.set(ALBEDO_MAP_BIT); return (*this); }
|
||||||
Builder& withMetallicMap() { _flags.set(METALLIC_MAP_BIT); return (*this); }
|
Builder& withMetallicMap() { _flags.set(METALLIC_MAP_BIT); return (*this); }
|
||||||
Builder& withRoughnessMap() { _flags.set(ROUGHNESS_MAP_BIT); return (*this); }
|
Builder& withRoughnessMap() { _flags.set(ROUGHNESS_MAP_BIT); return (*this); }
|
||||||
|
|
||||||
Builder& withTransparentMap() { _flags.set(OPACITY_TRANSLUCENT_MAP_BIT); return (*this); }
|
Builder& withTranslucentMap() { _flags.set(OPACITY_TRANSLUCENT_MAP_BIT); return (*this); }
|
||||||
Builder& withMaskMap() { _flags.set(OPACITY_MASK_MAP_BIT); return (*this); }
|
Builder& withMaskMap() { _flags.set(OPACITY_MASK_MAP_BIT); return (*this); }
|
||||||
|
|
||||||
Builder& withNormalMap() { _flags.set(NORMAL_MAP_BIT); return (*this); }
|
Builder& withNormalMap() { _flags.set(NORMAL_MAP_BIT); return (*this); }
|
||||||
|
@ -122,8 +122,8 @@ public:
|
||||||
void setTranslucentFactor(bool value) { _flags.set(OPACITY_VAL_BIT, value); }
|
void setTranslucentFactor(bool value) { _flags.set(OPACITY_VAL_BIT, value); }
|
||||||
bool isTranslucentFactor() const { return _flags[OPACITY_VAL_BIT]; }
|
bool isTranslucentFactor() const { return _flags[OPACITY_VAL_BIT]; }
|
||||||
|
|
||||||
void setTransparentMap(bool value) { _flags.set(OPACITY_TRANSLUCENT_MAP_BIT, value); }
|
void setTranslucentMap(bool value) { _flags.set(OPACITY_TRANSLUCENT_MAP_BIT, value); }
|
||||||
bool isOpacityMap() const { return _flags[OPACITY_TRANSLUCENT_MAP_BIT]; }
|
bool isTranslucentMap() const { return _flags[OPACITY_TRANSLUCENT_MAP_BIT]; }
|
||||||
|
|
||||||
void setOpacityMaskMap(bool value) { _flags.set(OPACITY_MASK_MAP_BIT, value); }
|
void setOpacityMaskMap(bool value) { _flags.set(OPACITY_MASK_MAP_BIT, value); }
|
||||||
bool isOpacityMaskMap() const { return _flags[OPACITY_MASK_MAP_BIT]; }
|
bool isOpacityMaskMap() const { return _flags[OPACITY_MASK_MAP_BIT]; }
|
||||||
|
@ -140,6 +140,12 @@ public:
|
||||||
void setMapChannel(MapChannel channel, bool value) { _flags.set(EMISSIVE_MAP_BIT + channel, value); }
|
void setMapChannel(MapChannel channel, bool value) { _flags.set(EMISSIVE_MAP_BIT + channel, value); }
|
||||||
bool isMapChannel(MapChannel channel) const { return _flags[EMISSIVE_MAP_BIT + channel]; }
|
bool isMapChannel(MapChannel channel) const { return _flags[EMISSIVE_MAP_BIT + channel]; }
|
||||||
|
|
||||||
|
|
||||||
|
// Translucency and Opacity Heuristics are combining several flags:
|
||||||
|
bool isTranslucent() const { return isTranslucentFactor() || isTranslucentMap(); }
|
||||||
|
bool isOpaque() const { return !isTranslucent(); }
|
||||||
|
bool isSurfaceOpaque() const { return isOpaque() && !isOpacityMaskMap(); }
|
||||||
|
bool isTexelOpaque() const { return isOpaque() && isOpacityMaskMap(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -183,12 +189,11 @@ public:
|
||||||
Builder& withoutRoughnessMap() { _value.reset(MaterialKey::ROUGHNESS_MAP_BIT); _mask.set(MaterialKey::ROUGHNESS_MAP_BIT); return (*this); }
|
Builder& withoutRoughnessMap() { _value.reset(MaterialKey::ROUGHNESS_MAP_BIT); _mask.set(MaterialKey::ROUGHNESS_MAP_BIT); return (*this); }
|
||||||
Builder& withRoughnessMap() { _value.set(MaterialKey::ROUGHNESS_MAP_BIT); _mask.set(MaterialKey::ROUGHNESS_MAP_BIT); return (*this); }
|
Builder& withRoughnessMap() { _value.set(MaterialKey::ROUGHNESS_MAP_BIT); _mask.set(MaterialKey::ROUGHNESS_MAP_BIT); return (*this); }
|
||||||
|
|
||||||
Builder& withoutTransparentFactor() { _value.reset(MaterialKey::OPACITY_VAL_BIT); _mask.set(MaterialKey::OPACITY_VAL_BIT); return (*this); }
|
Builder& withoutTranslucentFactor() { _value.reset(MaterialKey::OPACITY_VAL_BIT); _mask.set(MaterialKey::OPACITY_VAL_BIT); return (*this); }
|
||||||
Builder& withTransparentFactor() { _value.set(MaterialKey::OPACITY_VAL_BIT); _mask.set(MaterialKey::OPACITY_VAL_BIT); return (*this); }
|
Builder& withTranslucentFactor() { _value.set(MaterialKey::OPACITY_VAL_BIT); _mask.set(MaterialKey::OPACITY_VAL_BIT); return (*this); }
|
||||||
Builder& withOpaqueFactor() { return withoutTransparentFactor(); }
|
|
||||||
|
|
||||||
Builder& withoutTransparentMap() { _value.reset(MaterialKey::OPACITY_TRANSLUCENT_MAP_BIT); _mask.set(MaterialKey::OPACITY_TRANSLUCENT_MAP_BIT); return (*this); }
|
Builder& withoutTranslucentMap() { _value.reset(MaterialKey::OPACITY_TRANSLUCENT_MAP_BIT); _mask.set(MaterialKey::OPACITY_TRANSLUCENT_MAP_BIT); return (*this); }
|
||||||
Builder& withTransparentMap() { _value.set(MaterialKey::OPACITY_TRANSLUCENT_MAP_BIT); _mask.set(MaterialKey::OPACITY_TRANSLUCENT_MAP_BIT); return (*this); }
|
Builder& withTranslucentMap() { _value.set(MaterialKey::OPACITY_TRANSLUCENT_MAP_BIT); _mask.set(MaterialKey::OPACITY_TRANSLUCENT_MAP_BIT); return (*this); }
|
||||||
|
|
||||||
Builder& withoutMaskMap() { _value.reset(MaterialKey::OPACITY_MASK_MAP_BIT); _mask.set(MaterialKey::OPACITY_MASK_MAP_BIT); return (*this); }
|
Builder& withoutMaskMap() { _value.reset(MaterialKey::OPACITY_MASK_MAP_BIT); _mask.set(MaterialKey::OPACITY_MASK_MAP_BIT); return (*this); }
|
||||||
Builder& withMaskMap() { _value.set(MaterialKey::OPACITY_MASK_MAP_BIT); _mask.set(MaterialKey::OPACITY_MASK_MAP_BIT); return (*this); }
|
Builder& withMaskMap() { _value.set(MaterialKey::OPACITY_MASK_MAP_BIT); _mask.set(MaterialKey::OPACITY_MASK_MAP_BIT); return (*this); }
|
||||||
|
@ -203,7 +208,7 @@ public:
|
||||||
Builder& withLightmapMap() { _value.set(MaterialKey::LIGHTMAP_MAP_BIT); _mask.set(MaterialKey::LIGHTMAP_MAP_BIT); return (*this); }
|
Builder& withLightmapMap() { _value.set(MaterialKey::LIGHTMAP_MAP_BIT); _mask.set(MaterialKey::LIGHTMAP_MAP_BIT); return (*this); }
|
||||||
|
|
||||||
// Convenient standard keys that we will keep on using all over the place
|
// Convenient standard keys that we will keep on using all over the place
|
||||||
static MaterialFilter opaqueAlbedo() { return Builder().withAlbedo().withOpaqueFactor().build(); }
|
static MaterialFilter opaqueAlbedo() { return Builder().withAlbedo().withoutTranslucentFactor().build(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Item Filter operator testing if a key pass the filter
|
// Item Filter operator testing if a key pass the filter
|
||||||
|
|
|
@ -43,17 +43,17 @@ const int EMISSIVE_VAL_BIT = 0x00000001;
|
||||||
const int ALBEDO_VAL_BIT = 0x00000002;
|
const int ALBEDO_VAL_BIT = 0x00000002;
|
||||||
const int METALLIC_VAL_BIT = 0x00000004;
|
const int METALLIC_VAL_BIT = 0x00000004;
|
||||||
const int GLOSSY_VAL_BIT = 0x00000008;
|
const int GLOSSY_VAL_BIT = 0x00000008;
|
||||||
const int TRANSPARENT_VAL_BIT = 0x00000010;
|
const int OPACITY_VAL_BIT = 0x00000010;
|
||||||
const int TRANSPARENT_TEX_VAL_BIT = 0x00000020;
|
|
||||||
|
|
||||||
const int EMISSIVE_MAP_BIT = 0x00000040;
|
const int EMISSIVE_MAP_BIT = 0x00000020;
|
||||||
const int ALBEDO_MAP_BIT = 0x00000080;
|
const int ALBEDO_MAP_BIT = 0x00000040;
|
||||||
const int METALLIC_MAP_BIT = 0x00000100;
|
const int OPACITY_MASK_MAP_BIT = 0x00000080;
|
||||||
const int ROUGHNESS_MAP_BIT = 0x00000200;
|
const int OPACITY_TRANSLUCENT_MAP_BIT = 0x00000100;
|
||||||
const int TRANSPARENT_MAP_BIT = 0x00000400;
|
const int METALLIC_MAP_BIT = 0x00000200;
|
||||||
const int NORMAL_MAP_BIT = 0x00000800;
|
const int ROUGHNESS_MAP_BIT = 0x00000400;
|
||||||
const int OCCLUSION_MAP_BIT = 0x00001000;
|
const int NORMAL_MAP_BIT = 0x00001000;
|
||||||
|
const int OCCLUSION_MAP_BIT = 0x00002000;
|
||||||
|
const int LIGHTMAP_MAP_BIT = 0x00004000;
|
||||||
|
|
||||||
const int LIGHTMAP_MAP_BIT = 0x00002000;
|
|
||||||
|
|
||||||
<@endif@>
|
<@endif@>
|
||||||
|
|
|
@ -59,7 +59,7 @@ float fetchOcclusionMap(vec2 uv) {
|
||||||
|
|
||||||
<@func fetchMaterialTextures(matKey, texcoord0, albedo, roughness, normal, metallic, emissive, occlusion)@>
|
<@func fetchMaterialTextures(matKey, texcoord0, albedo, roughness, normal, metallic, emissive, occlusion)@>
|
||||||
<@if albedo@>
|
<@if albedo@>
|
||||||
vec4 <$albedo$> = (((<$matKey$> & ALBEDO_MAP_BIT) != 0) ? fetchAlbedoMap(<$texcoord0$>) : vec4(1.0));
|
vec4 <$albedo$> = (((<$matKey$> & (ALBEDO_MAP_BIT | OPACITY_MASK_MAP_BIT | OPACITY_TRANSLUCENT_MAP_BIT)) != 0) ? fetchAlbedoMap(<$texcoord0$>) : vec4(1.0));
|
||||||
<@endif@>
|
<@endif@>
|
||||||
<@if roughness@>
|
<@if roughness@>
|
||||||
float <$roughness$> = (((<$matKey$> & ROUGHNESS_MAP_BIT) != 0) ? fetchRoughnessMap(<$texcoord0$>) : 1.0);
|
float <$roughness$> = (((<$matKey$> & ROUGHNESS_MAP_BIT) != 0) ? fetchRoughnessMap(<$texcoord0$>) : 1.0);
|
||||||
|
@ -112,6 +112,23 @@ vec3 fetchLightmapMap(vec2 uv) {
|
||||||
}
|
}
|
||||||
<@endfunc@>
|
<@endfunc@>
|
||||||
|
|
||||||
|
<@func evalMaterialOpacity(fetchedOpacity, materialOpacity, matKey, opacity)@>
|
||||||
|
{
|
||||||
|
const float OPACITY_MASK_THRESHOLD = 0.5;
|
||||||
|
<$opacity$> = (((<$matKey$> & (OPACITY_TRANSLUCENCY_MAP_BIT | OPACITY_MASK_MAP_BIT)) != 0) ?
|
||||||
|
(((<$matKey$> & OPACITY_MASK_MAP_BIT) != 0) ? step(OPACITY_MASK_THRESHOLD, <$fetchedOpacity$>) : <$fetchedOpacity$>) :
|
||||||
|
1.0) * <$materialOpacity$>;
|
||||||
|
}
|
||||||
|
<@endfunc@>
|
||||||
|
|
||||||
|
<@func $discardTransparent(opacity)@>
|
||||||
|
{
|
||||||
|
if (<$opacity$> < 1.0) {
|
||||||
|
discard;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<@endfunc@>
|
||||||
|
|
||||||
<@func evalMaterialRoughness(fetchedRoughness, materialRoughness, matKey, roughness)@>
|
<@func evalMaterialRoughness(fetchedRoughness, materialRoughness, matKey, roughness)@>
|
||||||
{
|
{
|
||||||
<$roughness$> = (((<$matKey$> & ROUGHNESS_MAP_BIT) != 0) ? <$fetchedRoughness$> : <$materialRoughness$>);
|
<$roughness$> = (((<$matKey$> & ROUGHNESS_MAP_BIT) != 0) ? <$fetchedRoughness$> : <$materialRoughness$>);
|
||||||
|
|
|
@ -81,7 +81,7 @@ ItemKey MeshPartPayload::getKey() const {
|
||||||
|
|
||||||
if (_drawMaterial) {
|
if (_drawMaterial) {
|
||||||
auto matKey = _drawMaterial->getKey();
|
auto matKey = _drawMaterial->getKey();
|
||||||
if (matKey.isTransparentFactor() || matKey.isTransparentMap()) {
|
if (matKey.isTranslucentFactor() || matKey.isTranslucentMap()) {
|
||||||
builder.withTransparent();
|
builder.withTransparent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ ShapeKey MeshPartPayload::getShapeKey() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
ShapeKey::Builder builder;
|
ShapeKey::Builder builder;
|
||||||
if (drawMaterialKey.isTransparentFactor() || drawMaterialKey.isTransparentMap()) {
|
if (drawMaterialKey.isTranslucent()) {
|
||||||
builder.withTranslucent();
|
builder.withTranslucent();
|
||||||
}
|
}
|
||||||
if (drawMaterialKey.isNormalMap()) {
|
if (drawMaterialKey.isNormalMap()) {
|
||||||
|
@ -365,7 +365,7 @@ ItemKey ModelMeshPartPayload::getKey() const {
|
||||||
|
|
||||||
if (_drawMaterial) {
|
if (_drawMaterial) {
|
||||||
auto matKey = _drawMaterial->getKey();
|
auto matKey = _drawMaterial->getKey();
|
||||||
if (matKey.isTransparentFactor() || matKey.isTransparentMap()) {
|
if (matKey.isTranslucent()) {
|
||||||
builder.withTransparent();
|
builder.withTransparent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -412,8 +412,7 @@ ShapeKey ModelMeshPartPayload::getShapeKey() const {
|
||||||
drawMaterialKey = _drawMaterial->getKey();
|
drawMaterialKey = _drawMaterial->getKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isTranslucent =
|
bool isTranslucent = drawMaterialKey.isTranslucent();
|
||||||
drawMaterialKey.isTransparentFactor() || drawMaterialKey.isTransparentMap();
|
|
||||||
bool hasTangents = drawMaterialKey.isNormalMap() && !mesh.tangents.isEmpty();
|
bool hasTangents = drawMaterialKey.isNormalMap() && !mesh.tangents.isEmpty();
|
||||||
bool hasSpecular = drawMaterialKey.isMetallicMap();
|
bool hasSpecular = drawMaterialKey.isMetallicMap();
|
||||||
bool hasLightmap = drawMaterialKey.isLightmapMap();
|
bool hasLightmap = drawMaterialKey.isLightmapMap();
|
||||||
|
|
|
@ -29,6 +29,10 @@ void main(void) {
|
||||||
int matKey = getMaterialKey(mat);
|
int matKey = getMaterialKey(mat);
|
||||||
<$fetchMaterialTextures(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex, occlusionTex)$>
|
<$fetchMaterialTextures(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex, occlusionTex)$>
|
||||||
|
|
||||||
|
float opacity = 1.0;
|
||||||
|
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)&>;
|
||||||
|
<$discardTransparent(opacity)$>;
|
||||||
|
|
||||||
vec3 albedo = getMaterialAlbedo(mat);
|
vec3 albedo = getMaterialAlbedo(mat);
|
||||||
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
||||||
albedo *= _color;
|
albedo *= _color;
|
||||||
|
@ -41,7 +45,7 @@ void main(void) {
|
||||||
|
|
||||||
packDeferredFragment(
|
packDeferredFragment(
|
||||||
normalize(_normal.xyz),
|
normalize(_normal.xyz),
|
||||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedoTex.a),
|
opacity,
|
||||||
albedo,
|
albedo,
|
||||||
roughness,
|
roughness,
|
||||||
getMaterialMetallic(mat),
|
getMaterialMetallic(mat),
|
||||||
|
|
|
@ -30,6 +30,10 @@ void main(void) {
|
||||||
int matKey = getMaterialKey(mat);
|
int matKey = getMaterialKey(mat);
|
||||||
<$fetchMaterialTextures(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, _SCRIBE_NULL, emissiveTex, occlusionTex)$>
|
<$fetchMaterialTextures(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, _SCRIBE_NULL, emissiveTex, occlusionTex)$>
|
||||||
|
|
||||||
|
float opacity = 1.0;
|
||||||
|
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)&>;
|
||||||
|
<$discardTransparent(opacity)$>;
|
||||||
|
|
||||||
vec3 albedo = getMaterialAlbedo(mat);
|
vec3 albedo = getMaterialAlbedo(mat);
|
||||||
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
||||||
albedo *= _color;
|
albedo *= _color;
|
||||||
|
@ -45,7 +49,7 @@ void main(void) {
|
||||||
|
|
||||||
packDeferredFragment(
|
packDeferredFragment(
|
||||||
viewNormal,
|
viewNormal,
|
||||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedoTex.a),
|
opacity,
|
||||||
albedo,
|
albedo,
|
||||||
roughness,
|
roughness,
|
||||||
getMaterialMetallic(mat),
|
getMaterialMetallic(mat),
|
||||||
|
|
|
@ -30,6 +30,10 @@ void main(void) {
|
||||||
int matKey = getMaterialKey(mat);
|
int matKey = getMaterialKey(mat);
|
||||||
<$fetchMaterialTextures(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex, occlusionTex)$>
|
<$fetchMaterialTextures(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex, occlusionTex)$>
|
||||||
|
|
||||||
|
float opacity = 1.0;
|
||||||
|
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)&>;
|
||||||
|
<$discardTransparent(opacity)$>;
|
||||||
|
|
||||||
vec3 albedo = getMaterialAlbedo(mat);
|
vec3 albedo = getMaterialAlbedo(mat);
|
||||||
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
||||||
albedo *= _color;
|
albedo *= _color;
|
||||||
|
@ -49,7 +53,7 @@ void main(void) {
|
||||||
|
|
||||||
packDeferredFragment(
|
packDeferredFragment(
|
||||||
normalize(viewNormal.xyz),
|
normalize(viewNormal.xyz),
|
||||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedoTex.a),
|
opacity,
|
||||||
albedo,
|
albedo,
|
||||||
roughness,
|
roughness,
|
||||||
metallic,
|
metallic,
|
||||||
|
|
|
@ -30,6 +30,10 @@ void main(void) {
|
||||||
int matKey = getMaterialKey(mat);
|
int matKey = getMaterialKey(mat);
|
||||||
<$fetchMaterialTextures(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex, occlusionTex)$>
|
<$fetchMaterialTextures(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex, occlusionTex)$>
|
||||||
|
|
||||||
|
float opacity = 1.0;
|
||||||
|
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)&>;
|
||||||
|
<$discardTransparent(opacity)$>;
|
||||||
|
|
||||||
vec3 albedo = getMaterialAlbedo(mat);
|
vec3 albedo = getMaterialAlbedo(mat);
|
||||||
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
||||||
albedo *= _color;
|
albedo *= _color;
|
||||||
|
@ -45,7 +49,7 @@ void main(void) {
|
||||||
|
|
||||||
packDeferredFragment(
|
packDeferredFragment(
|
||||||
normalize(_normal),
|
normalize(_normal),
|
||||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedoTex.a),
|
opacity,
|
||||||
albedo,
|
albedo,
|
||||||
roughness,
|
roughness,
|
||||||
metallic,
|
metallic,
|
||||||
|
|
|
@ -36,6 +36,10 @@ void main(void) {
|
||||||
int matKey = getMaterialKey(mat);
|
int matKey = getMaterialKey(mat);
|
||||||
<$fetchMaterialTextures(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex, occlusionTex)$>
|
<$fetchMaterialTextures(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex, occlusionTex)$>
|
||||||
|
|
||||||
|
float opacity = getMaterialOpacity(mat) * _alpha;
|
||||||
|
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)&>;
|
||||||
|
<$discardTransparent(opacity)$>;
|
||||||
|
|
||||||
vec3 albedo = getMaterialAlbedo(mat);
|
vec3 albedo = getMaterialAlbedo(mat);
|
||||||
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
||||||
albedo *= _color;
|
albedo *= _color;
|
||||||
|
@ -52,8 +56,6 @@ void main(void) {
|
||||||
vec3 fragPosition = _position.xyz;
|
vec3 fragPosition = _position.xyz;
|
||||||
vec3 fragNormal = normalize(_normal);
|
vec3 fragNormal = normalize(_normal);
|
||||||
|
|
||||||
float fragOpacity = getMaterialOpacity(mat) * albedoTex.a * _alpha;
|
|
||||||
|
|
||||||
TransformCamera cam = getTransformCamera();
|
TransformCamera cam = getTransformCamera();
|
||||||
|
|
||||||
_fragColor = vec4(evalAmbientSphereGlobalColor(
|
_fragColor = vec4(evalAmbientSphereGlobalColor(
|
||||||
|
@ -66,5 +68,5 @@ void main(void) {
|
||||||
metallic,
|
metallic,
|
||||||
emissive,
|
emissive,
|
||||||
roughness),
|
roughness),
|
||||||
fragOpacity);
|
opacity);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue