/// <summary> /// Applys a shader effect /// </summary> /// <param name="effect">The shader effect to apply</param> /// <param name="inTexture">The DrawingLayer to be used as input</param> /// <param name="outTexture">The DrawingLayer to be used as output</param> /// <param name="clearOutput">Clear the output before writing</param> public void Apply(ShaderEffect effect, RenderTargetTexture inTexture, RenderTargetTexture outTexture, bool clearOutput) { var device = m_directCanvasFactory.DeviceContext.Device; if(clearOutput) outTexture.Clear(new Color4(0, 0, 0, 0)); outTexture.SetRenderTarget(); device.PixelShader.SetShaderResource(inTexture.InternalShaderResourceView, 0); if (effect.Filter == ShaderEffectFilter.Linear) device.PixelShader.SetSampler(m_linearSamplerState, 0); else if (effect.Filter == ShaderEffectFilter.Point) device.PixelShader.SetSampler(m_pointSamplerState, 0); device.OutputMerger.BlendState = m_alphaBlendState; effect.Draw(); }
/// <summary> /// Applys a shader effect /// </summary> /// <param name="effect">The shader effect to apply</param> /// <param name="inTexture">The DrawingLayer to be used as input</param> /// <param name="outTexture">The DrawingLayer to be used as output</param> /// <param name="targetRect"></param> /// <param name="clearOutput">Clear the output before writing</param> public void Apply(ShaderEffect effect, RenderTargetTexture inTexture, RenderTargetTexture outTexture, Rectangle targetRect, bool clearOutput) { var device = m_directCanvasFactory.DeviceContext.Device; if (clearOutput) outTexture.Clear(new Color4(0, 0, 0, 0)); outTexture.SetRenderTarget(new Viewport(targetRect.X, targetRect.Y, targetRect.Width, targetRect.Height, 0, 1)); device.PixelShader.SetShaderResource(inTexture.InternalShaderResourceView, 0); if (effect.Filter == ShaderEffectFilter.Linear) device.PixelShader.SetSampler(m_linearSamplerState, 0); else if (effect.Filter == ShaderEffectFilter.Point) device.PixelShader.SetSampler(m_pointSamplerState, 0); effect.Draw(); }