Rasagar/Assets/ProceduralTerrainPainter/Runtime/Modifiers/TextureMask.cs

30 lines
810 B
C#
Raw Permalink Normal View History

2024-08-26 13:07:20 -07:00
using UnityEngine;
namespace sc.terrain.proceduralpainter
{
[System.Serializable]
public class TextureMask : Modifier
{
public Texture2D texture;
[Attributes.ChannelPicker]
public int channel;
[Tooltip("Spans the texture across all terrains")]
public bool spanTerrains;
public float tiling = 1f;
public void OnEnable()
{
passIndex = FilterPass.TextureMask;
}
public override void Configure(Material material)
{
base.Configure(material);
material.SetTexture("_MaskTexture", texture);
material.SetVector("_TilingParams", new Vector4(tiling, spanTerrains ? 1 : 0, 0f, 0f));
material.SetInt("_Channel", channel);
}
}
}