opengl - Multisampling in pipeline -
in multisampling, during rasterization there more 1 sample points in each pixel , sample points decided constitutes primitive.
which attributes same each sample in pixel? read somewhere color , texture values same depth , stensil values samples in pixel different. fragment shader executed each sample points should different.
also, when multiple samples resolved in pipeline, after fragment shader? , linearly average out?
first have realize how multisampling works , why created.
i going approach perspective of anti-aliasing, because primary use-case multisampling until multisample textures introduced in gl3.
when multisampled, means each sample point contains multiple samples. these samples may identical 1 if primitive has relatively uniform characteristics (e.g. has same depth everywhere) , smart gl/hardware implementations capable of identifying such situations , reducing memory bandwidth reading/writing shared samples intelligently (similar color/depth buffer compression). however, cost in terms of required storage 4x msaa framebuffer same 4x ssaa because gl has accommodate worst-case scenario, each of 4 samples unique.
which attributes same each sample in pixel?
each fragment may cover multiple sample points attributes such color, texture coordinates, etc. rather invoking fragment shader 4x achieve 4x anti-aliasing, trick devised each attribute sampled @ fragment center (this default) , single output written each of covered sample locations. default behavior lacking in situation center of fragment not part of actual coverage area - this, centroid sampling introduced... vertex attributes interpolated @ center of primitive's coverage area within fragment rather center of fragment itself.
later, when comes time write color framebuffer, of these samples need averaged produce single pixel; call multisample resolve. works things, not address issues of aliasing occurs during fragment shading itself.
texturing occurs during execution of fragment shader, , means sample frequency texturing remains same, msaa not texture aliasing. thus, while supersample anti-aliasing improves both aliasing @ geometric edges and texture / shader aliasing (things specular highlights), multisampling reduces "jaggies."
i read somewhere color , texture values same depth , stensil values samples in pixel different.
in short, computed in fragment shader same covered samples. can determined before fragment shading (e.g. depth) may vary.
fragment tests such depth/stencil evaluated each sub-sample. multisampled depth buffers carry restrictions. until d3d 10.1, hardware not required support multisampled depth textures not sample multisampled depth buffers in fragment shader.
but fragment shader executed each sample points should different.
there feature called sample shading, can force implementation of msaa work more ssaa improving ratio between fragments shaded , samples generated during rasterization. default, behavior describing not multisampling.
when multiple samples resolved in pipeline, after fragment shader? , linearly average out?
multisample resolution occurs after fragment shading, anytime have write contents of multisampled buffer singlesampled buffer. includes things glblitframebuffer (...). can manually implement multisample resolution in fragment shader, if use multisampled textures.
finally, regarding process used multisample resolution, implementation-specific sample layout. if ever open display driver's control panel , @ myriad of anti-aliasing options available see multiple options sample layout , msaa resolve algorithm.
i highly suggest take @ this article. while related d3d10+ , not opengl, general rules apply both apis (d3d9 has different rules) , quality of diagrams phenomenal.
in particular, pay special attention section on msaa rasterization rules triangles, states:
for triangle, coverage test performed each sample location (not pixel center). if more 1 sample location covered, pixel shader runs once attributes interpolated @ pixel center. result stored (replicated) each covered sample location in pixel passes depth/stencil test.
Comments
Post a Comment