Esc

Gltf_Material

structextensionsince 0.36.1Source
  • macOS: Gltf_Material works on macOS
  • Linux: Gltf_Material works on Linux
  • Windows: Gltf_Material works on Windows
  • Wasm: Gltf_Material works on Wasm

Declaration

Gltf_Material :: struct @json(rename_all=camelCase) {
    pbr_metallic_roughness: *Gltf_Pbr; @json(default,skip_serializing_if=null)    normal_texture: *Gltf_Texture_Info; @json(default,skip_serializing_if=null)    occlusion_texture: *Gltf_Texture_Info; @json(default,skip_serializing_if=null)    emissive_texture: *Gltf_Texture_Info; @json(default,skip_serializing_if=null)    emissive_factor: [3] float32 = .[0, 0, 0]; @json(default)    alpha_mode: Gltf_Alpha_Mode = .OPAQUE; @json(default)    alpha_cutoff: float32 = 0.5; @json(default)    double_sided: bool = false; @json(default)    name: string; @json(default,skip_serializing_if=empty)    extensions: Json_Value; @json(default,skip_serializing_if=null)    extras: Json_Value; @json(default,skip_serializing_if=null)}

How a surface looks: PBR parameters, normal, occlusion and emissive inputs, and alpha handling.

Example↗
asset, error := gltf_load("{\"asset\":{\"version\":\"2.0\"},\"images\":[{\"uri\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==\"}],\"samplers\":[{\"magFilter\":9729,\"wrapS\":33071}],\"textures\":[{\"sampler\":0,\"source\":0}],\"materials\":[{\"pbrMetallicRoughness\":{\"baseColorTexture\":{\"index\":0},\"metallicFactor\":0.5},\"alphaMode\":\"BLEND\"}]}");
assert(error.kind == .NONE);
defer gltf_free(*asset);
material := asset.document.materials[0];
assert(material.alpha_mode == .BLEND && !material.double_sided);

See also