Difference between revisions of "love.graphics.newVolumeImage"

m
m
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{newin|[[0.11.0]]|110|type=function}}
+
{{newin|[[11.0]]|110|type=function}}
 
Creates a new [[TextureType|volume]] (3D) [[Image]].
 
Creates a new [[TextureType|volume]] (3D) [[Image]].
 
{{newobjectnotice}}
 
{{newobjectnotice}}
  
Volume images are 3D textures with width, height, and depth. They can't be rendered directly, they can only be used in [[Shader]] code (and sent to the shader via [[Shader:send]]).
+
Volume images are 3D textures with width, height, and depth. They can't be rendered directly, they can only be used in [[Shader]] code (and sent to the shader via [[Shader:send]]). Or, more accurately, the default shaders can't render volume images, and you need to make one yourself to do it.
  
 
To use a volume image in a Shader, it must be declared as a <code>VolumeImage</code> or <code>sampler3D</code> type (instead of <code>Image</code> or <code>sampler2D</code>). The <code>Texel(VolumeImage image, vec3 texcoords)</code> shader function must be used to get pixel colors from the volume image. The vec3 argument is a normalized texture coordinate with the z component representing the depth to sample at (ranging from [0, 1]).
 
To use a volume image in a Shader, it must be declared as a <code>VolumeImage</code> or <code>sampler3D</code> type (instead of <code>Image</code> or <code>sampler2D</code>). The <code>Texel(VolumeImage image, vec3 texcoords)</code> shader function must be used to get pixel colors from the volume image. The vec3 argument is a normalized texture coordinate with the z component representing the depth to sample at (ranging from [0, 1]).

Latest revision as of 13:32, 9 August 2020

Available since LÖVE 11.0
This function is not supported in earlier versions.

Creates a new volume (3D) Image.

O.png This function can be slow if it is called repeatedly, such as from love.update or love.draw. If you need to use a specific resource often, create it once and store it somewhere it can be reused!  



Volume images are 3D textures with width, height, and depth. They can't be rendered directly, they can only be used in Shader code (and sent to the shader via Shader:send). Or, more accurately, the default shaders can't render volume images, and you need to make one yourself to do it.

To use a volume image in a Shader, it must be declared as a VolumeImage or sampler3D type (instead of Image or sampler2D). The Texel(VolumeImage image, vec3 texcoords) shader function must be used to get pixel colors from the volume image. The vec3 argument is a normalized texture coordinate with the z component representing the depth to sample at (ranging from [0, 1]).

Volume images are typically used as lookup tables in shaders for color grading, for example, because sampling using a texture coordinate that is partway in between two pixels can interpolate across all 3 dimensions in the volume image, resulting in a smooth gradient even when a small-sized volume image is used as the lookup table.

Array images are a much better choice than volume images for storing multiple different sprites in a single array image for directly drawing them.

Function

Creates a volume Image given multiple image files with matching dimensions.

Synopsis

image = love.graphics.newVolumeImage( layers, settings )

Arguments

table layers
A table containing filepaths to images (or File, FileData, ImageData, or CompressedImageData objects), in an array. A table of tables can also be given, where each sub-table represents a single mipmap level and contains all layers for that mipmap.
table settings (nil)
Optional table of settings to configure the volume image, containing the following fields:
boolean mipmaps (false)
True to make the image use mipmaps, false to disable them. Mipmaps will be automatically generated if the image isn't a compressed texture format.
boolean linear (false)
True to treat the image's pixels as linear instead of sRGB, when gamma correct rendering is enabled. Most images are authored as sRGB.

Returns

Image image
A volume Image object.

Notes

Volume images are not supported on some older mobile devices. Use love.graphics.getTextureTypes to check at runtime.

See Also


Other Languages