Hi!
I’m currenty trying to experiment with Shader Graph custom funcion to create multiple Sphere Mask according to an array, but I’m running into an issue that the array might not get populated.
C#Script:
using UnityEngine;
public class shieldtest : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
public Vector4[] points;
public Material material;
void Start()
{
points = new Vector4[200];
}
// Update is called once per frame
void Update()
{
material.SetVectorArray("_ExampleArray", points);
}
}
Shader Graph Custom Function:
#ifndef MYHLSLINCLUDE_INCLUDED
#define MYHLSLINCLUDE_INCLUDED
float4 _ExampleArray[200];
void _Spehererre_float(float4 Center, float Hardness, out float sphereout)
{
for (int i=0;i<200;i++){
float4 _Spherecenter = float4(_ExampleArray[i][0], _ExampleArray[i][1], _ExampleArray[i][2], 1);
float _Radiusmeasure = _ExampleArray[i][3];
sphereout = 1 - saturate((distance(_Spherecenter, Center) - _Radiusmeasure) / (1 - Hardness));
}
}
#endif
Do you have any suggestion what can I try?