Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1357165
  • 博文数量: 281
  • 博客积分: 8800
  • 博客等级: 中将
  • 技术积分: 3346
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-17 22:31
文章分类

全部博文(281)

文章存档

2013年(1)

2012年(18)

2011年(16)

2010年(44)

2009年(86)

2008年(41)

2007年(10)

2006年(65)

我的朋友

分类: LINUX

2012-02-14 09:58:00

Overview

UE3 supports full scene anti aliasing in DirectX 11 through MSAA. is a hardware feature that only shades pixels once, but evaluates the depth test multiple times per pixel.

Enabling MSAA

MSAA is not enabled by default, but can be enabled by setting MaxMultiSamples in the engine ini to a value of 4. Alternatively you can enable MSAA without restarting the editor or game with the command 'scale set MaxMultiSamples 4'. The DirectX 11 renderer only supports MaxMultiSamples values of 1 (no AA) and 4 (4x MSAA).

MSAA with Deferred Shading

The DirectX11 renderer does many operations in a deferred pass, which do not work nicely with MSAA untouched. Each deferred pass (lighting, shadowing, fog, SSS, reflections, etc) has been updated to super sample the shading along geometry edges, which reduces aliasing.

 

Full-scene antialiasing refers to blurring the edges of each polygon in the scene as it is rasterized in a single pass; no second pass is required. Full-scene antialiasing, when supported, affects only triangles and groups of triangles. Lines cannot be antialiased by using Direct3D services. Full-scene antialiasing is done in Direct3D by using multisampling on each pixel. When multisampling is enabled, all subsamples of a pixel are updated in one pass but when used for other effects that involve multiple rendering passes, the application can specify that only some subsamples are to be affected by a given rendering pass. This latter approach enables simulation of motion blur, depth-of-field focus effects, reflection blur, and so on.

In both cases, the various samples recorded for each pixel are blended together and output to the screen. This enables the improved image quality of antialiasing or other effects.

Before creating a device with the method, you need to determine if full-scene antialiasing is supported. Do this by calling the method as shown in the code example below.

/* * The code below assumes that pD3D is a valid pointer * to a IDirect3D9 interface. */ if( SUCCEEDED(pD3D->CheckDeviceMultiSampleType( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL , D3DFMT_R8G8B8, FALSE, D3DMULTISAMPLE_2_SAMPLES, NULL ) ) ) // Full-scene antialiasing is supported. Enable it here.

The first parameter that accepts is an ordinal number that denotes the display adapter to query. This sample uses D3DADAPTER_DEFAULT to specify the primary display adapter. The second parameter is a value from the enumerated type, specifying the device type. The third parameter specifies the format of the surface. The fourth parameter tells Direct3D whether to inquire about full-windowed multisampling (TRUE) or full-scene antialiasing (FALSE). This sample uses FALSE to tell Direct3D that it is inquiring about full-scene antialiasing. The last parameter specifies the multisampling technique that you want to test. Use a value from the enumerated type. This sample tests to see if two levels of multisampling are supported.

If the device supports the level of multisampling that you want to use, the next step is to set the presentation parameters by filling in the appropriate members of the structure to create a multisample rendering surface. After that, you can create the device. The sample code below shows how to set up a device with a multisampling render surface.

/* * The example below assumes that pD3D is a valid pointer * to a IDirect3D9 interface, d3dDevice is a pointer to a * IDirect3DDevice9 interface, and hWnd is a valid handle * to a window. */ D3DPRESENT_PARAMETER d3dPP ZeroMemory( &d3dPP, sizeof( d3dPP ) ); d3dPP.Windowed = FALSE d3dPP.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dPP.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES; pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3dDevice)

To use multisampling, the SwapEffect member of D3DPRESENT_PARAMETER must be set to D3DSWAPEFFECT_DISCARD.

The last step is to enable multisampling antialiasing by calling the method and setting the D3DRS_MULTISAMPLEANTIALIAS to TRUE. After setting this value to TRUE, any rendering that you do will have multisampling applied to it. You might want to enable and disable multisampling, depending on what you are rendering.

阅读(1726) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~