Ejemplo n.º 1
0
        public override void Start()
        {
            base.Start();

            paradoxTexture = Asset.Load <Texture>("LogoParadox");
            customEffect   = EffectSystem.LoadEffect("Effect").WaitForResult();
            quad           = new PrimitiveQuad(GraphicsDevice, customEffect);

            // set fixed parameters once
            quad.Parameters.Set(EffectKeys.Center, new Vector2(0.5f, 0.5f));
            quad.Parameters.Set(EffectKeys.Frequency, 40);
            quad.Parameters.Set(EffectKeys.Spread, 0.5f);
            quad.Parameters.Set(EffectKeys.Amplitude, 0.015f);
            quad.Parameters.Set(EffectKeys.InvAspectRatio, GraphicsDevice.BackBuffer.Height / (float)GraphicsDevice.BackBuffer.Width);

            // NOTE: Linear-Wrap sampling is not available for non-square non-power-of-two textures on opengl es 2.0
            samplingState = SamplerState.New(GraphicsDevice, new SamplerStateDescription(TextureFilter.Linear, TextureAddressMode.Clamp));

            // Add Effect rendering to the end of the pipeline
            var scene      = SceneSystem.SceneInstance.Scene;
            var compositor = ((SceneGraphicsCompositorLayers)scene.Settings.GraphicsCompositor);

            renderer = new SceneDelegateRenderer(RenderQuad);
            compositor.Master.Renderers.Add(renderer);
        }
Ejemplo n.º 2
0
        protected override Task Initialize()
        {
            specificMipmapSamplerState = SamplerState.New(Game.GraphicsDevice, new SamplerStateDescription(TextureFilter.ComparisonPoint, TextureAddressMode.Clamp));

            currentEffect.Initialize(Game.Services);

            return(base.Initialize());
        }
Ejemplo n.º 3
0
        protected override void Initialize()
        {
            base.Initialize();



            Window.Title = "Kaibo Crawler";

            // Setup states
            var rasterizerStateDesc = SharpDX.Direct3D11.RasterizerStateDescription.Default();

            m_backfaceCullingState = RasterizerState.New(GraphicsDevice, "CullModeBack", rasterizerStateDesc);

            var depthStencilStateDesc = SharpDX.Direct3D11.DepthStencilStateDescription.Default();

            m_depthStencilStateState = DepthStencilState.New(GraphicsDevice, "NormalZBufferUse", depthStencilStateDesc);

            depthStencilStateDesc = SharpDX.Direct3D11.DepthStencilStateDescription.Default();
            depthStencilStateDesc.IsDepthEnabled = false;


            m_noDepthStencil = DepthStencilState.New(GraphicsDevice, "NoZBufferUse", depthStencilStateDesc);


            var samplerStateDesc = SharpDX.Direct3D11.SamplerStateDescription.Default();

            samplerStateDesc.AddressV = SharpDX.Direct3D11.TextureAddressMode.Wrap;
            samplerStateDesc.AddressU = SharpDX.Direct3D11.TextureAddressMode.Wrap;
            samplerStateDesc.Filter   = SharpDX.Direct3D11.Filter.MinMagMipPoint;
            m_linearSamplerState      = SamplerState.New(GraphicsDevice, "LinearSampler", samplerStateDesc);


            var blendStateDesc = SharpDX.Direct3D11.BlendStateDescription.Default();

            m_blendStateOpaque = BlendState.New(GraphicsDevice, "Opaque", blendStateDesc);


            var blendStateDesc1 = SharpDX.Direct3D11.BlendStateDescription.Default();

            blendStateDesc1.IndependentBlendEnable = false;
            blendStateDesc1.AlphaToCoverageEnable  = false;


            m_alphaBlendState = BlendState.New(GraphicsDevice, SharpDX.Direct3D11.BlendOption.SourceAlpha,     //sourceBlend
                                               SharpDX.Direct3D11.BlendOption.InverseSourceAlpha,              //destinationBlend
                                               SharpDX.Direct3D11.BlendOperation.Add,                          //blendoperation
                                               SharpDX.Direct3D11.BlendOption.SourceAlpha,                     //source alphaBlend
                                               SharpDX.Direct3D11.BlendOption.InverseSourceAlpha,              //destination alpha blend
                                               SharpDX.Direct3D11.BlendOperation.Add,                          //alphablend operation
                                               SharpDX.Direct3D11.ColorWriteMaskFlags.All,                     //rendertarget mask
                                               -1);                                                            //mask



            Input.init(this);
        }
