diff --git a/Explorer/Assets/Protocol/DecentralandProtocol/Material.gen.cs b/Explorer/Assets/Protocol/DecentralandProtocol/Material.gen.cs
index 5a730df92f..90c927e6e0 100644
--- a/Explorer/Assets/Protocol/DecentralandProtocol/Material.gen.cs
+++ b/Explorer/Assets/Protocol/DecentralandProtocol/Material.gen.cs
@@ -27,46 +27,48 @@ static MaterialReflection() {
"CipkZWNlbnRyYWxhbmQvc2RrL2NvbXBvbmVudHMvbWF0ZXJpYWwucHJvdG8S",
"G2RlY2VudHJhbGFuZC5zZGsuY29tcG9uZW50cxogZGVjZW50cmFsYW5kL2Nv",
"bW1vbi9jb2xvcnMucHJvdG8aIWRlY2VudHJhbGFuZC9jb21tb24vdGV4dHVy",
- "ZS5wcm90byKGCwoKUEJNYXRlcmlhbBJGCgV1bmxpdBgBIAEoCzI1LmRlY2Vu",
+ "ZS5wcm90byLXCwoKUEJNYXRlcmlhbBJGCgV1bmxpdBgBIAEoCzI1LmRlY2Vu",
"dHJhbGFuZC5zZGsuY29tcG9uZW50cy5QQk1hdGVyaWFsLlVubGl0TWF0ZXJp",
"YWxIABJCCgNwYnIYAiABKAsyMy5kZWNlbnRyYWxhbmQuc2RrLmNvbXBvbmVu",
- "dHMuUEJNYXRlcmlhbC5QYnJNYXRlcmlhbEgAGvMBCg1VbmxpdE1hdGVyaWFs",
+ "dHMuUEJNYXRlcmlhbC5QYnJNYXRlcmlhbEgAGsQCCg1VbmxpdE1hdGVyaWFs",
"EjcKB3RleHR1cmUYASABKAsyIS5kZWNlbnRyYWxhbmQuY29tbW9uLlRleHR1",
"cmVVbmlvbkgAiAEBEhcKCmFscGhhX3Rlc3QYAiABKAJIAYgBARIZCgxjYXN0",
"X3NoYWRvd3MYAyABKAhIAogBARI3Cg1kaWZmdXNlX2NvbG9yGAQgASgLMhsu",
- "ZGVjZW50cmFsYW5kLmNvbW1vbi5Db2xvcjRIA4gBAUIKCghfdGV4dHVyZUIN",
- "CgtfYWxwaGFfdGVzdEIPCg1fY2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RvX2NvbG9yQhEKD19lbWlzc2l2ZV9jb2xvckIV",
+ "ChNfcmVmbGVjdGl2aXR5X2NvbG9yQhQKEl90cmFuc3BhcmVuY3lfbW9kZUIL",
+ "CglfbWV0YWxsaWNCDAoKX3JvdWdobmVzc0IVChNfc3BlY3VsYXJfaW50ZW5z",
+ "aXR5QhUKE19lbWlzc2l2ZV9pbnRlbnNpdHlCEwoRX2RpcmVjdF9pbnRlbnNp",
+ "dHlKBAgNEA5CCgoIbWF0ZXJpYWwqhQEKGE1hdGVyaWFsVHJhbnNwYXJlbmN5",
+ "TW9kZRIOCgpNVE1fT1BBUVVFEAASEgoOTVRNX0FMUEhBX1RFU1QQARITCg9N",
+ "VE1fQUxQSEFfQkxFTkQQAhIiCh5NVE1fQUxQSEFfVEVTVF9BTkRfQUxQSEFf",
+ "QkxFTkQQAxIMCghNVE1fQVVUTxAEQhSqAhFEQ0wuRUNTQ29tcG9uZW50c2IG",
+ "cHJvdG8z"));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Decentraland.Common.ColorsReflection.Descriptor, global::Decentraland.Common.TextureReflection.Descriptor, },
new pbr::GeneratedClrTypeInfo(new[] {typeof(global::DCL.ECSComponents.MaterialTransparencyMode), }, null, new pbr::GeneratedClrTypeInfo[] {
- new pbr::GeneratedClrTypeInfo(typeof(global::DCL.ECSComponents.PBMaterial), global::DCL.ECSComponents.PBMaterial.Parser, new[]{ "Unlit", "Pbr" }, new[]{ "Material" }, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::DCL.ECSComponents.PBMaterial.Types.UnlitMaterial), global::DCL.ECSComponents.PBMaterial.Types.UnlitMaterial.Parser, new[]{ "Texture", "AlphaTest", "CastShadows", "DiffuseColor" }, new[]{ "Texture", "AlphaTest", "CastShadows", "DiffuseColor" }, null, null, null),
+ new pbr::GeneratedClrTypeInfo(typeof(global::DCL.ECSComponents.PBMaterial), global::DCL.ECSComponents.PBMaterial.Parser, new[]{ "Unlit", "Pbr" }, new[]{ "Material" }, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::DCL.ECSComponents.PBMaterial.Types.UnlitMaterial), global::DCL.ECSComponents.PBMaterial.Types.UnlitMaterial.Parser, new[]{ "Texture", "AlphaTest", "CastShadows", "DiffuseColor", "AlphaTexture" }, new[]{ "Texture", "AlphaTest", "CastShadows", "DiffuseColor", "AlphaTexture" }, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::DCL.ECSComponents.PBMaterial.Types.PbrMaterial), global::DCL.ECSComponents.PBMaterial.Types.PbrMaterial.Parser, new[]{ "Texture", "AlphaTest", "CastShadows", "AlphaTexture", "EmissiveTexture", "BumpTexture", "AlbedoColor", "EmissiveColor", "ReflectivityColor", "TransparencyMode", "Metallic", "Roughness", "SpecularIntensity", "EmissiveIntensity", "DirectIntensity" }, new[]{ "Texture", "AlphaTest", "CastShadows", "AlphaTexture", "EmissiveTexture", "BumpTexture", "AlbedoColor", "EmissiveColor", "ReflectivityColor", "TransparencyMode", "Metallic", "Roughness", "SpecularIntensity", "EmissiveIntensity", "DirectIntensity" }, null, null, null)})
}));
}
@@ -413,6 +415,7 @@ public UnlitMaterial(UnlitMaterial other) : this() {
alphaTest_ = other.alphaTest_;
castShadows_ = other.castShadows_;
diffuseColor_ = other.diffuseColor_ != null ? other.diffuseColor_.Clone() : null;
+ alphaTexture_ = other.alphaTexture_ != null ? other.alphaTexture_.Clone() : null;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}
@@ -508,6 +511,21 @@ public void ClearCastShadows() {
}
}
+ /// Field number for the "alpha_texture" field.
+ public const int AlphaTextureFieldNumber = 5;
+ private global::Decentraland.Common.TextureUnion alphaTexture_;
+ ///
+ /// default = null
+ ///
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
+ [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
+ public global::Decentraland.Common.TextureUnion AlphaTexture {
+ get { return alphaTexture_; }
+ set {
+ alphaTexture_ = value;
+ }
+ }
+
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public override bool Equals(object other) {
@@ -527,6 +545,7 @@ public bool Equals(UnlitMaterial other) {
if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(AlphaTest, other.AlphaTest)) return false;
if (CastShadows != other.CastShadows) return false;
if (!object.Equals(DiffuseColor, other.DiffuseColor)) return false;
+ if (!object.Equals(AlphaTexture, other.AlphaTexture)) return false;
return Equals(_unknownFields, other._unknownFields);
}
@@ -538,6 +557,7 @@ public override int GetHashCode() {
if (HasAlphaTest) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(AlphaTest);
if (HasCastShadows) hash ^= CastShadows.GetHashCode();
if (diffuseColor_ != null) hash ^= DiffuseColor.GetHashCode();
+ if (alphaTexture_ != null) hash ^= AlphaTexture.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
@@ -572,6 +592,10 @@ public void WriteTo(pb::CodedOutputStream output) {
output.WriteRawTag(34);
output.WriteMessage(DiffuseColor);
}
+ if (alphaTexture_ != null) {
+ output.WriteRawTag(42);
+ output.WriteMessage(AlphaTexture);
+ }
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
@@ -598,6 +622,10 @@ public void WriteTo(pb::CodedOutputStream output) {
output.WriteRawTag(34);
output.WriteMessage(DiffuseColor);
}
+ if (alphaTexture_ != null) {
+ output.WriteRawTag(42);
+ output.WriteMessage(AlphaTexture);
+ }
if (_unknownFields != null) {
_unknownFields.WriteTo(ref output);
}
@@ -620,6 +648,9 @@ public int CalculateSize() {
if (diffuseColor_ != null) {
size += 1 + pb::CodedOutputStream.ComputeMessageSize(DiffuseColor);
}
+ if (alphaTexture_ != null) {
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(AlphaTexture);
+ }
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
@@ -650,6 +681,12 @@ public void MergeFrom(UnlitMaterial other) {
}
DiffuseColor.MergeFrom(other.DiffuseColor);
}
+ if (other.alphaTexture_ != null) {
+ if (alphaTexture_ == null) {
+ AlphaTexture = new global::Decentraland.Common.TextureUnion();
+ }
+ AlphaTexture.MergeFrom(other.AlphaTexture);
+ }
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}
@@ -687,6 +724,13 @@ public void MergeFrom(pb::CodedInputStream input) {
input.ReadMessage(DiffuseColor);
break;
}
+ case 42: {
+ if (alphaTexture_ == null) {
+ AlphaTexture = new global::Decentraland.Common.TextureUnion();
+ }
+ input.ReadMessage(AlphaTexture);
+ break;
+ }
}
}
#endif
@@ -724,6 +768,13 @@ public void MergeFrom(pb::CodedInputStream input) {
input.ReadMessage(DiffuseColor);
break;
}
+ case 42: {
+ if (alphaTexture_ == null) {
+ AlphaTexture = new global::Decentraland.Common.TextureUnion();
+ }
+ input.ReadMessage(AlphaTexture);
+ break;
+ }
}
}
}
@@ -866,7 +917,7 @@ public void ClearCastShadows() {
public const int AlphaTextureFieldNumber = 4;
private global::Decentraland.Common.TextureUnion alphaTexture_;
///
- /// default = null
+ /// @deprecated Alpha textures are no longer supported on PBRMaterial and UnlitMaterial.alphaTexture should be used instead.
///
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
diff --git a/Explorer/Assets/Scripts/ECS/Unity/Materials/Components/MaterialData.cs b/Explorer/Assets/Scripts/ECS/Unity/Materials/Components/MaterialData.cs
index 3e87210e37..8b8e1e5a42 100644
--- a/Explorer/Assets/Scripts/ECS/Unity/Materials/Components/MaterialData.cs
+++ b/Explorer/Assets/Scripts/ECS/Unity/Materials/Components/MaterialData.cs
@@ -82,11 +82,11 @@ internal MaterialData(bool isPbrMaterial, TextureComponent? albedoTexture, Textu
DirectIntensity = directIntensity;
}
- internal static MaterialData CreateBasicMaterial(TextureComponent? albedoTexture, float alphaTest, Color diffuseColor, bool castShadows)
+ internal static MaterialData CreateBasicMaterial(TextureComponent? albedoTexture, TextureComponent? alphaTexture, float alphaTest, Color diffuseColor, bool castShadows)
{
Color defaultColor = Color.white;
- return new MaterialData(false, albedoTexture, null, null, null,
+ return new MaterialData(false, albedoTexture, alphaTexture, null, null,
alphaTest, castShadows, defaultColor, diffuseColor, defaultColor, defaultColor, MaterialTransparencyMode.Auto,
0, 0, 0, 0, 0);
}
diff --git a/Explorer/Assets/Scripts/ECS/Unity/Materials/MaterialReference/BasicShapeMaterial.mat b/Explorer/Assets/Scripts/ECS/Unity/Materials/MaterialReference/BasicShapeMaterial.mat
index 4bff5200ae..24d5f542d6 100644
--- a/Explorer/Assets/Scripts/ECS/Unity/Materials/MaterialReference/BasicShapeMaterial.mat
+++ b/Explorer/Assets/Scripts/ECS/Unity/Materials/MaterialReference/BasicShapeMaterial.mat
@@ -8,7 +8,7 @@ Material:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: BasicShapeMaterial
- m_Shader: {fileID: 4800000, guid: 56a9743f8d94f684190dc11bb521fb78, type: 3}
+ m_Shader: {fileID: 4800000, guid: d77b7a7570974707a3c094386b19c6bc, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
@@ -17,12 +17,17 @@ Material:
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
- stringTagMap: {}
+ stringTagMap:
+ RenderType: Opaque
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
+ - _AlphaTexture:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
- _BaseMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
@@ -61,6 +66,7 @@ Material:
- _AlphaToMask: 0
- _Blend: 0
- _BlendModePreserveSpecular: 1
+ - _BlendOp: 0
- _BumpScale: 1
- _Cull: 2
- _CullYPlane: 0
@@ -93,6 +99,7 @@ Material:
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _PlaneClipping: {r: -2.1474836e+9, g: 2.1474836e+9, b: -2.1474836e+9, a: 2.1474836e+9}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
+ - _VerticalClipping: {r: -2.1474836e+9, g: 2.1474836e+9, b: 0, a: 0}
m_BuildTextureStacks: []
--- !u!114 &5218572137218344763
MonoBehaviour:
diff --git a/Explorer/Assets/Scripts/ECS/Unity/Materials/Systems/CreateBasicMaterialSystem.cs b/Explorer/Assets/Scripts/ECS/Unity/Materials/Systems/CreateBasicMaterialSystem.cs
index d6c941be7e..074763994d 100644
--- a/Explorer/Assets/Scripts/ECS/Unity/Materials/Systems/CreateBasicMaterialSystem.cs
+++ b/Explorer/Assets/Scripts/ECS/Unity/Materials/Systems/CreateBasicMaterialSystem.cs
@@ -6,6 +6,7 @@
using ECS.StreamableLoading.Common.Components;
using ECS.StreamableLoading.Textures;
using ECS.Unity.Materials.Components;
+using ECS.Unity.Textures.Components;
using UnityEngine;
using UnityEngine.Pool;
using UnityEngine.Rendering;
@@ -48,7 +49,8 @@ private void ConstructMaterial(ref MaterialComponent materialComponent)
// Check if all promises are finished
// Promises are finished if: all of their entities are invalid, no promises at all, or the result component exists
- if (TryGetTextureResult(ref materialComponent.AlbedoTexPromise, out StreamableLoadingResult albedoResult))
+ if (TryGetTextureResult(ref materialComponent.AlbedoTexPromise, out StreamableLoadingResult albedoResult) &&
+ TryGetTextureResult(ref materialComponent.AlphaTexPromise, out StreamableLoadingResult alphaResult))
{
materialComponent.Status = StreamableLoading.LifeCycle.LoadingFinished;
@@ -56,12 +58,71 @@ private void ConstructMaterial(ref MaterialComponent materialComponent)
SetUp(materialComponent.Result, materialComponent.Data.AlphaTest, materialComponent.Data.DiffuseColor);
+ SetUpTransparency(materialComponent.Result, materialComponent.Data.TransparencyMode, in materialComponent.Data.Textures.AlphaTexture, materialComponent.Data.AlbedoColor, materialComponent.Data.AlphaTest);
+
TrySetTexture(materialComponent.Result, ref albedoResult, ShaderUtils.BaseMap, in materialComponent.Data.Textures.AlbedoTexture);
+ TrySetTexture(materialComponent.Result, ref alphaResult, ShaderUtils.AlphaTexture, in materialComponent.Data.Textures.AlphaTexture);
DestroyEntityReference(ref materialComponent.AlbedoTexPromise);
}
}
+ public static void SetUpTransparency(Material material, MaterialTransparencyMode transparencyMode,
+ in TextureComponent? alphaTexture, Color albedoColor, float alphaTest)
+ {
+ transparencyMode.ResolveAutoMode(alphaTexture, albedoColor);
+
+ // ReSharper disable once SwitchStatementMissingSomeEnumCasesNoDefault
+ switch (transparencyMode)
+ {
+ case MaterialTransparencyMode.Opaque:
+ material.DisableKeyword("_ALPHATEST_ON"); // Cut Out Transparency
+ material.DisableKeyword("_ALPHABLEND_ON"); // Fade Transparency
+ material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); // Transparent
+
+ material.renderQueue = (int)RenderQueue.Geometry;
+ material.SetFloat(ShaderUtils.AlphaClip, 0);
+ break;
+ case MaterialTransparencyMode.AlphaTest: // ALPHATEST
+ material.EnableKeyword("_ALPHATEST_ON");
+ material.DisableKeyword("_ALPHABLEND_ON"); // Fade Transparency
+ material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); // Transparent
+
+ material.SetInt(ShaderUtils.SrcBlend, (int)BlendMode.One);
+ material.SetInt(ShaderUtils.DstBlend, (int)BlendMode.Zero);
+ material.SetInt(ShaderUtils.ZWrite, 1);
+ material.SetFloat(ShaderUtils.AlphaClip, 1);
+ material.SetFloat(ShaderUtils.Cutoff, alphaTest);
+ material.SetInt(ShaderUtils.Surface, 0);
+ material.renderQueue = (int)RenderQueue.AlphaTest;
+ break;
+ case MaterialTransparencyMode.AlphaBlend: // ALPHABLEND
+ material.DisableKeyword("_ALPHATEST_ON");
+ material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); // Transparent
+ material.EnableKeyword("_ALPHABLEND_ON");
+
+ material.SetInt(ShaderUtils.SrcBlend, (int)BlendMode.SrcAlpha);
+ material.SetInt(ShaderUtils.DstBlend, (int)BlendMode.OneMinusSrcAlpha);
+ material.SetInt(ShaderUtils.ZWrite, 0);
+ material.SetFloat(ShaderUtils.AlphaClip, 0);
+ material.renderQueue = (int)RenderQueue.Transparent;
+ material.SetInt(ShaderUtils.Surface, 1);
+ break;
+ case MaterialTransparencyMode.AlphaTestAndAlphaBlend:
+ material.DisableKeyword("_ALPHATEST_ON"); // Cut Out Transparency
+ material.DisableKeyword("_ALPHABLEND_ON"); // Fade Transparency
+ material.EnableKeyword("_ALPHAPREMULTIPLY_ON"); // Transparent
+
+ material.SetInt(ShaderUtils.SrcBlend, (int)BlendMode.One);
+ material.SetInt(ShaderUtils.DstBlend, (int)BlendMode.OneMinusSrcAlpha);
+ material.SetInt(ShaderUtils.ZWrite, 0);
+ material.SetFloat(ShaderUtils.AlphaClip, 1);
+ material.renderQueue = (int)RenderQueue.Transparent;
+ material.SetInt(ShaderUtils.Surface, 1);
+ break;
+ }
+ }
+
public static void SetUp(Material material, float alphaTest, Color diffuseColor)
{
material.EnableKeyword("_ALPHATEST_ON");
diff --git a/Explorer/Assets/Scripts/ECS/Unity/Materials/Systems/CreatePBRMaterialSystem.cs b/Explorer/Assets/Scripts/ECS/Unity/Materials/Systems/CreatePBRMaterialSystem.cs
index 21e74a3ecc..d92035a6d4 100644
--- a/Explorer/Assets/Scripts/ECS/Unity/Materials/Systems/CreatePBRMaterialSystem.cs
+++ b/Explorer/Assets/Scripts/ECS/Unity/Materials/Systems/CreatePBRMaterialSystem.cs
@@ -55,7 +55,6 @@ private void ConstructMaterial(Entity entity, ref MaterialComponent materialComp
if (TryGetTextureResult(ref materialComponent.AlbedoTexPromise, out StreamableLoadingResult albedoResult)
&& TryGetTextureResult(ref materialComponent.EmissiveTexPromise, out StreamableLoadingResult emissiveResult)
- && TryGetTextureResult(ref materialComponent.AlphaTexPromise, out StreamableLoadingResult alphaResult)
&& TryGetTextureResult(ref materialComponent.BumpTexPromise, out StreamableLoadingResult bumpResult))
{
materialComponent.Status = StreamableLoading.LifeCycle.LoadingFinished;
@@ -64,11 +63,10 @@ private void ConstructMaterial(Entity entity, ref MaterialComponent materialComp
SetUpColors(materialComponent.Result, materialComponent.Data.AlbedoColor, materialComponent.Data.EmissiveColor, materialComponent.Data.ReflectivityColor, materialComponent.Data.EmissiveIntensity);
SetUpProps(materialComponent.Result, materialComponent.Data.Metallic, materialComponent.Data.Roughness, materialComponent.Data.SpecularIntensity, materialComponent.Data.DirectIntensity);
- SetUpTransparency(materialComponent.Result, materialComponent.Data.TransparencyMode, in materialComponent.Data.Textures.AlphaTexture, materialComponent.Data.AlbedoColor, materialComponent.Data.AlphaTest);
+ SetUpTransparency(materialComponent.Result, materialComponent.Data.TransparencyMode, materialComponent.Data.AlbedoColor, materialComponent.Data.AlphaTest);
TrySetTexture(materialComponent.Result, ref albedoResult, ShaderUtils.BaseMap, in materialComponent.Data.Textures.AlbedoTexture);
TrySetTexture(materialComponent.Result, ref emissiveResult, ShaderUtils.EmissionMap, in materialComponent.Data.Textures.EmissiveTexture);
- TrySetTexture(materialComponent.Result, ref alphaResult, ShaderUtils.AlphaTexture, in materialComponent.Data.Textures.AlphaTexture);
TrySetTexture(materialComponent.Result, ref bumpResult, ShaderUtils.BumpMap, in materialComponent.Data.Textures.BumpTexture);
DestroyEntityReferencesForPromises(ref materialComponent);
@@ -98,10 +96,9 @@ public static void SetUpProps(Material material, float metallic, float roughness
material.SetFloat(ShaderUtils.SpecularHighlights, specularIntensity * directIntensity);
}
- public static void SetUpTransparency(Material material, MaterialTransparencyMode transparencyMode,
- in TextureComponent? alphaTexture, Color albedoColor, float alphaTest)
+ public static void SetUpTransparency(Material material, MaterialTransparencyMode transparencyMode, Color albedoColor, float alphaTest)
{
- transparencyMode.ResolveAutoMode(alphaTexture, albedoColor);
+ transparencyMode.ResolveAutoMode(null, albedoColor);
// ReSharper disable once SwitchStatementMissingSomeEnumCasesNoDefault
switch (transparencyMode)
diff --git a/Explorer/Assets/Scripts/ECS/Unity/Materials/Systems/StartMaterialsLoadingSystem.cs b/Explorer/Assets/Scripts/ECS/Unity/Materials/Systems/StartMaterialsLoadingSystem.cs
index d7fa63423e..3cefb86d95 100644
--- a/Explorer/Assets/Scripts/ECS/Unity/Materials/Systems/StartMaterialsLoadingSystem.cs
+++ b/Explorer/Assets/Scripts/ECS/Unity/Materials/Systems/StartMaterialsLoadingSystem.cs
@@ -115,7 +115,7 @@ private void CreateMaterialComponent(Entity entity, ref PBMaterial material, ref
private MaterialData CreateMaterialData(in PBMaterial material)
{
if (material.Unlit != null)
- return CreateBasicMaterialData(material, albedoTexture: material.Unlit.Texture.CreateTextureComponent(sceneData));
+ return CreateBasicMaterialData(material, albedoTexture: material.Unlit.Texture.CreateTextureComponent(sceneData), material.Unlit.AlphaTexture.CreateTextureComponent(sceneData));
TextureComponent? albedoTexture = material.Pbr.Texture.CreateTextureComponent(sceneData);
TextureComponent? alphaTexture = material.Pbr.AlphaTexture.CreateTextureComponent(sceneData);
@@ -160,10 +160,14 @@ private void CreateGetTexturePromises(ref MaterialComponent materialComponent,
TryCreateGetTexturePromise(in materialComponent.Data.Textures.EmissiveTexture, oldTexturesData?.EmissiveTexture, ref materialComponent.EmissiveTexPromise, partitionComponent);
TryCreateGetTexturePromise(in materialComponent.Data.Textures.BumpTexture, oldTexturesData?.BumpTexture, ref materialComponent.BumpTexPromise, partitionComponent);
}
+ else
+ {
+ TryCreateGetTexturePromise(in materialComponent.Data.Textures.AlphaTexture, oldTexturesData?.AlphaTexture, ref materialComponent.AlphaTexPromise, partitionComponent);
+ }
}
- private static MaterialData CreateBasicMaterialData(in PBMaterial pbMaterial, in TextureComponent? albedoTexture) =>
- MaterialData.CreateBasicMaterial(albedoTexture, pbMaterial.GetAlphaTest(), pbMaterial.GetDiffuseColor(), pbMaterial.GetCastShadows());
+ private static MaterialData CreateBasicMaterialData(in PBMaterial pbMaterial, in TextureComponent? albedoTexture, in TextureComponent? alphaTexture) =>
+ MaterialData.CreateBasicMaterial(albedoTexture, alphaTexture, pbMaterial.GetAlphaTest(), pbMaterial.GetDiffuseColor(), pbMaterial.GetCastShadows());
private bool TryCreateGetTexturePromise(in TextureComponent? textureComponent,
in TextureComponent? oldTextureComponent,
diff --git a/Explorer/Assets/Scripts/ECS/Unity/Materials/Tests/CreateBasicMaterialSystemShould.cs b/Explorer/Assets/Scripts/ECS/Unity/Materials/Tests/CreateBasicMaterialSystemShould.cs
index a2822082bd..74d398c1e3 100644
--- a/Explorer/Assets/Scripts/ECS/Unity/Materials/Tests/CreateBasicMaterialSystemShould.cs
+++ b/Explorer/Assets/Scripts/ECS/Unity/Materials/Tests/CreateBasicMaterialSystemShould.cs
@@ -81,7 +81,8 @@ private void CreateAndFinalizeTexturePromise(ref AssetPromise
new (MaterialData.CreateBasicMaterial(
- new TextureComponent("albedo", string.Empty, TextureWrapMode.Mirror, FilterMode.Point),
+ new TextureComponent("albedo",string.Empty, TextureWrapMode.Mirror, FilterMode.Point),
+ null,
0,
Color.red,
false));
diff --git a/Explorer/Assets/Scripts/ECS/Unity/Materials/Tests/LoadMaterialFromCacheSystemShould.cs b/Explorer/Assets/Scripts/ECS/Unity/Materials/Tests/LoadMaterialFromCacheSystemShould.cs
index 5f755c50d4..2bc5eb45b6 100644
--- a/Explorer/Assets/Scripts/ECS/Unity/Materials/Tests/LoadMaterialFromCacheSystemShould.cs
+++ b/Explorer/Assets/Scripts/ECS/Unity/Materials/Tests/LoadMaterialFromCacheSystemShould.cs
@@ -24,7 +24,8 @@ public void SetUp()
public void FinishLoadingIfPresentInCache()
{
var materialComponent = new MaterialComponent(MaterialData.CreateBasicMaterial(
- new TextureComponent("test-texture", "file-hash", TextureWrapMode.Mirror, FilterMode.Bilinear),
+ new TextureComponent("test-texture","file-hash", TextureWrapMode.Mirror, FilterMode.Bilinear),
+ null,
0.5f,
Color.red,
true));
@@ -54,7 +55,8 @@ public void FinishLoadingIfPresentInCache()
public void DoNothingIfLoadingStarted([Values(StreamableLoading.LifeCycle.LoadingInProgress, StreamableLoading.LifeCycle.LoadingFinished, StreamableLoading.LifeCycle.Applied)] StreamableLoading.LifeCycle status)
{
var materialComponent = new MaterialComponent(MaterialData.CreateBasicMaterial(
- new TextureComponent("test-texture", "file-hash", TextureWrapMode.Mirror, FilterMode.Bilinear),
+ new TextureComponent("test-texture","file-hash", TextureWrapMode.Mirror, FilterMode.Bilinear),
+ null,
0.5f,
Color.red,
true));
@@ -84,10 +86,10 @@ public void DoNothingIfLoadingStarted([Values(StreamableLoading.LifeCycle.Loadin
public void NotFinishLoadingIfNotPresentInCache()
{
var materialComponent = new MaterialComponent(MaterialData.CreatePBRMaterial(
- new TextureComponent("1", "file-hash", TextureWrapMode.Mirror, FilterMode.Bilinear),
- new TextureComponent("2", "file-hash", TextureWrapMode.MirrorOnce, FilterMode.Trilinear),
- new TextureComponent("3", "file-hash", TextureWrapMode.Repeat, FilterMode.Point),
- new TextureComponent("4", "file-hash", TextureWrapMode.Clamp, FilterMode.Point),
+ new TextureComponent("1","file-hash", TextureWrapMode.Mirror, FilterMode.Bilinear),
+ new TextureComponent("2","file-hash", TextureWrapMode.MirrorOnce, FilterMode.Trilinear),
+ new TextureComponent("3","file-hash", TextureWrapMode.Repeat, FilterMode.Point),
+ new TextureComponent("4","file-hash", TextureWrapMode.Clamp, FilterMode.Point),
0.5f,
true,
Color.red,
diff --git a/scripts/package-lock.json b/scripts/package-lock.json
index a99f36086d..09ba2bf708 100644
--- a/scripts/package-lock.json
+++ b/scripts/package-lock.json
@@ -9,7 +9,7 @@
"version": "1.0.0",
"license": "Apache-2.0",
"dependencies": {
- "@dcl/protocol": "^1.0.0-10955038136.commit-7fe9554",
+ "@dcl/protocol": "^1.0.0-11406954347.commit-ba19c4f",
"@protobuf-ts/protoc": "^2.8.2",
"@types/fs-extra": "^11.0.1",
"@types/glob": "^8.0.1",
@@ -36,9 +36,9 @@
}
},
"node_modules/@dcl/protocol": {
- "version": "1.0.0-10955038136.commit-7fe9554",
- "resolved": "https://registry.npmjs.org/@dcl/protocol/-/protocol-1.0.0-10955038136.commit-7fe9554.tgz",
- "integrity": "sha512-0BcRTJxFhxpX1k4oN8ErL+HiJYDmd98aDh6Kti54zoCph3SlJqkq0r1KshHAeMaXLSKNRtljjgkf4KkB8MriKA==",
+ "version": "1.0.0-11406954347.commit-ba19c4f",
+ "resolved": "https://registry.npmjs.org/@dcl/protocol/-/protocol-1.0.0-11406954347.commit-ba19c4f.tgz",
+ "integrity": "sha512-oMoq5IKAe1gout5SbP2w3Jq3Im+tbUiREW70BC+aVwwOly0YDtTWTZG9FyjeF36RDhyCg7z6jwtHL/rbWp0skw==",
"dependencies": {
"@dcl/ts-proto": "1.154.0"
}
@@ -569,9 +569,9 @@
}
},
"@dcl/protocol": {
- "version": "1.0.0-10955038136.commit-7fe9554",
- "resolved": "https://registry.npmjs.org/@dcl/protocol/-/protocol-1.0.0-10955038136.commit-7fe9554.tgz",
- "integrity": "sha512-0BcRTJxFhxpX1k4oN8ErL+HiJYDmd98aDh6Kti54zoCph3SlJqkq0r1KshHAeMaXLSKNRtljjgkf4KkB8MriKA==",
+ "version": "1.0.0-11406954347.commit-ba19c4f",
+ "resolved": "https://registry.npmjs.org/@dcl/protocol/-/protocol-1.0.0-11406954347.commit-ba19c4f.tgz",
+ "integrity": "sha512-oMoq5IKAe1gout5SbP2w3Jq3Im+tbUiREW70BC+aVwwOly0YDtTWTZG9FyjeF36RDhyCg7z6jwtHL/rbWp0skw==",
"requires": {
"@dcl/ts-proto": "1.154.0"
}
diff --git a/scripts/package.json b/scripts/package.json
index c4c5cb535f..5f97affe78 100644
--- a/scripts/package.json
+++ b/scripts/package.json
@@ -16,7 +16,7 @@
"typescript": "^4.2.3"
},
"dependencies": {
- "@dcl/protocol": "^1.0.0-10955038136.commit-7fe9554",
+ "@dcl/protocol": "^1.0.0-11406954347.commit-ba19c4f",
"@protobuf-ts/protoc": "^2.8.2",
"@types/fs-extra": "^11.0.1",
"@types/glob": "^8.0.1",