Exemplo n.º 1
0
        public TCParticlesBoidsFlock(ParticleManager system, ParticleForceManager force, ComputeShader computeShader)
        {
            m_system        = system;
            m_computeShader = computeShader;
            m_force         = force;

            m_posSumBuffer      = new ComputeBuffer(system.MaxParticles, 12);
            m_velocitySumBuffer = new ComputeBuffer(system.MaxParticles, 12);

            m_tempPosBuffer      = new ComputeBuffer(system.MaxParticles, 12);
            m_tempVelocityBuffer = new ComputeBuffer(system.MaxParticles, 12);

            m_sumKernel  = computeShader.FindKernel("BoidsFlockSum");
            m_initKernel = computeShader.FindKernel("BoidsFlockInit");

            m_updateBoidsKernel = computeShader.FindKernel("BoidsFlockUpdate");
        }
Exemplo n.º 2
0
        public void Awake(ParticleEmitter emitter, ParticleColliderManager colliderManager, ParticleRenderer renderer,
                          ParticleForceManager forceManager, ParticleManager system)
        {
            //reference all components for easy acess

            PartEmitter     = emitter;
            ColliderManager = colliderManager;
            Renderer        = renderer;
            ForceManager    = forceManager;
            Manager         = system;

            //Load the compute shader reference
            if (system.ComputeShader == null)
            {
                ComputeShader = Resources.Load("MassParticle") as ComputeShader;
            }

            ComputeShader = system.ComputeShader;

            if (ComputeShader == null)
            {
                Debug.LogError("Failed to load compute shader!");
                return;
            }

            //find all kernels for quick acces.
            UpdateAllKernel = ComputeShader.FindKernel("UpdateAll");
            EmitKernel      = ComputeShader.FindKernel("Emit");
            ClearKernel     = ComputeShader.FindKernel("Clear");

            UpdateForcesKernel           = ComputeShader.FindKernel("UpdateForces");
            UpdateTurbulenceForcesKernel = ComputeShader.FindKernel("UpdateTurbulenceForces");

            UpdateCollidersKernel = ComputeShader.FindKernel("UpdateColliders");
            Transform             = SystemComp.transform;
        }