Fix bug when using material instance of material that uses GlobalSDF

This commit is contained in:
Wojtek Figat
2023-04-12 16:59:03 +02:00
parent 609217a3bb
commit abf68328e6
4 changed files with 5 additions and 190 deletions

View File

@@ -95,6 +95,7 @@ namespace FlaxEditor.Surface
case MaterialParameterType.ChannelMask: return typeof(ChannelMask);
case MaterialParameterType.GameplayGlobal: return typeof(GameplayGlobals);
case MaterialParameterType.TextureGroupSampler: return typeof(int);
case MaterialParameterType.GlobalSDF: return typeof(object);
default: throw new ArgumentOutOfRangeException(nameof(type), type, null);
}
}

View File

@@ -1,110 +0,0 @@
// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
namespace FlaxEngine
{
/// <summary>
/// Material parameters types.
/// </summary>
public enum MaterialParameterType : byte
{
/// <summary>
/// The invalid type.
/// </summary>
Invalid = 0,
/// <summary>
/// The bool.
/// </summary>
Bool = 1,
/// <summary>
/// The integer.
/// </summary>
Integer = 2,
/// <summary>
/// The float.
/// </summary>
Float = 3,
/// <summary>
/// The vector2
/// </summary>
Vector2 = 4,
/// <summary>
/// The vector3.
/// </summary>
Vector3 = 5,
/// <summary>
/// The vector4.
/// </summary>
Vector4 = 6,
/// <summary>
/// The color.
/// </summary>
Color = 7,
/// <summary>
/// The texture.
/// </summary>
Texture = 8,
/// <summary>
/// The cube texture.
/// </summary>
CubeTexture = 9,
/// <summary>
/// The normal map texture.
/// </summary>
NormalMap = 10,
/// <summary>
/// The scene texture.
/// </summary>
SceneTexture = 11,
/// <summary>
/// The GPU texture (created from code).
/// </summary>
GPUTexture = 12,
/// <summary>
/// The matrix.
/// </summary>
Matrix = 13,
/// <summary>
/// The GPU texture array (created from code).
/// </summary>
GPUTextureArray = 14,
/// <summary>
/// The GPU volume texture (created from code).
/// </summary>
GPUTextureVolume = 15,
/// <summary>
/// The GPU cube texture (created from code).
/// </summary>
GPUTextureCube = 16,
/// <summary>
/// The RGBA channel selection mask.
/// </summary>
ChannelMask = 17,
/// <summary>
/// The gameplay global.
/// </summary>
GameplayGlobal = 18,
/// <summary>
/// The texture sampler derived from texture group settings.
/// </summary>
TextureGroupSampler = 19,
}
}

View File

@@ -12,6 +12,7 @@
#include "Engine/Graphics/GPUDevice.h"
#include "Engine/Graphics/RenderTask.h"
#include "Engine/Renderer/GlobalSignDistanceFieldPass.h"
#include "Engine/Scripting/Enums.h"
#include "Engine/Streaming/Streaming.h"
bool MaterialInfo8::operator==(const MaterialInfo8& other) const
@@ -127,81 +128,6 @@ bool MaterialInfo::operator==(const MaterialInfo& other) const
&& MaxTessellationFactor == other.MaxTessellationFactor;
}
const Char* ToString(MaterialParameterType value)
{
const Char* result;
switch (value)
{
case MaterialParameterType::Invalid:
result = TEXT("Invalid");
break;
case MaterialParameterType::Bool:
result = TEXT("Bool");
break;
case MaterialParameterType::Integer:
result = TEXT("Integer");
break;
case MaterialParameterType::Float:
result = TEXT("Float");
break;
case MaterialParameterType::Vector2:
result = TEXT("Vector2");
break;
case MaterialParameterType::Vector3:
result = TEXT("Vector3");
break;
case MaterialParameterType::Vector4:
result = TEXT("Vector4");
break;
case MaterialParameterType::Color:
result = TEXT("Color");
break;
case MaterialParameterType::Texture:
result = TEXT("Texture");
break;
case MaterialParameterType::CubeTexture:
result = TEXT("CubeTexture");
break;
case MaterialParameterType::NormalMap:
result = TEXT("NormalMap");
break;
case MaterialParameterType::SceneTexture:
result = TEXT("SceneTexture");
break;
case MaterialParameterType::GPUTexture:
result = TEXT("GPUTexture");
break;
case MaterialParameterType::Matrix:
result = TEXT("Matrix");
break;
case MaterialParameterType::GPUTextureArray:
result = TEXT("GPUTextureArray");
break;
case MaterialParameterType::GPUTextureVolume:
result = TEXT("GPUTextureVolume");
break;
case MaterialParameterType::GPUTextureCube:
result = TEXT("GPUTextureCube");
break;
case MaterialParameterType::ChannelMask:
result = TEXT("ChannelMask");
break;
case MaterialParameterType::GameplayGlobal:
result = TEXT("GameplayGlobal");
break;
case MaterialParameterType::TextureGroupSampler:
result = TEXT("TextureGroupSampler");
break;
case MaterialParameterType::GlobalSDF:
result = TEXT("GlobalSDF");
break;
default:
result = TEXT("");
break;
}
return result;
}
Variant MaterialParameter::GetValue() const
{
switch (_type)
@@ -347,7 +273,7 @@ void MaterialParameter::SetValue(const Variant& value)
}
if (invalidType)
{
LOG(Error, "Invalid material parameter value type {0} to set (param type: {1})", value.Type, ::ToString(_type));
LOG(Error, "Invalid material parameter value type {0} to set (param type: {1})", value.Type, ScriptingEnum::ToString<MaterialParameterType>(_type));
}
}
@@ -604,7 +530,7 @@ bool MaterialParameter::operator==(const MaterialParameter& other) const
String MaterialParameter::ToString() const
{
return String::Format(TEXT("\'{0}\' ({1}:{2}:{3})"), _name, ::ToString(_type), _paramId, _isPublic);
return String::Format(TEXT("\'{0}\' ({1}:{2}:{3})"), _name, ScriptingEnum::ToString<MaterialParameterType>(_type), _paramId, _isPublic);
}
MaterialParameter* MaterialParams::Get(const Guid& id)

View File

@@ -27,7 +27,7 @@ struct MaterialParamsLink
/// <summary>
/// The material parameter types.
/// </summary>
enum class MaterialParameterType : byte
API_ENUM() enum class MaterialParameterType : byte
{
/// <summary>
/// The invalid type.
@@ -135,8 +135,6 @@ enum class MaterialParameterType : byte
GlobalSDF = 20,
};
const Char* ToString(MaterialParameterType value);
/// <summary>
/// Structure of serialized material parameter data.
/// </summary>