Skip to content

Commit f058442

Browse files
[Rendering] Minor fix to material default textures;
1 parent 9224524 commit f058442

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

Engine/Staple.Core/Rendering/Material.cs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -858,15 +858,22 @@ public void SetTexture(string name, Texture value)
858858
{
859859
if (parameter.type == MaterialParameterType.Texture)
860860
{
861-
if(value == null && (parameter.shaderHandle.DefaultValue?.Length ?? 0) > 0)
861+
if(value == null)
862862
{
863-
if(parameter.shaderHandle.DefaultValue == WhiteTexture.Guid.Guid)
863+
if(string.IsNullOrEmpty(parameter.shaderHandle.DefaultValue) == false)
864864
{
865-
value = WhiteTexture;
865+
if (parameter.shaderHandle.DefaultValue == WhiteTexture.Guid.Guid)
866+
{
867+
value = WhiteTexture;
868+
}
869+
else
870+
{
871+
value = ResourceManager.instance.LoadTexture(parameter.shaderHandle.DefaultValue);
872+
}
866873
}
867874
else
868875
{
869-
value = ResourceManager.instance.LoadTexture(parameter.shaderHandle.DefaultValue);
876+
value = WhiteTexture;
870877
}
871878
}
872879

@@ -878,15 +885,22 @@ public void SetTexture(string name, Texture value)
878885
{
879886
var handle = shader.GetUniformHandle(hash);
880887

881-
if (value == null && (handle.DefaultValue?.Length ?? 0) > 0)
888+
if (value == null)
882889
{
883-
if (handle.DefaultValue == WhiteTexture.Guid.Guid)
890+
if (string.IsNullOrEmpty(parameter.shaderHandle.DefaultValue) == false)
884891
{
885-
value = WhiteTexture;
892+
if (parameter.shaderHandle.DefaultValue == WhiteTexture.Guid.Guid)
893+
{
894+
value = WhiteTexture;
895+
}
896+
else
897+
{
898+
value = ResourceManager.instance.LoadTexture(parameter.shaderHandle.DefaultValue);
899+
}
886900
}
887901
else
888902
{
889-
value = ResourceManager.instance.LoadTexture(handle.DefaultValue);
903+
value = WhiteTexture;
890904
}
891905
}
892906

0 commit comments

Comments
 (0)