public void Draw(List <VRageRender.MyBillboard> collectedBillboards)
        {
            if (m_renderId == MyRenderProxy.RENDER_ID_UNASSIGNED)
            {
                m_renderId = MyRenderProxy.CreateGPUEmitter();
            }
            if (IsDirty)
            {
                MyGPUEmitter emitter = new MyGPUEmitter();
                FillData(ref emitter);
                MyParticlesManager.GPUEmitters.Add(emitter);

                m_dirty = false;
            }
            else if (m_effect.IsPositionDirty)
            {
                var transform = new MyGPUEmitterTransformUpdate()
                {
                    GID       = m_renderId,
                    Transform = CalculateWorldMatrix()
                };
                MyParticlesManager.GPUEmitterTransforms.Add(transform);

                m_positionDirty = false;
            }
        }
Esempio n. 2
0
        public void Start(MyParticleEffect effect)
        {
            System.Diagnostics.Debug.Assert(m_effect == null);
            System.Diagnostics.Debug.Assert(Life == null);

            m_effect   = effect;
            m_name     = "ParticleGeneration GPU";
            m_dirty    = true;
            m_renderId = MyRenderProxy.CreateGPUEmitter();
        }
        public void Draw(List <VRageRender.MyBillboard> collectedBillboards)
        {
            VRage.Profiler.ProfilerShort.Begin("GPU_Draw");
            if (m_renderId == MyRenderProxy.RENDER_ID_UNASSIGNED)
            {
                m_renderId = MyRenderProxy.CreateGPUEmitter();
            }

            if (IsDirty)
            {
                ProfilerShort.Begin("GPU_FillDataComplete");
                m_emitter = new MyGPUEmitter();
                FillDataComplete(ref m_emitter);
                MyParticlesManager.GPUEmitters.Add(m_emitter);
                ProfilerShort.End();
                m_dirty = m_animDirty = m_positionDirty = false;
            }
            else if (m_animatedTimeValues || m_animDirty)
            {
                ProfilerShort.Begin("GPU_FillData");
                FillData(ref m_emitter);
                MyParticlesManager.GPUEmitters.Add(m_emitter);
                ProfilerShort.End();
                m_animDirty = false;
            }
            else if (IsPositionDirty)
            {
                ProfilerShort.Begin("GPU_FillPosition");
                var transform = new MyGPUEmitterTransformUpdate()
                {
                    GID                = m_renderId,
                    Transform          = CalculateWorldMatrix(),
                    Scale              = m_effect.GetEmitterScale(),
                    Gravity            = m_effect.Gravity * Gravity,
                    ParticlesPerSecond = GetParticlesPerSecond()
                };
                MyParticlesManager.GPUEmitterTransforms.Add(transform);
                ProfilerShort.End();

                m_positionDirty = false;
            }
            else if (ParticlesPerSecond.GetKeysCount() > 1)
            {
                ProfilerShort.Begin("GPU_FillLight");
                MyParticlesManager.GPUEmittersLight.Add(new MyGPUEmitterLight()
                {
                    GID = m_renderId,
                    ParticlesPerSecond = GetParticlesPerSecond()
                });
                ProfilerShort.End();
            }
            ProfilerShort.End();
        }
