Exemplo n.º 1
0
 void ApplyForce(Vector2 position, Vector2 direction)
 {
     m_CommandBuffer.SetGlobalVector(Properties.Force, new Vector4(position.x, position.y, direction.x, direction.y));
     m_CommandBuffer.SetGlobalTexture(Properties.Buffer, m_VelocityBuffer.active);
     m_VelocityBuffer.Swap();
     Blit(m_VelocityBuffer.active, SolverPass.ApplyForce);
 }
Exemplo n.º 2
0
        private void ApplyImpulse(float dt)
        {
            m_applyImpulse.SetVector("_Size", m_size);
            m_applyImpulse.SetFloat("_Radius", m_inputRadius);
            m_applyImpulse.SetFloat("_DensityAmount", m_densityAmount);
            m_applyImpulse.SetFloat("_TemperatureAmount", m_temperatureAmount);
            m_applyImpulse.SetFloat("_DeltaTime", dt);
            m_applyImpulse.SetVector("_Pos", m_inputPos);

            m_applyImpulse.SetTexture(0, "_Read", m_atmosphere.Active);
            m_applyImpulse.SetTexture(0, "_Write", m_atmosphere.Inactive);

            m_applyImpulse.Dispatch(0, (int)m_size.x / (int)KernelThreadSize_X, (int)m_size.y / (int)KernelThreadSize_Y, (int)m_size.z / (int)KernelThreadSize_Z);

            m_atmosphere.Swap();
        }
Exemplo n.º 3
0
        private void ApplyBuoyancy(float dt)
        {
            m_applyBuoyancy.SetVector("_Size", m_size);
            m_applyBuoyancy.SetVector("_Up", new Vector4(0, 1, 0, 0));
            m_applyBuoyancy.SetFloat("_Buoyancy", m_densityBuoyancy);
            m_applyBuoyancy.SetFloat("_AmbientTemperature", m_ambientTemperature);
            m_applyBuoyancy.SetFloat("_Weight", m_densityWeight);
            m_applyBuoyancy.SetFloat("_DeltaTime", dt);

            m_applyBuoyancy.SetTexture(0, "_Write", m_velocity.Inactive);
            m_applyBuoyancy.SetTexture(0, "_Velocity", m_velocity.Active);
            m_applyBuoyancy.SetTexture(0, "_Atmosphere", m_atmosphere.Active);

            m_applyBuoyancy.Dispatch(0, (int)m_size.x / (int)KernelThreadSize_X, (int)m_size.y / (int)KernelThreadSize_Y, (int)m_size.z / (int)KernelThreadSize_Z);

            m_velocity.Swap();
        }
Exemplo n.º 4
0
 void Pressure()
 {
     m_CommandBuffer.SetGlobalFloat(Properties.PoissonAlphaCoefficient, -m_GridScale * m_GridScale * viscosity);
     m_CommandBuffer.SetGlobalTexture(Properties.Buffer2, m_DivergenceBuffer.active);
     m_CommandBuffer.SetGlobalTexture(Properties.Buffer, m_PressureBuffer.active);
     m_PressureBuffer.Swap();
     for (int i = 0; i < iterations; i++)
     {
         Blit(m_PressureBuffer.active, SolverPass.Pressure);
     }
 }
Exemplo n.º 5
0
        private void ComputePressure()
        {
            m_computeJacobi.SetVector("_Size", m_size);
            m_computeJacobi.SetTexture(0, "_Divergence", m_divergence.Active);
            m_computeJacobi.SetTexture(0, "_Obstacles", m_obstacles.Active);

            for (int i = 0; i < m_iterations; i++)
            {
                m_computeJacobi.SetTexture(0, "_Write", m_pressure.Inactive);
                m_computeJacobi.SetTexture(0, "_Pressure", m_pressure.Active);

                m_computeJacobi.Dispatch(0, (int)m_size.x / (int)KernelThreadSize_X, (int)m_size.y / (int)KernelThreadSize_Y, (int)m_size.z / (int)KernelThreadSize_Z);

                m_pressure.Swap();
            }
        }