Color Gradient
This commit is contained in:
@ -52,7 +52,7 @@ public class Fractal : MonoBehaviour
|
||||
|
||||
NativeArray<float3x4>[] matrices;
|
||||
|
||||
[SerializeField, Range(1, 8)]
|
||||
[SerializeField, Range(2, 8)]
|
||||
int depth = 4;
|
||||
|
||||
[SerializeField]
|
||||
@ -61,6 +61,9 @@ public class Fractal : MonoBehaviour
|
||||
[SerializeField]
|
||||
Material material = default;
|
||||
|
||||
[SerializeField]
|
||||
Gradient gradient = default;
|
||||
|
||||
static float3[] directions =
|
||||
{
|
||||
up(), right(), left(), forward(), back()
|
||||
@ -84,6 +87,7 @@ public class Fractal : MonoBehaviour
|
||||
|
||||
ComputeBuffer[] matricesBuffers;
|
||||
|
||||
static readonly int colorId = Shader.PropertyToID("_Color");
|
||||
static readonly int matricesId = Shader.PropertyToID("_Matrices");
|
||||
|
||||
static MaterialPropertyBlock propertyBlock;
|
||||
@ -177,6 +181,7 @@ public class Fractal : MonoBehaviour
|
||||
{
|
||||
ComputeBuffer buffer = matricesBuffers[i];
|
||||
buffer.SetData(matrices[i]);
|
||||
propertyBlock.SetColor(colorId, gradient.Evaluate(i / (matricesBuffers.Length - 1f)));
|
||||
propertyBlock.SetBuffer(matricesId, buffer);
|
||||
Graphics.DrawMeshInstancedProcedural(mesh, 0, material, bounds, buffer.count, propertyBlock);
|
||||
}
|
||||
|
Reference in New Issue
Block a user