Example #1
0
        /*Shader*/
        void drawTexture(Texture texture, float opacity)
        {
            _screenShader.SetTexture("d_screen", texture);
            _Device.SetSamplerState(0, SamplerState.AddressU, TextureAddress.Clamp);
            _Device.SetSamplerState(0, SamplerState.AddressV, TextureAddress.Clamp);
            _Device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Point);
            _Device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Point);

            _screenShader.SetValue("d_opacity", _particles.Fade);
            // patch pour directx 9, ne pas avoir se code en open gl es
            _screenShader.SetValue("d_miPixX", -0.5f / texture.GetLevelDescription(0).Width);
            _screenShader.SetValue("d_miPixY", -0.5f / texture.GetLevelDescription(0).Height);
            _screenShader.Begin();
            _screenShader.BeginPass(0);
            UtilDraw.drawInQuad(_Device);
            _screenShader.EndPass();
            _screenShader.End();
        }
Example #2
0
        private void updateParticles()
        {
            int             particleRes = _particles.getParticleStateResolution();
            RenderToSurface rts         = new RenderToSurface(_Device, particleRes, particleRes, _stateParticleTexture1.GetLevelDescription(0).Format);
            Surface         surface     = _stateParticleTexture1.GetSurfaceLevel(0);

            rts.BeginScene(surface, new SharpDX.Viewport(0, 0, particleRes, particleRes, 0, 1));

            /*set parametres shader*/
            _updateParticleShader.SetTexture("d_wind", _windTexture);
            _Device.SetSamplerState(0, SamplerState.AddressU, TextureAddress.Clamp);
            _Device.SetSamplerState(0, SamplerState.AddressV, TextureAddress.Clamp);
            _Device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Linear);
            _Device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Linear);

            _updateParticleShader.SetTexture("d_particles", _stateParticleTexture0);
            _Device.SetSamplerState(1, SamplerState.AddressU, TextureAddress.Clamp);
            _Device.SetSamplerState(1, SamplerState.AddressV, TextureAddress.Clamp);
            _Device.SetSamplerState(1, SamplerState.MinFilter, TextureFilter.Point);
            _Device.SetSamplerState(1, SamplerState.MagFilter, TextureFilter.Point);

            //parametros JSON
            _updateParticleShader.SetValue("d_rand_seed", (float)new Random().NextDouble());
            _updateParticleShader.SetValue("d_wind_resolution", new float[] { _windData.width, _windData.height });
            _updateParticleShader.SetValue("d_wind_min", new float[] { _windData.uMin, _windData.vMin });
            _updateParticleShader.SetValue("d_wind_max", new float[] { _windData.uMax, _windData.vMax });
            _updateParticleShader.SetValue("d_particles_res", particleRes);
            _updateParticleShader.SetValue("d_particles_min", min_range);
            _updateParticleShader.SetValue("d_particles_max", max_range);

            //parametros Menu
            _updateParticleShader.SetValue("d_speed_factor", _particles.SpeedFactor);

            //correction texture inverse
            _updateParticleShader.SetValue("d_miPixX", -0.5f / _stateParticleTexture0.GetLevelDescription(0).Width);
            _updateParticleShader.SetValue("d_miPixY", -0.5f / _stateParticleTexture0.GetLevelDescription(0).Height);

            if (_particles.IsWave)
            {
                _updateParticleShader.Technique = "Wave";
            }
            else
            {
                _updateParticleShader.Technique = "Default";
            }

            /************************/
            _updateParticleShader.SetValue("d_ParticulesByBlock", _particlesPerBlock);
            _updateParticleShader.SetValue("d_delta", dx);
            /************************/

            _updateParticleShader.Begin();
            _updateParticleShader.BeginPass(0);
            UtilDraw.drawInQuad(_Device);
            _updateParticleShader.EndPass();
            _updateParticleShader.End();

            rts.EndScene(Filter.None);
            surface.Dispose();
            rts.Dispose();

            /*Change index for fading and reset*/
            updateIndexReset();

            /*exchange texture*/
            _tempTexture           = _stateParticleTexture0;
            _stateParticleTexture0 = _stateParticleTexture1;
            _stateParticleTexture1 = _tempTexture;
        }