Skip to content

Textures

The renderer supports two texture dimensionalities - Texture2D for flat images and Texture3D / cubemaps for volumetric and environment data. Both are managed by ResourceManager and loaded asynchronously per backend.

Texture2D

A Texture2D wraps a single 2D image. Common uses include albedo maps, normal maps, roughness/metallic maps, and shadow map reads.

Registration

cpp
auto res = ResourceManager::get();

res->register_texture(Texture2DDescriptor::create("albedo", "textures/albedo.png"_engine));
res->register_texture(Texture2DDescriptor::create("normal", "textures/normal.png"_engine));

Descriptor Fields

FieldTypeDescription
idstd::stringUnique identifier used to look up the texture
pathPathEngine-relative path to the image file
formatTextureFormatPixel format (inferred from file if omitted)
generate_mipmapsboolWhether to build the full mip chain on upload
wrapTextureWrapUV wrapping mode (Repeat, ClampToEdge, etc.)
filterTextureFilterSampling filter (Linear, Nearest)

Sampling in a Pass

Textures are bound through the active GraphicsPipeline or shader uniform:

cpp
auto* tex = ResourceManager::get()->get_texture2d("albedo");
pipeline->bind_texture(tex, /* slot */ 0);

Texture3D & Cubemaps

Texture3D covers both volumetric textures (e.g. LUT volumes) and cubemaps (six-face environment maps used by the skybox and IBL).

Cubemap Registration

cpp
res->register_texture(Texture3DDescriptor::create(
    "sky_cubemap",
    {
        "textures/skybox/right.png"_engine,
        "textures/skybox/left.png"_engine,
        "textures/skybox/top.png"_engine,
        "textures/skybox/bottom.png"_engine,
        "textures/skybox/front.png"_engine,
        "textures/skybox/back.png"_engine,
    }
));

Usage with Skybox

cpp
// In Scene::start()
auto* skybox = add_entity<Skybox>("Sky");
skybox->cubemap_id = "sky_cubemap";
skybox->shader_id  = "skybox_shader";
skybox->add_component<MeshComponent>();
skybox->add_component<ResourceComponent>();

SkyboxPass resolves the cubemap handle each frame and binds it as a samplerCube uniform.

Uploading

Both types are uploaded together with the rest of the descriptors:

cpp
res->load_from_descriptors<Texture2DDescriptor, Texture3DDescriptor>(
    RendererBackend::OpenGL
);

See Async Resource Loading for details on load states and generational handles.

Formats

FormatUsage
RGBA8Standard color textures
RGBA16FHDR color, render targets
DEPTH_ONLYShadow maps, depth prepass
R8Single-channel masks, AO
RG16FNormal maps (BC5 variant)