iso2/effects/TerrainSuperBlendController.cs
public class TerrainSuperBlendController : Component, Component.ExecuteInEditor {
public struct Spot {
public Vector3 Position;
public float Radius;
public float Falloff;
public float Strength;
}
public static void Set(Scene scene, RenderAttributes target) {
SetForType(scene, target, "WarmSpots", typeof(Warmth));
SetForType(scene, target, "BlightSpots", typeof(Blight));
SetForType(scene, target, "RiverClearSpots", typeof(RiverClear));
}
private static void SetForType(Scene scene, RenderAttributes target, string dest, Type type) {
List<Spot> spots = new();
foreach (BaseSpot warmth in scene.GetAllComponents(type).Cast<BaseSpot>()) {
spots.Add(new() {
Position = warmth.WorldPosition,
Radius = warmth.Range,
Falloff = warmth.Falloff,
Strength = warmth.Strength,
});
}
if (spots.Count > 0) {
var gpuwarmspots = new GpuBuffer<Spot>(spots.Count);
gpuwarmspots.SetData(spots);
target.Set(dest, gpuwarmspots);
} else
target.Set(dest, new GpuBuffer<Spot>(1));
target.Set(dest+"Count", spots.Count);
}
}
public class BaseSpot : Component {
[Property, Range(0,1000)] public float Range {get; set;} = 400f;
[Property, Range(0,10)] public float Falloff {get; set;} = 1f;
[Property, Range(0,1)] public float Strength {get; set;} = 1f;
}