Ejemplo n.º 4
0
        public override void DisplayMipMap(int level)
        {
            var samplerDescrition = new SamplerStateDescription(TextureFilter.ComparisonPoint, TextureAddressMode.Clamp)
            {
                MinMipLevel = level,
                MaxMipLevel = level
            };

            specificMipmapSamplerState.Dispose();
            specificMipmapSamplerState = SamplerState.New(Game.GraphicsDevice, samplerDescrition);
        }
        public ObjectParameterKey <SamplerState> GetSamplerKey(SamplerStateDescription samplerStateDesc, GraphicsDevice graphicsDevice)
        {
            ObjectParameterKey <SamplerState> key;

            if (!declaredSamplerStates.TryGetValue(samplerStateDesc, out key))
            {
                key = MaterialKeys.Sampler.ComposeWith("i" + declaredSamplerStates.Count.ToString(CultureInfo.InvariantCulture));
                declaredSamplerStates.Add(samplerStateDesc, key);
            }

            var samplerState = graphicsDevice != null?SamplerState.New(graphicsDevice, samplerStateDesc) : SamplerState.NewFake(samplerStateDesc);

            Parameters.Set(key, samplerState);
            return(key);
        }
Ejemplo n.º 6
0
        protected override void InitializeCore()
        {
            base.InitializeCore();

            customEffect         = EffectSystem.LoadEffect("Effect").WaitForResult();
            customEffectInstance = new EffectInstance(customEffect);

            spriteBatch = new SpriteBatch(GraphicsDevice)
            {
                VirtualResolution = new Vector3(1)
            };

            // set fixed parameters once
            customEffectInstance.Parameters.Set(TexturingKeys.Sampler, samplerState);
            customEffectInstance.Parameters.Set(EffectKeys.Center, new Vector2(0.5f, 0.5f));
            customEffectInstance.Parameters.Set(EffectKeys.Frequency, 40);
            customEffectInstance.Parameters.Set(EffectKeys.Spread, 0.5f);
            customEffectInstance.Parameters.Set(EffectKeys.Amplitude, 0.015f);
            customEffectInstance.Parameters.Set(EffectKeys.InvAspectRatio, GraphicsDevice.Presenter.BackBuffer.Height / (float)GraphicsDevice.Presenter.BackBuffer.Width);

            samplerState = SamplerState.New(GraphicsDevice, new SamplerStateDescription(TextureFilter.Linear, TextureAddressMode.Clamp));
        }
