Files Class List

Detailed Description

An implementation of alpha distribution methods. This implementation only works for textures with 8-bit channels.

Cem Yuksel. 2017. Alpha Distribution for Alpha Testing. PACM on CGIT (I3D 2018). http://www.cemyuksel.com/research/alphadistribution/

#include <cyAlphaDistribution.h>

Public Types

enum  Method { METHOD_ERROR_DIF , METHOD_PYRAMID }
 

Static Public Member Functions

static void FixAlpha (Method method, unsigned char *alpha, int width, int height, int spp=1)
 Fixes the alpha values of an image with the given width and height using the specified method. If the image will be used with alpha-to-coverage, the spp parameter should indicate the number of alpha samples; otherwise, it should be 1.
 
static void FixAlphaRGBA (Method method, unsigned char *image, int width, int height, int spp=1)
 Fixes the alpha values of an RGBA image with the given width and height using the specified method. Only the alpha channel of the image is modified, the RGB values are not altered. If the image will be used with alpha-to-coverage, the spp parameter should indicate the number of alpha samples; otherwise, it should be 1.
 
template<typename SAMPLE_MASK_TYPE = unsigned char>
static void GenerateSampleMaskTexture (SAMPLE_MASK_TYPE *sampleMask, unsigned char const *alpha, int width, int height, int spp)
 Generates a sample mask texture from the alpha values of an image with the given width and height. This sample mask texture can be used with the original texture for handling alpha-to-coverage. The spp parameter is the number of alpha samples that will be used.
 
template<typename SAMPLE_MASK_TYPE = unsigned char>
static void GenerateSampleMaskTextureRGBA (SAMPLE_MASK_TYPE *sampleMask, unsigned char const *image, int width, int height, int spp)
 Generates a sample mask texture from the alpha values of an RGBA image with the given width and height. This sample mask texture can be used with the original texture for handling alpha-to-coverage. The spp parameter is the number of alpha samples that will be used.
 

OpenGL Methods

static void FixTextureLevelAlpha (Method method, GLuint textureID, int level, int spp=1)
 Fixes the alpha values of a mipmap level of an OpenGL texture. If the image will be used with alpha-to-coverage, the spp parameter should indicate the number of alpha samples; otherwise, it should be 1.
 
static void FixTextureAlpha (Method method, GLuint textureID, int startingLevel=0, int spp=1)
 Fixes the alpha values of all mipmap levels of an OpenGL texture, starting with the given level. If the texture does not contain semi-transparent regions, modifying the first level (level zero) is not advisable, since the original values might work better with magnification filtering. If the image will be used with alpha-to-coverage, the spp parameter should indicate the number of alpha samples; otherwise, it should be 1.
 
static void FixTextureAlphaToSampleMask (Method method, GLuint textureID, int startingLevel=0)
 Fixes the alpha values of all mipmap levels of an OpenGL texture, starting with the given level. If the texture does not contain semi-transparent regions, modifying the first level (level zero) is not advisable, since the original values might work better with magnification filtering. The number of alpha samples for alpha-to-coverage is obtained from the current OpenGL context.
 

Member Enumeration Documentation

◆ Method

enum Method
Enumerator
METHOD_ERROR_DIF 

Error diffusion using Floyd–Steinberg dithering.

METHOD_PYRAMID 

Alpha Pyramid.