rokojori_action_library/Runtime/Procedural/HeightMaps/Shaders/HeightMapRibbonMaterial.cs

40 lines
1.1 KiB
C#
Raw Normal View History

2026-11-12 14:28:42 +00:00
using Godot;
using System;
using Rokojori.Extensions;
namespace Rokojori
{
public class HeightMapRibbonShader
{
public static readonly CachedResource<Shader> shader = new CachedResource<Shader>(
"res://addons/rokojori_action_library/Runtime/Procedural/HeightMaps/Shaders/HeightMapRibbon.gdshader"
);
public static readonly Vector4PropertyName region = Vector4PropertyName.Create( "ribbon_region" );
}
/** Material for HeightMapRibbon.gdshader.
One per ribbon rather than one shared, because the region clip has to be
per ribbon - see the shader. Everything else the pass writes comes off the
mesh's own vertex attributes.
*/
[Tool]
public partial class HeightMapRibbonMaterial:CustomMaterial
{
public readonly CustomMaterialProperty<Vector4> region;
public HeightMapRibbonMaterial()
{
Shader = HeightMapRibbonShader.shader.Get();
region = new CustomMaterialProperty<Vector4>( this, HeightMapRibbonShader.region );
}
public void SetRegion( Rect2I rect )
{
region.Set( new Vector4( rect.Position.X, rect.Position.Y, rect.Size.X, rect.Size.Y ) );
}
}
}