Ejemplo n.º 7
0
        public VideoTexture(GraphicsDevice graphicsDevice, IServiceRegistry serviceRegistry, int width, int height, int maxMipMapCount)
        {
            if (width <= 0 || height <= 0)
            {
                throw new InvalidOperationException("Invalid video resolution.");
            }

            if (maxMipMapCount < 0)
            {
                throw new InvalidOperationException("A negative number of mip maps is not allowed.");
            }

            var effectSystem = serviceRegistry.GetSafeServiceAs <EffectSystem>();

            // We want to sample mip maps using point filtering (to make sure nothing bleeds between mip maps).
            minMagLinearMipPointSampler = SamplerState.New(graphicsDevice, new SamplerStateDescription(TextureFilter.MinMagLinearMipPoint, TextureAddressMode.Clamp));

            // Allocate the effect for copying decoder output texture to our normal render texture
            effectDecoderTextureCopy = new EffectInstance(effectSystem.LoadEffect("SpriteEffectExtTexture").WaitForResult());
            effectDecoderTextureCopy.Parameters.Set(SpriteEffectExtTextureKeys.Gamma, 2.2f);
            effectDecoderTextureCopy.Parameters.Set(SpriteEffectExtTextureKeys.MipLevel, 0.0f);
            effectDecoderTextureCopy.Parameters.Set(SpriteEffectExtTextureKeys.Sampler, minMagLinearMipPointSampler);
            effectDecoderTextureCopy.UpdateEffect(graphicsDevice);

            // Allocate the effect for copying regular 2d textures:
            effectTexture2DCopy = new EffectInstance(effectSystem.LoadEffect("SpriteEffectExtTextureRegular").WaitForResult());
            effectTexture2DCopy.Parameters.Set(SpriteEffectExtTextureKeys.MipLevel, 0.0f);
            effectTexture2DCopy.Parameters.Set(SpriteEffectExtTextureRegularKeys.Sampler, minMagLinearMipPointSampler);
            effectTexture2DCopy.UpdateEffect(graphicsDevice);

            // Create a mip mapped texture with the same size as our video
            // Only generate up to "MaxMipMapCount" number of mip maps
            var mipMapCount        = Math.Min(Texture.CountMips(Math.Max(width, height)), maxMipMapCount + 1);
            var textureDescription = TextureDescription.New2D(width, height, mipMapCount, PixelFormat.R8G8B8A8_UNorm_SRgb, TextureFlags.ShaderResource | TextureFlags.RenderTarget, 1, GraphicsResourceUsage.Dynamic);

            renderTargetTexture = Texture.New(graphicsDevice, textureDescription, null); // Supply no data. Create an empty texture.
        }
Ejemplo n.º 8
0
        public void LoadRendering()
        {
            Vector3 virtualResolution = new Vector3(GraphicsDevice.Presenter.BackBuffer.Width,
                                                    GraphicsDevice.Presenter.BackBuffer.Height, 20f);

            ONAF2Component = new OnafMain(this);

            Scene scene = SceneSystem.SceneInstance.Scene;
            SceneGraphicsCompositorLayers compositor = (SceneGraphicsCompositorLayers)scene.Settings.GraphicsCompositor;

            compositor.Master.Renderers.Insert(1, new SceneDelegateRenderer(Draw));

            _spriteBatch = new SpriteBatch(GraphicsDevice)
            {
                VirtualResolution = virtualResolution
            };

            _sampler = SamplerState.New(GraphicsDevice,
                                        new SamplerStateDescription(TextureFilter.Point, TextureAddressMode.Wrap));

            LoadRealContent();

            _hasLoaded = true;
        }
