• 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

Can't Enable MSAA

4 posts in this topic



I've been doing some development in Direct3D 11 and C++ and I can't seem to be able to enable MSAA. I am getting horrible jagged lines when rendering a simple primitive. Here is what I have done so far:


SwapChain Creation

        // Display Mode
        // --------------------------------------------------------------------

        DXGI_RATIONAL RefreshRate = {60, 1};

        DXGI_MODE_DESC DisplayMode = {0};

        DisplayMode.Width = Width;
        DisplayMode.Height = Height;
        DisplayMode.RefreshRate = RefreshRate;
        DisplayMode.Format = DXGI_FORMAT_R8G8B8A8_UNORM;

        // --------------------------------------------------------------------

        // SwapChain Description
        // --------------------------------------------------------------------

        DXGI_SAMPLE_DESC Sampling = {4, 0};

        DXGI_SWAP_CHAIN_DESC SCDescription = {0};

        SCDescription.BufferCount = 1;
        SCDescription.BufferDesc = DisplayMode;
        SCDescription.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
        SCDescription.OutputWindow = RenderWindow;
        SCDescription.SampleDesc = Sampling;
        SCDescription.Windowed = TRUE;

        // --------------------------------------------------------------------

RenderTarget and DepthStencil and Rasterizer

        // Create RenderTarget
        // --------------------------------------------------------------------

        ID3D11Texture2D *Resource = NULL;
        m_SwapChain->GetBuffer(0, IID_ID3D11Texture2D, (void**)&Resource);

        D3D11_RENDER_TARGET_VIEW_DESC RTDescription;
        ZeroMemory(&RTDescription, sizeof(D3D11_RENDER_TARGET_VIEW_DESC));

        RTDescription.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
        RTDescription.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DMS;

        m_Device->CreateRenderTargetView(Resource, &RTDescription, 

        Resource = NULL;

        // --------------------------------------------------------------------

        // Create DepthStencil
        // --------------------------------------------------------------------

        D3D11_TEXTURE2D_DESC TextureDescription = {0};

        TextureDescription.BindFlags = D3D11_BIND_DEPTH_STENCIL;

        TextureDescription.Width = Width;
        TextureDescription.Height = Height;
        TextureDescription.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
        TextureDescription.SampleDesc = Sampling;

        TextureDescription.ArraySize = 1;
        TextureDescription.MipLevels = 1;

        ID3D11Texture2D *DepthResource = NULL;
            NULL, &DepthResource);

        D3D11_DEPTH_STENCIL_VIEW_DESC DSDescription;
        ZeroMemory(&DSDescription, sizeof(D3D11_DEPTH_STENCIL_VIEW_DESC));

        DSDescription.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
        DSDescription.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMS;

            &DSDescription, &m_DepthStencil);

        DepthResource = NULL;

        // --------------------------------------------------------------------

            OMSetRenderTargets(1, &m_RenderTarget, m_DepthStencil);

        // Customize Rasterizer
        // --------------------------------------------------------------------

        D3D11_RASTERIZER_DESC RasterizerDescription;
        ZeroMemory(&RasterizerDescription, sizeof(D3D11_RASTERIZER_DESC));

        RasterizerDescription.AntialiasedLineEnable = TRUE;
        RasterizerDescription.CullMode = D3D11_CULL_BACK;
        RasterizerDescription.DepthClipEnable = TRUE;
        RasterizerDescription.FillMode = D3D11_FILL_SOLID;
        RasterizerDescription.MultisampleEnable = TRUE;

        ID3D11RasterizerState *RasterizerState = NULL;

            (&RasterizerDescription, &RasterizerState);


        RasterizerState = NULL;

        // --------------------------------------------------------------------

Am I missing something? It should be noted that I am targeting D3D_FEATURE_LEVEL_9_3 and that my graphics card is capable of handling the above sampling count and quality.


Any help would be greatly appreciated!


Share this post

Link to post
Share on other sites

Thanks for the reply Erik.


I've actually managed to track down my problem and it is not anti-aliasing based. The jagged edges I am seeing are actually because of the filtering on my texture. 

        D3D11_SAMPLER_DESC SamplerDescription;
        ZeroMemory(&SamplerDescription, sizeof(D3D11_SAMPLER_DESC));

        SamplerDescription.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
        SamplerDescription.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
        SamplerDescription.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
        SamplerDescription.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
        SamplerDescription.Filter = D3D11_FILTER_ANISOTROPIC;
        SamplerDescription.MaxAnisotropy = 1;
        SamplerDescription.MaxLOD = D3D11_FLOAT32_MAX;

        ID3D11SamplerState *SamplerState = NULL;

        m_Device->CreateSamplerState(&SamplerDescription, &SamplerState);
        m_DeviceContext->PSSetSamplers(0, 1, &SamplerState);

        SamplerState = NULL;

When my filter is set to D3D11_FILTER_MIN_MAG_MIP_POINT, I get some insane jaggedness. So I changed my filter to D3D11_FILTER_ANISOTROPIC. Now my jaggedness is gone, but my texture is incredibly blurry. Does anyone have any thoughts?


Share this post

Link to post
Share on other sites

SamplerDescription.MaxAnisotropy = 1;


Maybe that is your issue. Try setting it to 16. Or determine the maximum supported:

if (deviceCaps->RasterCaps & D3DPRASTERCAPS_ANISOTROPY)
        SamplerDescrition.MaxAnisotrophy = deviceCaps->MaxAnisotropy;


Share this post

Link to post
Share on other sites

The "Quality" level doesn't literally refer to the quality of the antialiasing, it's primarily used to expose different MSAA variations supported by the driver. For instance you can use Nvidia's CSAA functionality through a quality level. A quality of 0 always gives you standard MSAA using the specified number of samples.

As for the bluriness, if it's occurring on surfaces being viewed at a grazing angle then you should follow the above suggestion and try increasing your MaxAnisotropy. 

Edited by MJP

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