public override Effect Init(EffectDescription description)
 {
     var effect = base.Init(description);
     var texture = _textures[0];
     _textureHeight = texture.Texture.Description.Height;
     return effect;
 }
        public override Effect Init(EffectDescription description)
        {
            base.Init(description);

            var mode = _demo.SetupModel.Mode;

            _greetingsRenderTarget = _disposer.Add(new RenderTarget(
                device: _demo.Device,
                width: mode.Width,                    // TODO(mstrandh): Honor setupmodel?
                height: mode.Height,                   // TODO(mstrandh): Honor setupmodel?
                sampleCount: 1,                 // TODO(mstrandh): Honor setupmodel?
                sampleQuality: 0,               // TODO(mstrandh): Honor setupmodel?
                format: Format.R8G8B8A8_UNorm   // TODO(mstrandh): Honor setupmodel?
            ));

            CreateCylinderBuffers();
            var texture = _textures[0];
            _textureHeight = texture.Texture.Description.Height;

            _tubeVertexShader = _demo.ShaderManager["greetingsTube.vs.cso"];
            _tubePixelShader = _demo.ShaderManager["greetingsTube.ps.cso"];

            _tubeInputLayout = _disposer.Add(new InputLayout(_demo.Device, _tubeVertexShader.Signature, new[]
            {
                new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0),
                new InputElement("TEXCOORD", 0, Format.R32G32_Float, 12, 0),
            }));

            _greetingsTexture = _resourceViews[0];
            _renderedCylinderTexture = _greetingsRenderTarget.ShaderResourceView;

            // Create the depth buffer
            var depthBuffer = _disposer.Add(new Texture2D(_demo.Device, new Texture2DDescription
            {
                Format = Format.D32_Float_S8X24_UInt,
                ArraySize = 1,
                MipLevels = 1,
                Width = mode.Width,
                Height = mode.Height,
                SampleDescription = new SampleDescription { Count = 1, Quality = 0 },
                Usage = ResourceUsage.Default,
                BindFlags = BindFlags.DepthStencil,
                CpuAccessFlags = CpuAccessFlags.None,
                OptionFlags = ResourceOptionFlags.None
            }));

            // Create the depth buffer view
            _greetingsDepthView = _disposer.Add(new DepthStencilView(_demo.Device, depthBuffer));

            return this;
        }
        public virtual Effect Init(EffectDescription description)
        {
            // vertex stuff
            VertexShader = _demo.ShaderManager[description.VertexShaderName ?? "vanillaPlane.vs.cso"];
            InputLayout = _disposer.Add(new VanillaInputLayout(VertexShader));
            PrimitiveTopology = PrimitiveTopology.TriangleList;

            // pixel stuff
            var addressMode = GetTextureAddressMode();
            PixelShader = _demo.ShaderManager[description.PixelShaderName];
            _textures = (description.TextureNames ?? new string[0])
                .Select(textureName => string.IsNullOrEmpty(textureName) 
                    ? null 
                    : _demo.TextureManager[textureName])
                .ToArray();
            _resourceViews = _textures
                .Select(texture => (texture == null) 
                    ? null
                    : _disposer.Add(new ShaderResourceView(_demo.Device, texture.Texture)))
                .ToArray();
            _samplers = _textures
                .Select(texture => (texture == null)
                    ? null
                    : _disposer.Add(new SamplerState(_demo.Device, new SamplerStateDescription() {
                        Filter = Filter.Anisotropic,
                        AddressU = addressMode,
                        AddressV = addressMode,
                        AddressW = addressMode,
                        BorderColor = Color.Black,
                        ComparisonFunction = Comparison.Never,
                        MaximumAnisotropy = 1, // 16
                        MipLodBias = 0,
                        MinimumLod = 0,
                        MaximumLod = 1, // 16
                })))
                .ToArray();

            //
            return this;
        }