• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0

DirectX10 setup and weird alpha artefacts

1 post in this topic

I have a weird problem. I use DirectX10 with SlimDX and I try to get the general setup right, but everytime there is something wrong. This time I encountered a weird error with alpha blending. I simply draw two intersecting planes with a opacity of 0.75f. When I draw them using 2x multisampling I get this result:
It looks like a tiny grid on top of my model. Strangely enough when I set multisampling to 1 everything seems fine, until I draw the model with 0.5f opacity, which creates the same artefacts. And that goes through each multisample count.
Here is my device setup:
// Create swap chain description
DXGI.SwapChainDescription swapChainDesc = new DXGI.SwapChainDescription()
BufferCount = 1,
Usage = DXGI.Usage.RenderTargetOutput,
OutputHandle = Window.Handle,
IsWindowed = true,
ModeDescription = new DXGI.ModeDescription(0, 0, new Rational(60, 1), DXGI.Format.R8G8B8A8_UNorm),
SampleDescription = new DXGI.SampleDescription(1, 0),
Flags = DXGI.SwapChainFlags.AllowModeSwitch,
SwapEffect = DXGI.SwapEffect.Discard,

// Get device and swap chain
DX10.Device.CreateWithSwapChain(null, DX10.DriverType.Hardware, DX10.DeviceCreationFlags.None, swapChainDesc, out Device, out SwapChain);

// Get back buffer view
using (DX10.Texture2D texture = DX10.Resource.FromSwapChain<DX10.Texture2D>(SwapChain, 0))
BackBufferView = new DX10.RenderTargetView(Device, texture);

// Get depth stencil view
DX10.Texture2DDescription descTexture2D = new DX10.Texture2DDescription()
Width = 1280,
Height = 720,
MipLevels = 1,
ArraySize = 1,
Format = DXGI.Format.D24_UNorm_S8_UInt,
SampleDescription = BackBufferView.Resource.AsSurface().Description.SampleDescription,
Usage = DX10.ResourceUsage.Default,
BindFlags = DX10.BindFlags.DepthStencil,
CpuAccessFlags = DX10.CpuAccessFlags.None,
OptionFlags = DX10.ResourceOptionFlags.None
DX10.DepthStencilViewDescription descDepthStencilView = new DX10.DepthStencilViewDescription()
ArraySize = 1,
Dimension = DX10.DepthStencilViewDimension.Texture2DMultisampled,
FirstArraySlice = 1,
MipSlice = 1,
Format = descTexture2D.Format,
using (DX10.Texture2D texture = new DX10.Texture2D(Device, descTexture2D))
DepthStencilView = new DX10.DepthStencilView(Device, texture, descDepthStencilView);

// Set rasterizer
DX10.RasterizerStateDescription rasteriserDesc = new DX10.RasterizerStateDescription()
CullMode = DX10.CullMode.Front,
DepthBias = 0,
DepthBiasClamp = 0,
FillMode = DX10.FillMode.Solid,
IsAntialiasedLineEnabled = false,
IsDepthClipEnabled = true,
IsFrontCounterclockwise = false,
IsMultisampleEnabled = false,
IsScissorEnabled = false,
SlopeScaledDepthBias = 0
Device.Rasterizer.State = DX10.RasterizerState.FromDescription(Device, rasteriserDesc);

// Set viewport
var viewport = new DX10.Viewport(0, 0, Window.ClientSize.Width, Window.ClientSize.Height);

// Set blend state
DX10.BlendStateDescription descBlendState = new DX10.BlendStateDescription()
IsAlphaToCoverageEnabled = true,
SourceBlend = DX10.BlendOption.SourceAlpha,
DestinationBlend = DX10.BlendOption.InverseSourceAlpha,
BlendOperation = DX10.BlendOperation.Add,
SourceAlphaBlend = DX10.BlendOption.Zero,
DestinationAlphaBlend = DX10.BlendOption.Zero,
AlphaBlendOperation = DX10.BlendOperation.Add,
descBlendState.SetBlendEnable(0, true);
descBlendState.SetWriteMask(0, DX10.ColorWriteMaskFlags.All);
Device.OutputMerger.BlendState = DX10.BlendState.FromDescription(Device, descBlendState);

// Set depth stencil state
DX10.DepthStencilStateDescription descDepthStencilState = new DX10.DepthStencilStateDescription()
IsDepthEnabled = true,
DepthWriteMask = DX10.DepthWriteMask.All,
DepthComparison = DX10.Comparison.LessEqual,
IsStencilEnabled = true,
StencilReadMask = 0xFF,
StencilWriteMask = 0xFF,
FrontFace = new DX10.DepthStencilOperationDescription()
FailOperation = DX10.StencilOperation.Keep,
DepthFailOperation = DX10.StencilOperation.Increment,
PassOperation = DX10.StencilOperation.Keep,
Comparison = DX10.Comparison.Always,
BackFace = new DX10.DepthStencilOperationDescription()
FailOperation = DX10.StencilOperation.Keep,
DepthFailOperation = DX10.StencilOperation.Decrement,
PassOperation = DX10.StencilOperation.Keep,
Comparison = DX10.Comparison.Always,
Device.OutputMerger.DepthStencilState = DX10.DepthStencilState.FromDescription(Device, descDepthStencilState);
Device.OutputMerger.DepthStencilReference = 1;

// Set render targets
Device.OutputMerger.SetTargets(DepthStencilView, BackBufferView);

Strange enough even though I don't use multisampling I must declare the DepthStencilViewDescription.Dimension to be Texture2DMultisampled or this line: [CODE]
DepthStencilView = new DX10.DepthStencilView(Device, texture, descDepthStencilView);
[/CODE] will throw an error.

If someone wants to reproduce the error, here's the project: [url="https://www.dropbox.com/s/lwkuzzkghyz3daq/Test.rar"]https://www.dropbox....yz3daq/Test.rar[/url]

So I wonder how to fix this problem since I've never encountered this kind of problem. Also I've been messing around with the device initialization code a lot, and my best bet is that the error lies somewhere within, but maybe you can tell me how to set the device up so that all basic functions work properly (eg multisampling, depth/stencling, alpha blending)

I really hope you can help me with this.

Share this post

Link to post
Share on other sites
You have alpha to coverage enabled, which will essentially "dither' your output based on the alpha value. It's meant to be used without blending, so that you can approximate the look of transparent geometry by rendering opaque geometry.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0