Ejemplo n.º 9
0
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            var vertices = new Vertex[4];

            vertices[0] = new Vertex {
                Position = new Vector3(-1, -1, 0.5f), TexCoords = new Vector2(0, 0)
            };
            vertices[1] = new Vertex {
                Position = new Vector3(-1, 1, 0.5f), TexCoords = new Vector2(3, 0)
            };
            vertices[2] = new Vertex {
                Position = new Vector3(1, 1, 0.5f), TexCoords = new Vector2(3, 3)
            };
            vertices[3] = new Vertex {
                Position = new Vector3(1, -1, 0.5f), TexCoords = new Vector2(0, 3)
            };

            var indices = new short[] { 0, 1, 2, 0, 2, 3 };

            var vertexBuffer = Buffer.Vertex.New(GraphicsDevice, vertices, GraphicsResourceUsage.Default);
            var indexBuffer  = Buffer.Index.New(GraphicsDevice, indices, GraphicsResourceUsage.Default);
            var meshDraw     = new MeshDraw
            {
                DrawCount     = 4,
                PrimitiveType = PrimitiveType.TriangleList,
                VertexBuffers = new[]
                {
                    new VertexBufferBinding(vertexBuffer,
                                            new VertexDeclaration(VertexElement.Position <Vector3>(),
                                                                  VertexElement.TextureCoordinate <Vector2>()),
                                            4)
                },
                IndexBuffer = new IndexBufferBinding(indexBuffer, false, indices.Length),
            };

            var mesh = new Mesh
            {
                Draw = meshDraw,
            };

            simpleEffect             = new Effect(GraphicsDevice, SpriteEffect.Bytecode);
            parameterCollection      = new ParameterCollection();
            parameterCollectionGroup = new EffectParameterCollectionGroup(GraphicsDevice, simpleEffect, new[] { parameterCollection });
            parameterCollection.Set(TexturingKeys.Texture0, UVTexture);

            vao = VertexArrayObject.New(GraphicsDevice, mesh.Draw.IndexBuffer, mesh.Draw.VertexBuffers);

            myDraws    = new DrawOptions[3];
            myDraws[0] = new DrawOptions {
                Sampler = GraphicsDevice.SamplerStates.LinearClamp, Transform = Matrix.Multiply(Matrix.Scaling(0.4f), Matrix.Translation(-0.5f, 0.5f, 0f))
            };
            myDraws[1] = new DrawOptions {
                Sampler = GraphicsDevice.SamplerStates.LinearWrap, Transform = Matrix.Multiply(Matrix.Scaling(0.4f), Matrix.Translation(0.5f, 0.5f, 0f))
            };
            myDraws[2] = new DrawOptions {
                Sampler = SamplerState.New(GraphicsDevice, new SamplerStateDescription(TextureFilter.Linear, TextureAddressMode.Mirror)), Transform = Matrix.Multiply(Matrix.Scaling(0.4f), Matrix.Translation(0.5f, -0.5f, 0f))
            };
            //var borderDescription = new SamplerStateDescription(TextureFilter.Linear, TextureAddressMode.Border) { BorderColor = Color.Purple };
            //var border = SamplerState.New(GraphicsDevice, borderDescription);
            //myDraws[3] = new DrawOptions { Sampler = border, Transform = Matrix.Multiply(Matrix.Scale(0.3f), Matrix.Translation(-0.5f, -0.5f, 0f)) };
        }
