Skip to content

Instantly share code, notes, and snippets.

@jaycelq
Created September 27, 2018 12:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaycelq/3d9cd97baeb1e6d41f1f9ac5ac40559d to your computer and use it in GitHub Desktop.
Save jaycelq/3d9cd97baeb1e6d41f1f9ac5ac40559d to your computer and use it in GitHub Desktop.
[Interactive Grass Shader UserCase] #unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class InteractionHolder : MonoBehaviour {
[SerializeField]
GameObject[] objects;
Vector4[] positions = new Vector4[100];
// Update is called once per frame
void Update () {
for (int i = 0; i < objects.Length; i++)
{
positions[i] = objects[i].transform.position;
}
Shader.SetGlobalFloat("_PositionArray", objects.Length);
Shader.SetGlobalVectorArray("_Positions", positions);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment