Atualizado em 2023/10/21
Tempos estimado de leitura: 2 min

Rasterization is the process by which a primitive is converted to a two-dimensional image. Each discrete location of this image contains associated data such as depth, color, or other attributes.

Rasterizing a primitive begins by determining which squares of an integer grid in framebuffer coordinates are occupied by the primitive, and assigning one or more depth values to each such square. This process is described below for points, lines, and polygons.

A grid square, including its (x,y) framebuffer coordinates, z (depth), and associated data added by fragment shaders, is called a fragment. A fragment is located by its upper left corner, which lies on integer grid coordinates.

Rasterization operations also refer to a fragment’s sample locations, which are offset by fractional values from its upper left corner. The rasterization rules for points, lines, and triangles involve testing whether each sample location is inside the primitive. Fragments need not actually be square, and rasterization rules are not affected by the aspect ratio of fragments. Display of nonsquare grids, however, will cause rasterized points and line segments to appear fatter in one direction than the other.

We assume that fragments are square, since it simplifies antialiasing and texturing. After rasterization, fragments are processed by fragment operations.

Several factors affect rasterization, including the members of VkPipelineRasterizationStateCreateInfo and VkPipelineMultisampleStateCreateInfo.

The afxPipelineRasterizationConfig structure is defined as:

    afxBool depthClampEnabled; /// controls whether to clamp the fragment’s depth values as described in Depth
 Test. Enabling depth clamp will also disable clipping primitives to the z planes of the frustrum
 as described in Primitive Clipping.
    afxBool rasterizerDiscardEnabled; /// controls whether primitives are discarded immediately before the
 rasterization stage.
    afxFillMode fillMode; /// is the triangle rendering mode.
    afxCullMode cullMode; /// is the triangle facing direction used for primitive culling.
    afxBool cwFrontFacing; /// is a value specifying the front-facing triangle orientation to be used for
    afxBool depthBiasEnabled; /// controls whether to bias fragment depth values.
    afxReal depthBiasConstFactor; /// is a scalar factor controlling the constant depth value added to each
    afxReal depthBiasClamp; /// is the maximum (or minimum) depth bias of a fragment.
    afxReal depthBiasSlopeFactor; /// is a scalar factor applied to a fragment's slope in depth bias calculations.
    afxReal lineWidth; /// is the width of rasterized line segments.

The afxPipelineMultisamplingConfig structure is defined as:

VkPipelineMultisampleStateCreateFlags flags;
VkSampleCountFlagBits rasterizationSamples; /// is a value specifying the number of samples used
 in rasterization.
    afxBool sampleShadingEnabled; /// can be used to enable Sample Shading.
    afxReal minSampleShading; /// specifies a minimum fraction of sample shading if sampleShadingEnabled is set to
    afxNat32 const* sampleBitmasks; /// is an array of values used in the sample mask test.
    afxBool alphaToCoverageEnabled; /// controls whether a temporary coverage value is generated based on the
 alpha component of the fragment's first color output as specified in the Multisample Coverage
    afxBool alphaToOneEnabled; ///  controls whether the alpha component of the fragment's first color output is
 replaced with one as described in Multisample Coverage.

Each bit in the sample mask is associated with a unique sample index as defined for the coverage mask. Each bit b for mask word w in the sample mask corresponds to sample index i, where i = 32 × w + b. sampleBitmasks has a length equal to rasterizationSamples / 32 words.

If sampleBitmasks is NULL, it is treated as if the mask has all bits set to 1.

The elements of the sample mask array are of type afxNat32, each representing 32 bits of
coverage information.

Rasterization only generates fragments which cover one or more pixels inside the framebuffer. Pixels outside the framebuffer are never considered covered in the fragment. Fragments which would be produced by application of any of the primitive rasterization rules described below but which lie outside the framebuffer are not produced, nor are they processed by any later stage of the pipeline, including any of the fragment operations.

Surviving fragments are processed by fragment shaders. Fragment shaders determine associated data for fragments, and can also modify or replace their assigned depth values.

Esta publicação foi útil?
Desaprovar 0
Leituras: 2


Translate »