SafiMaterial
The engine ships a single material type: unlit textured. It owns a SDL_GPUGraphicsPipeline, a SDL_GPUSampler, and (optionally) a base-color SDL_GPUTexture.
For glTF files with multiple materials, use SafiModel instead of managing SafiMaterial instances directly. SafiModel handles material deduplication, per-primitive texture binding, and fallback textures automatically.
Only the unlit textured material exists. The following are not yet implemented:
- PBR / lit materials — no metallic-roughness or normal-map pipeline
- Alpha modes — no opaque/mask/blend handling (
enable_blend = false) - Material parameters — no generalized uniform/parameter block; only base-color texture
- Double-sided flag — culling is globally disabled rather than per-material
- Texture abstraction — textures are raw
SDL_GPUTexture*inside the material, not standalone assets
See Lighting and Asset System.
Types
Functions
safi_material_create_unlit
Loads the compiled unlit shader artifacts from shader_dir via safi_shader_load (both vs_main and fs_main stages) and builds a graphics pipeline that:
- reads
SafiVertexfrom vertex buffer slot 0 - draws triangle lists with back-face culling and counter-clockwise front faces
- writes depth using
LESScomparison - blends one color attachment in swapchain format
Also creates a trilinear REPEAT sampler.
safi_material_set_base_color_rgba8
Uploads an RGBA8 texture and binds it as the base color. Replaces any previously bound texture. safi_gltf_load and safi_model_load call this automatically when the glTF has a base-color texture.
safi_material_destroy
Shader inputs
The default HLSL uses these bindings — if you write your own shader, match them or override the pipeline:
Example
See also
safi_shader_loadSafiMeshSafiModel— multi-material model loading