core.texture.create

Client

Creates a new texture instance from a file path


Syntax

local instance = core.texture.create(
    path,
    mipmaps = false
)

Only needed if you already know a mipmap-based filter is coming.

  • Use it when — a texture is going to use NEAREST_MIPMAP, LINEAR_MIPMAP, or an ANISOTROPIC filter variant.
  • Before compressing — if both mipmaps and compression are needed, pass true here; self:compress cannot generate mipmaps, so this is the only opportunity.

Parameters

TypeNameDescription
stringpathFile path to a supported texture asset
Refer Formats section
boolmipmapsDetermines whether to generate a mipmap chain for the underlying texture

Returns

TypeNameDescription
textureinstanceCreated texture instance

Formats

FormatExtensionDescription
JPEG.jpg | .jpegLossy compressed image, best for photos
PNG.pngLossless compressed image, supports transparency
WebP.webpModern format, supports both lossy and lossless
BMP.bmpUncompressed bitmap, no lossy artifacts
DDS.ddsGPU-native compressed format, ideal for 3D assets
KTX.ktx | .ktx2Khronos texture format, supports GPU compression and mipmaps

Examples

Create a texture instance from a JPEG file
local entity = core.texture.create("assets/photo.jpg")
Create a texture instance from a PNG file
local entity = core.texture.create("assets/sprite.png")
Create a texture instance from a WebP file
local entity = core.texture.create("assets/image.webp")
Create a texture instance from a DDS file
local entity = core.texture.create("assets/terrain.dds")
Create a texture with mipmaps
local entity = core.texture.create("assets/terrain/cliff_diffuse.png", true)

entity:set_filter(core.texture.texture_filter.LINEAR_MIPMAPANISOTROPIC)

On this page