I have an project I'm looking for a better solution to. I have a need to render n images over each other the previous one. So I have loop if you will. This should simulate alpha bending via basic combining the target and overlay pixel color values. Please see code below.
public void Render()
{
Device3DModule.DeviceContext.ClearRenderTargetView(Device3DModule.RenderTargetView, Colors.Blue.ToDXColor());
CompositeShader.Apply();
foreach (var image in Images)
{
Texture2D target = null;
var pass01 = true;
foreach (var imageChannel in image)
{
if(!imageChannel.IsVisible || imageChannel.Image == null) continue;
imageChannel.Pass01 = pass01;
Device3DModule.DeviceContext.PixelShader.SetShaderResource(1, imageChannel.Image);
imageChannel.CopyToDeviceBuffer(ref m_ChannelSettingBuffer);
QuadMesh.Draw();
target?.Dispose();
target = new Texture2D(Device3DModule.Device, Device3DModule.RenderTarget.Description);
Device3DModule.DeviceContext.CopyResource(Device3DModule.RenderTarget, target);
ShaderResourceView = new ShaderResourceView(Device3DModule.Device, target);
Device3DModule.DeviceContext.PixelShader.SetShaderResource(0, ShaderResourceView);
pass01 = false;
}
target?.Dispose();
ShaderResourceView.Dispose();
}
}
Does anyone have a better idea?