
Here's the shader code that should demonstrate the alpha channel :
float4 finalColor = gSpriteSheet.Sample(PointSampler, input.texcoord); // ------------------------------------------------------------------------ // final composition // ------------------------------------------------------------------------ return float4(finalColor.a,0,0,1);
But all I get is red !
What could I be doing wrong ?
Here's my rendertarget construction :
// create DirectX11 device CreateDevice11(form, out swapChain, out device11); // create depth buffer CreateDepthBuffer(form.ClientSize.Width, form.ClientSize.Height); // create a view of our render target, which is the backbuffer of the swap chain we just created RenderTargetView renderTarget; using (Resource resource = Resource.FromSwapChain<Texture2D>(swapChain, 0)) renderTarget = new RenderTargetView(device11, resource); // setting a viewport is required if you want to actually see anything var context = device11.ImmediateContext; //var viewport = new Viewport(0.0f, 0.0f, form.ClientSize.Width, form.ClientSize.Height); context.OutputMerger.SetTargets(renderTarget);
and here's my device/swapchain construction :
private static Result CreateDevice11(RenderForm form, out SwapChain swapChain, out Device device11)
{
var description = new SwapChainDescription()
{
BufferCount = 2,
Usage = Usage.RenderTargetOutput,
OutputHandle = form.Handle,
IsWindowed = true,
ModeDescription = new ModeDescription(0, 0, new Rational(60, 1), Format.R8G8B8A8_UNorm),
SampleDescription = new SampleDescription(1, 0),
Flags = SwapChainFlags.AllowModeSwitch,
SwapEffect = SwapEffect.Discard
};
return SlimDX.Direct3D11.Device.CreateWithSwapChain(adapter1, DeviceCreationFlags.Debug, description, out device11, out swapChain);
}






