• 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
Mathy

[SlimDX] Anti-aliasing?

11 posts in this topic

Hi there. I am rendering 2D through Direct3D on the SlimDX wrapper, because I was told that DirectDraw was deprecated or obsolete. Now, the edges of my faces of the meshes I render look terrible. I would like them to be anti-aliased. I've done a lot of research myself, and I've figured out that multisampling and anti-aliasing is apparently the same? (Correct me if I'm wrong) So I tried initializing the device in the following way:
            Dim PresentParameters As New PresentParameters
            PresentParameters.BackBufferCount = 1
            PresentParameters.BackBufferFormat = Format.R5G6B5
            PresentParameters.BackBufferWidth = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width
            PresentParameters.BackBufferHeight = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height
            PresentParameters.Windowed = False
            PresentParameters.SwapEffect = SwapEffect.Discard
            PresentParameters.EnableAutoDepthStencil = False
            PresentParameters.Multisample = MultisampleType.FourSamples
            PresentParameters.MultisampleQuality = 2

            Dim Direct3D As New Direct3D
            DEVICE = New Device(Direct3D, 0, DeviceType.Hardware, Control.Handle, CreateFlags.HardwareVertexProcessing, PresentParameters)
Notice that the present parameter's multi sample property is set to four samples, and the quality is set to two. I read somewhere that the quality depends on what the graphics card can hold. From what I can see, my graphics card can render the final outcome just fine, but the edges are still jagged. I am rendering sphere meshes, that has materials applied to them. There's been a few complaints in regards to myself appearing "lazy" to some, because they thought I didn't do enough research before going here first. That's not the case, and I appologize. I've tried to be describing the issue as well as I can with my beginner knowledge in game programming.
1

Share this post


Link to post
Share on other sites
Hi Mathy. Yes, multisampling is the one of anti-aliasing (AA) techniques. There are lot of AA algorithms but directx uses the one and it is implemented in hardware level.

I think three things can be wrong that your AA is not working:

1) AA is disabled is graphics driver. I don't know how to do it with ATI graphics cars, but nVidia has "nVidia ControlPannel". In Vista as well as Window 7 you can find it in Control Pannel => Personalization => Display Settings => Advanced Settings => GeForce 9600 GSO tab (in my case) => Start the nVidia Control Pannel. Here select "Manage 3D settings" (left side of window) and "Application-controlled" for "Antialiasing - Mode".

2) Check MultisampleAntialias state. Use Device.GetRenderState(RenderState.MultisampleAntialias).

3) Can be that you set incorrect values of Multisample or MultisampleQuality in PresentParameters. Have a look to SmapleFramework that produces with SlimDX SDK. There are examples how to do that correctly.
0

Share this post


Link to post
Share on other sites
Quote:
Original post by user88
Hi Mathy. Yes, multisampling is the one of anti-aliasing (AA) techniques. There are lot of AA algorithms but directx uses the one and it is implemented in hardware level.

I think three things can be wrong that your AA is not working:

1) AA is disabled is graphics driver. I don't know how to do it with ATI graphics cars, but nVidia has "nVidia ControlPannel". In Vista as well as Window 7 you can find it in Control Pannel => Personalization => Display Settings => Advanced Settings => GeForce 9600 GSO tab (in my case) => Start the nVidia Control Pannel. Here select "Manage 3D settings" (left side of window) and "Application-controlled" for "Antialiasing - Mode".

2) Check MultisampleAntialias state. Use Device.GetRenderState(RenderState.MultisampleAntialias).

3) Can be that you set incorrect values of Multisample or MultisampleQuality in PresentParameters. Have a look to SmapleFramework that produces with SlimDX SDK. There are examples how to do that correctly.


Still doesn't work! I appreciate your very well-described help, and your ability to give me a list of possibilities.



Here's what I did so far.


Right-clicked on my desktop and clicked "NVIDIA Control Panel".

Clicked "Manage 3D settings" to the left.

I went to the "Global Settings" tab.

I selected "Application-controlled" for "Antialiasing - Mode".

I selected "Multisampling" for "Antialiasing - Transparency".

I selected "On" for "Antialiasing - Gamma correction".

Now, I went back to my program, and made sure that I set the MultisampleAntialias in my Render procedure.

I now tried opening the program - still aliased edges on the spheres.

I experimented with different MultiSample and MultiSampleQuality numbers, even though I have no clue of what I am doing. Anyway, below you see the results.



All these multisample settings were tested with MultisampleQuality 1.


Multisample: MultisampleType.TwoSamples - Getting error "Invalid call (-2005530516)" upon initialization.

Multisample: MultisampleType.ThreeSamples - Getting error "Invalid call (-2005530516)" upon initialization.

Multisample: MultisampleType.FourSamples - Initializes just fine, but without antialiasing.

Multisample: MultisampleType.FiveSamples - Getting error "Invalid call (-2005530516)" upon initialization.

