分类: LINUX
2012-02-14 09:58:00
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 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.
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.