40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
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 ) );
|
|
}
|
|
}
|
|
}
|