Texture

Reference for the Texture class, which represents an image loaded into GPU memory and provides pixel‑level access, filtering and saving.

Texture

Texture(value, filtering='default')

Located in ursina/texture.py :contentReference[oaicite:0]{index=0}

Important

Looking for textures to add to your game? Browse community‑made shaders in the /assets folder.

👉 Browse Community Assets

Overview

The Texture class wraps a Panda3D texture object. It’s normally created for you when you assign a texture path or PIL image to an Entity. You can also manipulate pixels directly, change filtering modes, generate blank textures, and save to disk.

Constructor Arguments

ArgumentTypeDefaultDescription
valueanyPath, PIL Image, or existing Panda3D Texture object.
filteringstr'default'Filtering mode: 'default', 'nearest', 'linear'.

Properties

PropertyDescription
.nameInternal name or path of the texture.
.size(width, height) tuple in pixels.
.widthPixel width.
.heightPixel height.
.pixelsFlat list or buffer of pixel data.
.filteringCurrent filtering mode ('nearest' vs. 'linear').
.repeatUV wrap mode (True to repeat, False to clamp).

Methods

MethodDescription
new(size, color=(255,255,255))Create a blank texture of given size filled with color.
get_pixel(x, y)Return the RGBA tuple of the pixel at (x,y).
get_pixels(start, end)Return a list of pixel tuples from flat index start to end.
set_pixel(x, y, color)Change the pixel at (x,y) to the given RGBA color tuple.
apply()Upload any pixel changes to GPU memory.
save(path)Write the texture to disk at the given filesystem path.

Example Usage

from ursina import *
from ursina import texture_importer

app = Ursina()

# assign a texture by name (auto‑loaded/compressed)
e = Entity(model='quad', texture='brick')

# manually change one pixel to blue
e.texture.set_pixel(0, 2, color.blue)

# push the change to the GPU
e.texture.apply()

app.run()