20 FEB 2026

rahulmnavneeth

material system

homedocs

Location

include/mop/material.h   — Public API
src/viewport/viewport.c  — Draw call population

Types

MopMaterial

typedef struct MopMaterial {
    MopColor    base_color;     /* Multiplied with vertex color    */
    float       metallic;       /* [0, 1], 0 = dielectric          */
    float       roughness;      /* [0, 1], 1 = fully rough         */
    MopVec3     emissive;       /* Self-illumination (added post-light) */
    MopTexture *albedo_map;     /* Optional albedo texture, NULL = none  */
    MopTexture *normal_map;     /* Optional normal map, NULL = none      */
} MopMaterial;

Default values (from mop_material_default()):

FieldDefault
base_color{1, 1, 1, 1} (white)
metallic0.0
roughness0.5
emissive{0, 0, 0}
albedo_mapNULL
normal_mapNULL

Functions

mop_material_default

MopMaterial mop_material_default(void);

Returns a material with sensible defaults. Use this as a starting point and override individual fields.

mop_mesh_set_material

void mop_mesh_set_material(MopMesh *mesh, const MopMaterial *material);

Assigns a material to a mesh. The material struct is copied — the application may free or modify its copy after the call.

Texture pointers (albedo_map, normal_map) are retained by reference. The textures must remain alive as long as the mesh uses them.

Interaction with Other Systems