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 anANISOTROPICfilter variant. - Before compressing — if both mipmaps and compression are needed, pass
truehere;self:compresscannot generate mipmaps, so this is the only opportunity.
Parameters
| Type | Name | Description |
|---|---|---|
string | path | File path to a supported texture asset Refer Formats section |
bool | mipmaps | Determines whether to generate a mipmap chain for the underlying texture |
Returns
| Type | Name | Description |
|---|---|---|
texture | instance | Created texture instance |
Formats
| Format | Extension | Description |
|---|---|---|
| JPEG | .jpg | .jpeg | Lossy compressed image, best for photos |
| PNG | .png | Lossless compressed image, supports transparency |
| WebP | .webp | Modern format, supports both lossy and lossless |
| BMP | .bmp | Uncompressed bitmap, no lossy artifacts |
| DDS | .dds | GPU-native compressed format, ideal for 3D assets |
| KTX | .ktx | .ktx2 | Khronos texture format, supports GPU compression and mipmaps |
Examples
local entity = core.texture.create("assets/photo.jpg")local entity = core.texture.create("assets/sprite.png")local entity = core.texture.create("assets/image.webp")local entity = core.texture.create("assets/terrain.dds")local entity = core.texture.create("assets/terrain/cliff_diffuse.png", true)
entity:set_filter(core.texture.texture_filter.LINEAR_MIPMAPANISOTROPIC)