self:set_filter

Client

Sets the sampling filter of the texture


Syntax

local status = self:set_filter(
    mode
)

Mipmap-based filters require the texture to already have a mipmap chain — no chain is generated on demand.
NEAREST_MIPMAP, LINEAR_MIPMAP, and their ANISOTROPIC variants throw if the texture was created without mipmaps.

Parameters

TypeNameDescription
core.texture.texture_filtermodeSampling filter to apply

Returns

TypeNameDescription
boolstatustrue on successful execution, false otherwise

Examples

Force crisp nearest-neighbour sampling for pixel art
local entity = core.texture.create("assets/tiles/grass0.png")

entity:set_filter(core.texture.texture_filter.NEAREST)
Reset a texture back to the inherited default filter
local entity = core.texture.create("assets/sprite.png")

entity:set_filter(core.texture.texture_filter.NEAREST)
entity:set_filter(core.texture.texture_filter.DEFAULT)
Apply a mipmap filter
local entity = core.texture.create("assets/terrain/cliff_diffuse.png", true)

entity:set_filter(core.texture.texture_filter.LINEAR_MIPMAP_ANISOTROPIC)
Set filter before compressing - override carries through
local entity = core.texture.create("assets/terrain/cliff_diffuse.png", true)

entity:set_filter(core.texture.texture_filter.LINEAR_MIPMAP)
entity:compress(core.texture.compression_mode.BPTC)

On this page