Created
September 27, 2018 12:58
-
-
Save jaycelq/3d9cd97baeb1e6d41f1f9ac5ac40559d to your computer and use it in GitHub Desktop.
[Interactive Grass Shader UserCase] #unity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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