Difference between revisions of "PixelFormat"

m (0.110 -> 11.0)
m
Line 145: Line 145:
  
 
== Depth / stencil formats ==
 
== Depth / stencil formats ==
All depth and stencil pixel formats are only usable in [[Canvas]]es. They are [[Texture:isReadable|non-readable]] by default, and Canvases with a depth/stencil format created with the [[love.graphics.newCanvas|readable flag]] can only access the depth values of their pixels in shaders (stencil values are not readable no matter what).
+
All depth and stencil pixel formats are only usable in [[Canvas]]es.
 +
 
 +
They are [[Texture:isReadable|non-readable]] by default, and Canvases with a depth/stencil format created with the [[love.graphics.newCanvas|readable flag]] can only access the depth values of their pixels in shaders (stencil values are not readable no matter what).
 
=== Constants ===
 
=== Constants ===
 
{| class="wikitable"
 
{| class="wikitable"
Line 192: Line 194:
  
 
== Compressed formats ==
 
== Compressed formats ==
All compressed pixel formats are only usable in [[Image]]s via [[CompressedImageData]] (compressed textures). Unlike regular color formats, these stay compressed in RAM and VRAM. This is good for saving memory space as well as improving performance, since the graphics card will be able to keep more of the image's pixels in its fast-access cache when drawing it.
+
All compressed pixel formats are only usable in [[Image]]s via [[CompressedImageData]] (compressed textures).
 +
 
 +
Unlike regular color formats, these stay compressed in RAM and VRAM. This is good for saving memory space as well as improving performance, since the graphics card will be able to keep more of the image's pixels in its fast-access cache when drawing it.
  
 
=== Constants ===
 
=== Constants ===
Line 206: Line 210:
 
|4
 
|4
 
|[0, 1]
 
|[0, 1]
|
+
|Suitable for fully opaque images on desktop systems.
 +
|-
 +
|DXT3
 +
|4
 +
|8
 +
|[0, 1]
 +
|Smooth variations in opacity do not mix well with this format. DXT1 or DXT5 is generally better in every situation.
 +
|-
 +
|DXT5
 +
|4
 +
|8
 +
|[0, 1]
 +
|Recommended for images with varying opacity on desktop systems.
 +
|-
 +
|BC4
 +
|1
 +
|4
 +
|[0, 1]
 +
|Also known as 3Dc+ or ATI1. Stores just the red channel.
 +
|-
 +
|BC4s
 +
|1
 +
|4
 +
|[-1, 1]
 +
|Less precision than BC4 but allows negative numbers.
 +
|-
 +
|BC5
 +
|2
 +
|8
 +
|[0, 1]
 +
|Also known as 3Dc or ATI2. Often used for normal maps on desktop systems.
 +
|-
 +
|BC5s
 +
|2
 +
|8
 +
|[1, 1]
 +
|Less precision than BC5 but allows negative numbers. Often used for normal maps on desktop systems.
 +
|-
 +
|BC6h
 +
|3
 +
|8
 +
|[0, +infinity]
 +
|Stores [https://en.wikipedia.org/wiki/Half-precision_floating-point_format half-precision] floating point RGB data. Suitable for HDR images on desktop systems.
 +
|-
 +
|BC6hs
 +
|3
 +
|8
 +
|[-infinity, +infinity]
 +
|Less precision than BC6h but allows negative numbers.
 +
|-
 +
|BC7
 +
|4
 +
|8
 +
|[0, 1]
 +
|Very good at representing opaque or transparent images, but requires a DX11 / OpenGL 4-capable GPU.
 
|}
 
|}
  

Revision as of 23:52, 4 September 2018

Available since LÖVE 11.0
This enum replaces CanvasFormat and CompressedImageFormat.

Pixel formats for Textures, ImageData, and CompressedImageData.

O.png This page is a work-in-progress.  


Normal color formats

Constants

Name Components Bits per pixel Range Usable with Canvases Usable with ImageData Note(s)
r8 1 8 [0, 1] Yes
rg8 2 16 [0, 1] Yes
rgba8 4 32 [0, 1] Yes Yes
srgba8 4 32 [0, 1] Yes gamma-correct version of rgba8.
rgba16 4 64 [0, 1] Yes
r16f 1 16 [-65504, +65504] Yes
rg16f 2 32 [-65504, +65504] Yes
rgba16f 4 64 [-65504, +65504] Yes Yes
r32f 1 32 [-infinity, +infinity] Yes
rg32f 2 64 [-infinity, +infinity] Yes
rgba32f 4 128 [-infinity, +infinity] Yes Yes
rgba4 4 16 [0, 1] Yes
rgb5a1 4 16 [0, 1] Yes
rgb565 3 16 [0, 1] Yes
rgb10a2 4 32 [0, 1] Yes
rg11b10f 3 32 [0, 65024] Yes

Depth / stencil formats

All depth and stencil pixel formats are only usable in Canvases.

They are non-readable by default, and Canvases with a depth/stencil format created with the readable flag can only access the depth values of their pixels in shaders (stencil values are not readable no matter what).

Constants

Name Bits per pixel Has depth Has stencil Note(s)
stencil8 8 Yes
depth16 16 Yes
depth24 24 Yes
depth32f 32 Yes
depth24stencil8 32 Yes Yes
depth32fstencil8 40 Yes Yes

Compressed formats

All compressed pixel formats are only usable in Images via CompressedImageData (compressed textures).

Unlike regular color formats, these stay compressed in RAM and VRAM. This is good for saving memory space as well as improving performance, since the graphics card will be able to keep more of the image's pixels in its fast-access cache when drawing it.

Constants

Name Components Bits per pixel Range Note(s)
DXT1 3 4 [0, 1] Suitable for fully opaque images on desktop systems.
DXT3 4 8 [0, 1] Smooth variations in opacity do not mix well with this format. DXT1 or DXT5 is generally better in every situation.
DXT5 4 8 [0, 1] Recommended for images with varying opacity on desktop systems.
BC4 1 4 [0, 1] Also known as 3Dc+ or ATI1. Stores just the red channel.
BC4s 1 4 [-1, 1] Less precision than BC4 but allows negative numbers.
BC5 2 8 [0, 1] Also known as 3Dc or ATI2. Often used for normal maps on desktop systems.
BC5s 2 8 [1, 1] Less precision than BC5 but allows negative numbers. Often used for normal maps on desktop systems.
BC6h 3 8 [0, +infinity] Stores half-precision floating point RGB data. Suitable for HDR images on desktop systems.
BC6hs 3 8 [-infinity, +infinity] Less precision than BC6h but allows negative numbers.
BC7 4 8 [0, 1] Very good at representing opaque or transparent images, but requires a DX11 / OpenGL 4-capable GPU.

See Also

Other Languages