rj-action-library/Runtime/Shading/Generators/Spatial/UV/UVChannel.cs

46 lines
926 B
C#
Raw Normal View History

2025-09-21 07:35:17 +00:00
using Godot;
using System.Reflection;
using System.Collections.Generic;
namespace Rokojori
{
[Tool]
[GlobalClass]
public partial class UVChannel:ShaderGenerationModule
{
[Export]
public string uvTarget = "UV";
[Export]
public UVSource uvSource = new MeshUVSource();
[Export]
public UVModifier modifier = new UVScaleOffset();
public List<ShaderCode> GetShaderCode( ShaderGenerationContext context )
{
var sourceCode = uvSource.GetUV( context, uvTarget, 0 );
var modifierCode = modifier.ModifyUV( context, uvTarget );
if ( sourceCode == null && modifierCode == null )
{
return null;
}
var list = new List<ShaderCode>();
if ( sourceCode != null )
{
list.AddRange( sourceCode );
}
if ( modifierCode != null )
{
list.AddRange( modifierCode );
}
return list;
}
}
}