Multisample: MultisampleType.SixSamples - Getting error "Invalid call (-2005530516)" upon initialization.


From here I didn't test any other. Now, I find it weird that FourSamples initializes, and TwoSamples doesn't. In games such as Battlefield 2, I can easily have 2, 4, 6 or 8 X antialiasing.

My graphics card is an NVidia Quadro NVS 140M.
0

Share this post


Link to post
Share on other sites
I might want to mention that I am using Direct3D9. I heard that DirectX 10 is not supported on DirectX 9 cards (or is it generally supported, just not with all features?)
0

Share this post


Link to post
Share on other sites
Quote:
Original post by Mathy
Multisample: MultisampleType.TwoSamples - Getting error "Invalid call (-2005530516)" upon initialization.

Multisample: MultisampleType.ThreeSamples - Getting error "Invalid call (-2005530516)" upon initialization.

Multisample: MultisampleType.FourSamples - Initializes just fine, but without antialiasing.

Multisample: MultisampleType.FiveSamples - Getting error "Invalid call (-2005530516)" upon initialization.

Multisample: MultisampleType.SixSamples - Getting error "Invalid call (-2005530516)" upon initialization.

Do you use Debug version of Direct3D. It can give you more information about error.

Here you can read about debug version and here you can download tool for debug logs capture.
0

Share this post


Link to post
Share on other sites
Apparently the error was "Invalid quality" or something.

But once I got the error fixed by changing to a valid quality (normally 0), it still didn't work.
0

Share this post


Link to post
Share on other sites
Does your card / driver actually support AA? If you look at the DX caps viewer (comes with the SDK), what do you see under:
Direct3D9 Devices/your_graphics_adapter/D3D Device Types / HAL / Adapter formats / D3DFMT_R5G6B5 (Fullscreen) / Render Format Compatibility / D3DFMT_R5G6B5 / ?
0

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
Does your card / driver actually support AA? If you look at the DX caps viewer (comes with the SDK), what do you see under:
Direct3D9 Devices/your_graphics_adapter/D3D Device Types / HAL / Adapter formats / D3DFMT_R5G6B5 (Fullscreen) / Render Format Compatibility / D3DFMT_R5G6B5 / ?


Yes it does.

D3DMULTISAMPLE_NONE: 1 quality level
D3DMULTISAMPLE_NONMASKABLE: 8 quality levels
D3DMULTISAMPLE_2_SAMPLES: 1 quality level
D3DMULTISAMPLE_4_SAMPLES: 8 quality levels
D3DMULTISAMPLE_8_SAMPLES: 3 quality levels
0

Share this post


Link to post
Share on other sites
I figured out the issue. I had a post-processing blur shader that ruined it. Removing the shader fixed the problem. Is there any way I can get that blur shader to work with Anti Aliasing though?

Also, how would I programmatically see how many quality levels the graphics card supports etc? I can't find anything about this.
0

Share this post


Link to post
Share on other sites
Quote:
Original post by Mathy
Also, how would I programmatically see how many quality levels the graphics card supports etc?


Here is a code snippet from SlimDX SDK 2009 Simple Framework:

static void BuildMultisampleTypeList(SettingsCombo9 combo)
{
List<MultisampleType> possibleMultisampleTypes = new List<MultisampleType>
{
MultisampleType.None,
MultisampleType.NonMaskable,
MultisampleType.TwoSamples,
MultisampleType.ThreeSamples,
MultisampleType.FourSamples,
MultisampleType.FiveSamples,
MultisampleType.SixSamples,
MultisampleType.SevenSamples,
MultisampleType.EightSamples,
MultisampleType.NineSamples,
MultisampleType.TenSamples,
MultisampleType.ElevenSamples,
MultisampleType.TwelveSamples,
MultisampleType.ThirteenSamples,
MultisampleType.FourteenSamples,
MultisampleType.FifteenSamples,
MultisampleType.SixteenSamples
};
int quality;
foreach (MultisampleType type in possibleMultisampleTypes)
{
if (GraphicsDeviceManager.Direct3D9Object.CheckDeviceMultisampleType(combo.AdapterOrdinal, combo.DeviceType, // Direct3D9Object is of SlimDX.Direct3D9.Direct3D type
combo.AdapterFormat, combo.Windowed, type, out quality))
{
combo.MultisampleTypes.Add(type);
combo.MultisampleQualities.Add(quality); // note, quality (or quality - 1, can't remember) is highest value of quality level in current multisample type
}
}
}
}



1

Share this post


Link to post
Share on other sites
Quote:
Original post by user88
Quote:
Original post by Mathy
Also, how would I programmatically see how many quality levels the graphics card supports etc?


Here is a code snippet from SlimDX SDK 2009 Simple Framework:
*** Source Snippet Removed ***


Perfect!

I've rated you excellent!
0

Share this post


Link to post
Share on other sites
Quote:

Here is a code snippet from SlimDX SDK 2009 Simple Framework:

Do note that this sample framework no longer exists in this form.
0

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