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 )
|
|
|
|
{
|
2025-09-26 12:00:59 +00:00
|
|
|
|
|
|
|
uvSource.uniformGroup = uniformGroup;
|
|
|
|
modifier.uniformGroup = uniformGroup;
|
|
|
|
|
2025-09-21 07:35:17 +00:00
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
2025-09-26 12:00:59 +00:00
|
|
|
if ( ShaderPhase.Variables == context.phase && ! ( uvTarget == "UV" || uvTarget == "UV2" ) )
|
|
|
|
{
|
|
|
|
list.Add( ToCode( VaryingVec2( uvTarget ) + "\n" ) );
|
|
|
|
}
|
|
|
|
|
2025-09-21 07:35:17 +00:00
|
|
|
return list;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|