Posts

Showing posts with the label instances

compute shader with skinned mesh flocking instances

This is v. similar to the previous flocking post, only now we use a skinned & animated mesh & it's attached Animator component. Something to note, one instance of the prefab has to be in the scene, or it doesn't work (move it off camera or something). Also - the material that uses the surface shader , must have the GPU instancing enabled! That's what those if-checks are for! The gist of this is - we need to store the vertex animation into another buffer. The compute shader doesn't deal with this data at all - it is only concerned with the position/direction of each instance. It is the surface/vert-frag shader that will deal with it. The only bit the compute shader does increment is the "frame" of animation, which is determined by the speed at which the boid is moving.    C# SCRIPT using System.Collections; using System.Collections.Generic; using UnityEngine; public class SkinnedFlocking : MonoBehaviour {     public struct Boid     {  ...