Ejemplo n.º 10
0
        public VoxelRenderer(GraphicsDevice graphicsDevice, ContentManager contentManager)
        {
            _cubeVertexBuffer = Buffer.Vertex.New(
                graphicsDevice,
                new[]
            {
                // 3D coordinates              UV Texture coordinates
                new CubeVertex()
                {
                    Position = new Vector3(-1.0f, -1.0f, -1.0f), Normal = -Vector3.UnitZ, Texcoord = new Vector2(0.0f, 1.0f)
                },                                                                                                                                     // Front
                new CubeVertex()
                {
                    Position = new Vector3(-1.0f, 1.0f, -1.0f), Normal = -Vector3.UnitZ, Texcoord = new Vector2(0.0f, 0.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(1.0f, 1.0f, -1.0f), Normal = -Vector3.UnitZ, Texcoord = new Vector2(1.0f, 0.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(-1.0f, -1.0f, -1.0f), Normal = -Vector3.UnitZ, Texcoord = new Vector2(0.0f, 1.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(1.0f, 1.0f, -1.0f), Normal = -Vector3.UnitZ, Texcoord = new Vector2(1.0f, 0.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(1.0f, -1.0f, -1.0f), Normal = -Vector3.UnitZ, Texcoord = new Vector2(1.0f, 1.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(-1.0f, -1.0f, 1.0f), Normal = Vector3.UnitZ, Texcoord = new Vector2(1.0f, 0.0f)
                },                                                                                                                                    // BACK
                new CubeVertex()
                {
                    Position = new Vector3(1.0f, 1.0f, 1.0f), Normal = Vector3.UnitZ, Texcoord = new Vector2(0.0f, 1.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(-1.0f, 1.0f, 1.0f), Normal = Vector3.UnitZ, Texcoord = new Vector2(1.0f, 1.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(-1.0f, -1.0f, 1.0f), Normal = Vector3.UnitZ, Texcoord = new Vector2(1.0f, 0.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(1.0f, -1.0f, 1.0f), Normal = Vector3.UnitZ, Texcoord = new Vector2(0.0f, 0.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(1.0f, 1.0f, 1.0f), Normal = Vector3.UnitZ, Texcoord = new Vector2(0.0f, 1.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(-1.0f, 1.0f, -1.0f), Normal = Vector3.UnitY, Texcoord = new Vector2(0.0f, 1.0f)
                },                                                                                                                                    // Top
                new CubeVertex()
                {
                    Position = new Vector3(-1.0f, 1.0f, 1.0f), Normal = Vector3.UnitY, Texcoord = new Vector2(0.0f, 0.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(1.0f, 1.0f, 1.0f), Normal = Vector3.UnitY, Texcoord = new Vector2(1.0f, 0.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(-1.0f, 1.0f, -1.0f), Normal = Vector3.UnitY, Texcoord = new Vector2(0.0f, 1.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(1.0f, 1.0f, 1.0f), Normal = Vector3.UnitY, Texcoord = new Vector2(1.0f, 0.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(1.0f, 1.0f, -1.0f), Normal = Vector3.UnitY, Texcoord = new Vector2(1.0f, 1.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(-1.0f, -1.0f, -1.0f), Normal = -Vector3.UnitY, Texcoord = new Vector2(1.0f, 0.0f)
                },                                                                                                                                     // Bottom
                new CubeVertex()
                {
                    Position = new Vector3(1.0f, -1.0f, 1.0f), Normal = -Vector3.UnitY, Texcoord = new Vector2(0.0f, 1.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(-1.0f, -1.0f, 1.0f), Normal = -Vector3.UnitY, Texcoord = new Vector2(1.0f, 1.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(-1.0f, -1.0f, -1.0f), Normal = -Vector3.UnitY, Texcoord = new Vector2(1.0f, 0.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(1.0f, -1.0f, -1.0f), Normal = -Vector3.UnitY, Texcoord = new Vector2(0.0f, 0.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(1.0f, -1.0f, 1.0f), Normal = -Vector3.UnitY, Texcoord = new Vector2(0.0f, 1.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(-1.0f, -1.0f, -1.0f), Normal = -Vector3.UnitX, Texcoord = new Vector2(0.0f, 1.0f)
                },                                                                                                                                     // Left
                new CubeVertex()
                {
                    Position = new Vector3(-1.0f, -1.0f, 1.0f), Normal = -Vector3.UnitX, Texcoord = new Vector2(0.0f, 0.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(-1.0f, 1.0f, 1.0f), Normal = -Vector3.UnitX, Texcoord = new Vector2(1.0f, 0.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(-1.0f, -1.0f, -1.0f), Normal = -Vector3.UnitX, Texcoord = new Vector2(0.0f, 1.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(-1.0f, 1.0f, 1.0f), Normal = -Vector3.UnitX, Texcoord = new Vector2(1.0f, 0.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(-1.0f, 1.0f, -1.0f), Normal = -Vector3.UnitX, Texcoord = new Vector2(1.0f, 1.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(1.0f, -1.0f, -1.0f), Normal = Vector3.UnitX, Texcoord = new Vector2(1.0f, 0.0f)
                },                                                                                                                                    // Right
                new CubeVertex()
                {
                    Position = new Vector3(1.0f, 1.0f, 1.0f), Normal = Vector3.UnitX, Texcoord = new Vector2(0.0f, 1.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(1.0f, -1.0f, 1.0f), Normal = Vector3.UnitX, Texcoord = new Vector2(1.0f, 1.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(1.0f, -1.0f, -1.0f), Normal = Vector3.UnitX, Texcoord = new Vector2(1.0f, 0.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(1.0f, 1.0f, -1.0f), Normal = Vector3.UnitX, Texcoord = new Vector2(0.0f, 0.0f)
                },
                new CubeVertex()
                {
                    Position = new Vector3(1.0f, 1.0f, 1.0f), Normal = Vector3.UnitX, Texcoord = new Vector2(0.0f, 1.0f)
                }
            }, SharpDX.Direct3D11.ResourceUsage.Immutable);

            // Create an input layout from the vertices
            _vertexInputLayout = VertexInputLayout.New(
                VertexBufferLayout.New(0, new VertexElement[] { new VertexElement("POSITION_CUBE", 0, SharpDX.DXGI.Format.R32G32B32_Float, 0),
                                                                new VertexElement("NORMAL", 0, SharpDX.DXGI.Format.R32G32B32_Float, sizeof(float) * 3),
                                                                new VertexElement("TEXCOORD", 0, SharpDX.DXGI.Format.R32G32_Float, sizeof(float) * 6) }, 0),
                VertexBufferLayout.New(1, new VertexElement[] { new VertexElement("POSITION_INSTANCE", SharpDX.DXGI.Format.R32_SInt) }, 1));

            // Create instance buffer for every VoxelInfo
            _voxelTypeRenderingData = new VoxelTypeInstanceData[TypeInformation.GetNumTypes() - 1];
            for (int i = 0; i < _voxelTypeRenderingData.Length; ++i)
            {
                _voxelTypeRenderingData[i] = new VoxelTypeInstanceData(graphicsDevice, (VoxelType)(i + 1));
            }
            LoadTextures(contentManager);


            // load shader
            EffectCompilerFlags compilerFlags = EffectCompilerFlags.None;

#if DEBUG
            compilerFlags |= EffectCompilerFlags.Debug;
#endif
            var voxelShaderCompileResult = EffectCompiler.CompileFromFile("Content/voxel.fx", compilerFlags);
            if (voxelShaderCompileResult.HasErrors)
            {
                System.Console.WriteLine(voxelShaderCompileResult.Logger.Messages);
                System.Diagnostics.Debugger.Break();
            }
            _voxelEffect = new SharpDX.Toolkit.Graphics.Effect(graphicsDevice, voxelShaderCompileResult.EffectData);

            // setup states
            var rasterizerStateDesc = SharpDX.Direct3D11.RasterizerStateDescription.Default();
            rasterizerStateDesc.CullMode = SharpDX.Direct3D11.CullMode.Back;
            _backfaceCullingState        = RasterizerState.New(graphicsDevice, "CullModeBack", rasterizerStateDesc);
            rasterizerStateDesc.CullMode = SharpDX.Direct3D11.CullMode.None;
            _noneCullingState            = RasterizerState.New(graphicsDevice, "CullModeNone", rasterizerStateDesc);

            var depthStencilStateDesc = SharpDX.Direct3D11.DepthStencilStateDescription.Default();
            depthStencilStateDesc.IsDepthEnabled = true;
            _depthStencilStateState = DepthStencilState.New(graphicsDevice, "NormalZBufferUse", depthStencilStateDesc);

            var samplerStateDesc = SharpDX.Direct3D11.SamplerStateDescription.Default();
            samplerStateDesc.AddressV = SharpDX.Direct3D11.TextureAddressMode.Mirror;
            samplerStateDesc.AddressU = SharpDX.Direct3D11.TextureAddressMode.Mirror;
            samplerStateDesc.Filter   = SharpDX.Direct3D11.Filter.MinMagMipPoint;
            _pointSamplerState        = SamplerState.New(graphicsDevice, "PointSampler", samplerStateDesc);
            _voxelEffect.Parameters["PointSampler"].SetResource(_pointSamplerState);

            var blendStateDesc = SharpDX.Direct3D11.BlendStateDescription.Default();
            _blendStateOpaque = BlendState.New(graphicsDevice, "Opaque", blendStateDesc);
            blendStateDesc.RenderTarget[0].IsBlendEnabled   = true;
            blendStateDesc.RenderTarget[0].SourceBlend      = SharpDX.Direct3D11.BlendOption.SourceAlpha;
            blendStateDesc.RenderTarget[0].DestinationBlend = SharpDX.Direct3D11.BlendOption.InverseSourceAlpha;
            blendStateDesc.RenderTarget[0].BlendOperation   = SharpDX.Direct3D11.BlendOperation.Add;
            _blendStateTransparent = BlendState.New(graphicsDevice, "AlphaBlend", blendStateDesc);

            // vertexbuffer for a single instance
            _singleInstanceBuffer = Buffer.Vertex.New <Int32>(graphicsDevice, 1, SharpDX.Direct3D11.ResourceUsage.Dynamic);
        }