CanvasFormat
Available since LÖVE 0.9.0
This enum is not supported in earlier versions.
Canvas formats.
Constants
- normal
- The default Canvas format - usually an alias for the
rgba8
format, or thesrgb
format if gamma-correct rendering is enabled in LÖVE 0.10.0 and newer. - hdr
- A format suitable for high dynamic range content - an alias for the
rgba16f
format, normally.
- rgba8 Available since 0.9.2
- 8 bits per channel (32 bpp) RGBA. Color channel values range from 0-255 (0-1 in shaders).
- rgba4 Available since 0.9.2
- 4 bits per channel (16 bpp) RGBA.
- rgb5a1 Available since 0.9.2
- RGB with 5 bits each, and a 1-bit alpha channel (16 bpp).
- rgb565 Available since 0.9.2
- RGB with 5, 6, and 5 bits each, respectively (16 bpp). There is no alpha channel in this format.
- rgb10a2 Available since 0.9.2
- RGB with 10 bits per channel, and a 2-bit alpha channel (32 bpp).
- rgba16f Available since 0.9.2
- Floating point RGBA with 16 bits per channel (64 bpp). Color values can range from [-65504, +65504].
- rgba32f Available since 0.9.2
- Floating point RGBA with 32 bits per channel (128 bpp).
- rg11b10f Available since 0.9.2
- 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, +65024].
- srgb Available since 0.9.2
- 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. This reduces color banding when doing gamma-correct rendering, since sRGB encoding has more precision than linear RGB for darker colors.
- r8 Available since 0.10.0
- Single-channel (red component) format (8 bpp).
- rg8 Available since 0.10.0
- Two channels (red and green components) with 8 bits per channel (16 bpp).
- r16f Available since 0.10.0
- Floating point single-channel format (16 bpp). Color values can range from [-65504, +65504].
- rg16f Available since 0.10.0
- Floating point two-channel format with 16 bits per channel (32 bpp). Color values can range from [-65504, +65504].
- r32f Available since 0.10.0
- Floating point single-channel format (32 bpp).
- rg32f Available since 0.10.0
- Floating point two-channel format with 32 bits per channel (64 bpp).
Notes
The 16 bpp RGB and RGBA formats use half as much VRAM as the 32 bpp RGBA formats, but they have significantly lower quality.
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
, and rgb5a1
are supported everywhere. rgb10a2
is also supported everywhere on desktop platforms.
The regular single- and two-channel formats (r8
and rg8
), as well as the srgb
format, are supported on desktop 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), and mobile GPUs capable of OpenGL ES 3.
The floating-point formats (rgba16f
, rgba32f
, rg11b10f
, r16f
, rg16f
, r32f
, and rg32f
) are supported on OpenGL 3-capable desktop graphics cards, and some OpenGL ES 3 mobile GPUs. The 32-bit-per-channel floating point formats are rarely supported on mobile devices.
rgb565
is often only supported on OpenGL ES / mobile devices, or with very new desktop OpenGL drivers.