Difference between revisions of "CanvasFormat"

m (Added note about support)
(constants: s/rgba5a1/rgb5a1/)
Line 5: Line 5:
 
;rgba8: 8 bits per channel (32 bpp) RGBA. Color channel values range from 0-255 (0-1 in shaders.)
 
;rgba8: 8 bits per channel (32 bpp) RGBA. Color channel values range from 0-255 (0-1 in shaders.)
 
;rgba4: 4 bits per channel (16 bpp) RGBA.
 
;rgba4: 4 bits per channel (16 bpp) RGBA.
;rgba5a1: RGB with 5 bits each, and a 1-bit alpha channel (16 bpp.)
+
;rgb5a1: RGB with 5 bits each, and a 1-bit alpha channel (16 bpp.)
 
;rgb565: RGB with 5, 6, and 5 bits each, respectively (16 bpp). There is no alpha channel in this format.
 
;rgb565: RGB with 5, 6, and 5 bits each, respectively (16 bpp). There is no alpha channel in this format.
 
;rgb10a2: RGB with 10 bits per channel, and a 2-bit alpha channel (32 bpp.)
 
;rgb10a2: RGB with 10 bits per channel, and a 2-bit alpha channel (32 bpp.)

Revision as of 01:39, 1 September 2014

Available since LÖVE 0.9.2
This enum is not supported in earlier versions.

Canvas formats.

Constants

normal
The default Canvas format - an alias for the rgba8 format, normally.
rgba8
8 bits per channel (32 bpp) RGBA. Color channel values range from 0-255 (0-1 in shaders.)
rgba4
4 bits per channel (16 bpp) RGBA.
rgb5a1
RGB with 5 bits each, and a 1-bit alpha channel (16 bpp.)
rgb565
RGB with 5, 6, and 5 bits each, respectively (16 bpp). There is no alpha channel in this format.
rgb10a2
RGB with 10 bits per channel, and a 2-bit alpha channel (32 bpp.)
hdr
A format suitable for high dynamic range content - an alias for the rgba16f format, normally.
rgba16f
Floating point RGBA with 16 bits per channel (64 bpp.) Color values can range from [-infinity, +infinity].
rgba32f
Floating point RGBA with 32 bits per channel (128 bpp.) Color values can range from [-infinity, +infinity].
rg11b10f
Floating point RGB with 11 bits in the red and green channels, and 10 bits in the blue channel (32 bpp.) There is no alpha channel. Color values can range from [0, +infinity].
srgb
The same as rgba8, but the Canvas is interpreted as being in the sRGB color space. Everything drawn to the Canvas will be converted from linear RGB to sRGB. When the Canvas is drawn (or used in a shader), it will be decoded from sRGB to linear RGB.

Notes

The 16 bpp formats use half as much VRAM as the 32 bpp formats, but they have significantly lower quality than regular rgba8.

The HDR / floating point formats are most useful when combined with pixel shaders. Effects such as tonemapped HDR with bloom can be accomplished, or the canvas can be used to store arbitrary non-color data such as positions which can then be used in a custom shader.

The sRGB format should only be used when doing gamma-correct rendering, which is an advanced topic and it's easy to get color-spaces mixed up. If you're not sure whether you need this, you might want to avoid it. Read more about gamma-correct rendering here, here, and here.

Not all systems support every format. Use love.graphics.getCanvasFormats to check before creating the Canvas.

In general, rgba8, rgba4, rgb5a1, and rgb10a2 are supported everywhere. The floating-point formats (rgba16f, rgba32f, and rg11b10f) and srgb are supported on graphics cards capable of OpenGL 3+ / DirectX 10+ (nvidia GeForce 8000 series and up, ATI/AMD HD 2000 series and up, and the Intel HD 2000 and up.) rgb565 is often only supported on OpenGL ES or very new desktop OpenGL drivers.

See Also

Other Languages