Exemplo n.º 1
0
        public void GlowingPass(Scene scene)
        {
            // On commence par rendre l'intégralité de la scène dans une texture
            ApplicationDX11.Instance.DeviceContext.OutputMerger.BlendState = ApplicationDX11.Instance.RenderToTextureBlendState;

            m_RenderTexture.Bind();
            ApplicationDX11.Instance.DeviceContext.ClearRenderTargetView(
                m_RenderTexture.RenderTargetView,
                new Color4(0.0f, 0.0f, 0.0f, 0.0f));

            //for (int i = 0; i < scene.sons_.Count; i++){
            //    Update(scene.sons_[i]);
            //}

            m_ImageProcessing.UpdatePasses();

            if (m_DrawingMaterial.textures_.Count == 0)
            {
                m_DrawingMaterial.AddShaderResourceView(m_ImageProcessing.GetFinalSRV());
            }
            else
            {
                m_DrawingMaterial.textures_[0] = m_ImageProcessing.GetFinalSRV();
            }
        }
Exemplo n.º 2
0
        private void UpdatePasse(int index)
        {
            // On commence par récupérer le matérial que l'on souhaite appliquer à l'image
            MaterialDX11 mat = passes_[index];

            //// On met à jour la vue

            View.Current = PostProcessingView;

            ApplicationDX11.Instance.DeviceContext.OutputMerger.BlendState = ApplicationDX11.Instance.RenderToTextureBlendState;

            //// On définit le renderTargetView pour bien dessiner dans la bonne RenderTexture
            GetCurrentOutput().Bind();

            ApplicationDX11.Instance.DeviceContext.ClearRenderTargetView(
                GetCurrentOutput().RenderTargetView,
                new Color4(0.0f, 1.0f, 0.0f, 1.0f));

            if (mat.textures_.Count == 0)
            {
                mat.AddShaderResourceView(m_input);
            }
            else
            {
                mat.textures_[0] = m_input;
            }


            SamplerState state = new SamplerState(ApplicationDX11.Instance.Device, new SamplerStateDescription()
            {
                AddressU           = TextureAddressMode.Clamp,
                AddressV           = TextureAddressMode.Clamp,
                AddressW           = TextureAddressMode.Clamp,
                BorderColor        = new Color4(0.0f, 1.0f, 0.0f, 1.0f),
                ComparisonFunction = Comparison.LessEqual,
                Filter             = Filter.MinLinearMagMipPoint,
                MaximumAnisotropy  = 0,
                MaximumLod         = 0,
                MinimumLod         = 0,
                MipLodBias         = 0
            });

            if (mat.samplers.Count == 0)
            {
                mat.samplers.Add(state);
            }
            else
            {
                mat.samplers[0] = state;
            }

            // On dessine
            model_.material_ = mat;

            transform_.Update();
            //model_.Draw(  );
        }
Exemplo n.º 3
0
        public void SetText(string text)
        {
            float offset = 0.0f;

            Width  = 0.0f;
            Height = 0.0f;

            for (int i = 0; i < text.Length; i++)
            {
                float coef = 0.1f;

                AtlasNode atlasnode = atlasfont.atlas.GetNode(text[i]);

                MaterialDX11 mat = new MaterialDX11("vDefault.cso", "pText.cso");
                mat.SetMainColor(1.0f, 0.0f, 0.0f, 1.0f);

                mat.AddShaderResourceView(atlasfont.atlas.SRV);

                Entity entity = new Entity();

                // On utilise XOffset et xadvance pour déterminer la position des caractères dans la ligne
                offset += atlasnode.XOffset * coef;

                entity.transform_.Translate(
                    offset + (( float )atlasnode.Width / 2.0f * coef),
                    -(atlasnode.Height * coef / 2.0f) - atlasnode.YOffset * coef,
                    0.0f);

                offset += atlasnode.XAdvance * coef;

                entity.transform_.SetScale(
                    atlasnode.Width * coef,
                    atlasnode.Height * coef,
                    1.0f);

                Width += atlasnode.Width * coef + atlasnode.XOffset * coef + atlasnode.XAdvance * coef;
                Height = atlasnode.Height * coef + atlasnode.YOffset * coef;

                Append(entity);

                //entity.modelrenderer_ = new MeshRenderer( mat, Quad.GetMesh() );

                SamplerState state = new SamplerState(ApplicationDX11.Instance.Device, new SamplerStateDescription()
                {
                    AddressU           = TextureAddressMode.Wrap,
                    AddressV           = TextureAddressMode.Wrap,
                    AddressW           = TextureAddressMode.Wrap,
                    BorderColor        = new Color4(0.0f, 1.0f, 0.0f, 1.0f),
                    ComparisonFunction = Comparison.LessEqual,
                    Filter             = Filter.MinLinearMagMipPoint,
                    MaximumAnisotropy  = 0,
                    MaximumLod         = 0,
                    MinimumLod         = 0,
                    MipLodBias         = 0
                });
                mat.samplers.Add(state);
                mat.SetTextureXOffset(( float )atlasnode.X / ( float )atlasfont.atlas.Width);
                mat.SetTextureYOffset(( float )atlasnode.Y / ( float )atlasfont.atlas.Height);
                mat.SetTextureWidth(( float )atlasnode.Width / ( float )atlasfont.atlas.Width);
                mat.SetTextureHeight(( float )atlasnode.Height / ( float )atlasfont.atlas.Height);
            }

            if (CenterText)
            {
                transform_.Translate(-Width / 4.0f, Height / 2.0f, 0.0f);
            }
        }