Esempio n. 4
0
        public static void TestGPUParticles()
        {
            if (VRage.Input.MyInput.Static.IsAnyShiftKeyPressed())
            {
                if (gid0 == 0)
                {
                    gid0 = MyRenderProxy.CreateGPUEmitter();
                    gid1 = MyRenderProxy.CreateGPUEmitter();
                }
                var Position = MyTransparentGeometry.Camera.Translation;
                var emitters = new MyGPUEmitter[2];
                // sparks
                emitters[0].GID = gid0;
                emitters[0].ParticlesPerSecond = 30000.0f;
                emitters[0].Data.Color0        = new Vector4(1.0f, 1.0f, 0.0f, 1f);
                emitters[0].Data.Color1        = new Vector4(1.0f, 0.0f, 0.0f, 1f);
                emitters[0].Data.Color2        = new Vector4(1.0f, 0.0f, 0.0f, 0.0f);
                emitters[0].Data.ColorKey1     = 0.5f;
                emitters[0].Data.ColorKey2     = 1.0f;
                emitters[0].Data.AlphaKey1     = 0.95f;
                emitters[0].Data.AlphaKey2     = 1.0f;
                emitters[0].Data.Bounciness    = 0.4f;
                emitters[0].Data.Velocity      = new Vector3(0.0f, 0.0f, -1.0f);
                emitters[0].Data.NumParticlesToEmitThisFrame = 0;
                emitters[0].Data.ParticleLifeSpan            = 9.0f;
                emitters[0].Data.Size0                     = 0.02f;
                emitters[0].Data.Size1                     = 0.016f;
                emitters[0].Data.Size2                     = 0.0f;
                emitters[0].Data.SizeKeys1                 = 0.95f;
                emitters[0].Data.SizeKeys2                 = 1.0f;
                emitters[0].Data.PositionVariance          = new Vector3(0.1f, 0.1f, 0.1f);
                emitters[0].Data.VelocityVariance          = 0.4f;
                emitters[0].Data.RotationVelocity          = 0;
                emitters[0].Data.Acceleration              = new Vector3(0, 0, -0.98f);
                emitters[0].Data.StreakMultiplier          = 4.0f;
                emitters[0].Data.Flags                     = GPUEmitterFlags.Streaks | GPUEmitterFlags.Collide | GPUEmitterFlags.SleepState;
                emitters[0].Data.SoftParticleDistanceScale = 5;
                emitters[0].Data.AnimationFrameTime        = 1.0f;
                emitters[0].Data.OITWeightFactor           = 0.3f;
                emitters[0].AtlasTexture                   = "Textures\\Particles\\gpuAtlas0.dds";
                emitters[0].AtlasDimension                 = new Vector2I(2, 1);
                emitters[0].AtlasFrameOffset               = 1;
                emitters[0].AtlasFrameModulo               = 1;
                emitters[0].WorldPosition                  = Position + new Vector3D(8.0f, 0.0f, 8.0f);

                // smoke
                emitters[1].GID = gid1;
                emitters[1].ParticlesPerSecond = 100.0f;
                emitters[1].Data.Color0        = new Vector4(0.5f, 0.5f, 0.5f, 1.0f);
                emitters[1].Data.Color1        = new Vector4(0.6f, 0.6f, 0.65f, 1.0f);
                emitters[1].Data.Color2        = new Vector4(0.6f, 0.6f, 0.65f, 0.0f);
                emitters[1].Data.ColorKey1     = 0.5f;
                emitters[1].Data.ColorKey2     = 1.0f;
                emitters[1].Data.AlphaKey1     = 0.95f;
                emitters[1].Data.AlphaKey2     = 1.0f;
                emitters[1].Data.Velocity      = new Vector3(0, 0, 1.0f);
                emitters[1].Data.NumParticlesToEmitThisFrame = 0;
                emitters[1].Data.ParticleLifeSpan            = 150.0f;
                emitters[1].Data.Size0                     = 0.50f;
                emitters[1].Data.Size1                     = 2.2f;
                emitters[1].Data.SizeKeys1                 = 1.0f;
                emitters[1].Data.SizeKeys2                 = 1.0f;
                emitters[1].Data.PositionVariance          = new Vector3(0.2f, 0.2f, 0.2f);
                emitters[1].Data.VelocityVariance          = 0.3f;
                emitters[1].Data.RotationVelocity          = 100.0f;
                emitters[1].Data.Acceleration              = new Vector3(0.00707f, 0.00707f, -0.00003f * 9.8f);
                emitters[1].Data.Flags                     = GPUEmitterFlags.Light | GPUEmitterFlags.VolumetricLight;
                emitters[1].Data.SoftParticleDistanceScale = 2;
                emitters[1].Data.AnimationFrameTime        = 1.0f;
                emitters[1].Data.OITWeightFactor           = 1.0f;
                emitters[1].AtlasTexture                   = "Textures\\Particles\\gpuAtlas1.dds";
                emitters[1].AtlasDimension                 = new Vector2I(2, 1);
                emitters[1].AtlasFrameOffset               = 0;
                emitters[1].AtlasFrameModulo               = 1;
                emitters[1].WorldPosition                  = Position + new Vector3D(2.0f, 0.0f, 1.0f);
                MyRenderProxy.UpdateGPUEmitters(emitters);
            }
        }