Docsity

OpenGL: Texturing, Filtering, Mipmapping, Anisotropic Filtering, AA, Study notes of Computer Science

Partial preview of the text

Download OpenGL: Texturing, Filtering, Mipmapping, Anisotropic Filtering, AA and more Study notes Computer Science in PDF only on Docsity!

Texturing and Sampling

๎€Š (^) Mipmapping ๎€Š Automatic mipmap generation ๎€Š (^) Generate mipmaps on the GPU ๎€Š (^) Framebuffer attached textures ๎€Š (^) Anisotropic texture filtering ๎€Š (^) Non-power-of-two textures ๎€Š Multisample Antialiasing

Image Representation

๎€Š (^) Continuous signal represented as discrete samples ๎€Š Nyquist sampling rate ๎€Š (^) At least 2 times the highest frequency in the image Continuous signal and undersampled reconstruction.

Mipmapping

๎€Š Mip (โ€œ multum in parvoโ€ = โ€œmany in a small placeโ€ ) ๎€Š Representation of an image at multiple scales ๎€Š (^) High spatial resolution image with high frequencies ๎€Š (^) Lower spatial resolution image with low frequencies To generate mipmaps : ๎€Š (^) Start from the highest resolution image (level = 0) ๎€Š (^) Smooth (low pass filter) ๎€Š (^) Subsample (take every other pixel)

Texture filtering

๎€Š (^) Magnification ๎€Š (^) GL_NEAREST โ€“ nearest texel center (1) ๎€Š (^) GL_LINEAR โ€“ weighted average of surrounding 4 texels (4) ๎€Š Minification ๎€Š (^) GL_NEAREST, GL_LINEAR ๎€Š (^) GL_NEAREST_MIPMAP_NEAREST (1) ๎€Š (^) Choose mipmap with texel size nearest the pixels size ๎€Š (^) Do nearest neighbor filtering within that mipmap ๎€Š (^) GL_LINEAR_MIPMAP_NEAREST (bilinear) (4) ๎€Š (^) Linear filtering within the nearest mipmap ๎€Š (^) GL_NEAREST_MIPMAP_LINEAR (2) ๎€Š (^) Nearest filtering within two mipmap levels, then average ๎€Š (^) GL_LINEAR_MIPMAP_LINEAR (trilinear) (8) ๎€Š (^) Linear filtering within two mipmap levels, then average (required texture reads)

Anisotropic texture filtering

๎€Š (^) When the slope of a textured object is high with respect to the view plane the degree of minification may be much greater in one direction than another. Image from โ€œAdvanced Graphics Programming Techniques Using OpenGLโ€ SIGGRAPH Course 1999

Anisotropic texture filtering

๎€Š (^) We may require different sampling rates in different directions. ๎€Š (^) This ratio (higher/lower) is referred to as the anisotropy Image from โ€œAdvanced Graphics Programming Techniques Using OpenGLโ€ SIGGRAPH Course 1999

Without anisotropic filtering

Anisotropic texture filtering in OpenGL

An EXT extension ๎€Š (^) glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &max_anisotropy); ๎€Š (^) anisotropy is the maximum supported anisotropy level (driver and HW dependent) ๎€Š (^) glTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, aniso); ๎€Š (^) Sets the maximum anisotropy to use for the currently bound texture object. ๎€Š (^) 1.0 is isotropic ๎€Š (^) Be careful ๎€Š (^) Could require 64 texture reads when anisotropy = 8.

Non-power-of-two (NPOT) Textures

Core feature since OpenGL 2. ๎€Š (^) Allows textures with width and height that are not a power of two. ๎€Š Requires no code changes. ๎€Š (^) Works for all texture targets ๎€Š (^) Cube faces must still be square ๎€Š (^) Mipmap sizes round down ๎€Š (^) Performance penalty is likely ๎€Š (^) You should still prefer power-of-two textures ๎€Š Also see ARB_texture_rectangle

MSAA

๎€Š (^) Coverage โ€“ 1 bit per sample ๎€Š (^) If sample inside polygon then coverage = 1 ๎€Š (^) Otherwise coverage = 0 No antialiasing : One sample per pixel Multisample antialiasing : 16 samples per pixel

Multisample rasterization

๎€Š (^) Per pixel computations ๎€Š (^) Lighting ๎€Š (^) Texturing ๎€Š (^) Fragment shading ๎€Š (^) All covered samples in the sample pixel have the same color. ๎€Š (^) Color buffer will be very compressible ๎€Š Per sample computations ๎€Š (^) Coverage bit ๎€Š (^) Depth (if coverage == 1) ๎€Š Contrast with supersampling approach ๎€Š (^) Everything is done per sample.

Occlusion Queries

Core feature as of OpenGL 1. ๎€Š (^) Promoted from ARB extension ๎€Š How many pixels get drawn by some sequence of commands? ๎€Š (^) Visibility testing ๎€Š (^) Don't draw what you can't see ๎€Š (^) Level-of-detail selection ๎€Š (^) Draw less detail for objects you can barely see. ๎€Š (^) Perform query for simple bounding geometry, such as a boxes. More info in OpenGL spec and ARB_occlusion_query spec.

Occlusion Queries

Object creation/destruction ๎€Š (^) glGenQueries(n, *ids) ๎€Š glDeleteQueries(n, *ids) ๎€Š Can create multiple query objects, but only one can be active at a time. Start/end query ๎€Š (^) glBeginQuery(target, id) ๎€Š (^) target = GL_SAMPLES_PASSED ๎€Š glEndQuery(target)