I want to use custom enums inside a shader. How can I achieve this?
In the chat @tonfilm said:
I’ve tried this now and it doesn’t seem to work.
Folder structure looks like this:
📂ShaderEnums
┣ 📂lib
┃ ┗ 📂net6.0
┃ ┗ 📜EffectEnums.dll
┣ 📂src
┃ ┣ 📂EffectEnums
┃ ┃ ┣ 📜EffectEnums.cs
┃ ┃ ┗ 📜EffectEnums.csproj
┃ ┗ 📜EffectEnums.sln
┗ 📂vl
┣ 📂shaders
┃ ┗📜EnumTest_TextureFX.sdsl
┗ 📜EnumTrial.vl
The enum is defined like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VL.Stride.Effects.TextureFX
{
public enum SomeColor
{
Black,
White,
Red,
Green,
Blue
};
}
And forwarded by EnumTrial.vl.
The shader looks like this:
[TextureSource]
[Category("Source")]
[Summary("For testing custom enum")]
shader EnumTest_TextureFX : TextureFX
{
[EnumType("VL.Stride.Effects.TextureFX.SomeColor")]
int Color;
stage override float4 Shading()
{
float4 col = 0;
switch((uint)Color%3)
{
case 0 : col = 0; break;
case 1 : col = 1; break;
case 2 : col = float4(1.0, 0.0, 0.0, 0.0); break;
}
return col;
}
};
Still the input is of type Int32 in the patch:
ShaderEnums.7z (28.4 KB)