46 lines
926 B
C#
46 lines
926 B
C#
![]() |
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;
|
||
|
}
|
||
|
}
|
||
|
}
|