$darkmode
Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
material.c File Reference
#include "material.h"
#include "io.h"
#include "log.h"
#include "utils.h"
#include <cJSON.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for material.c:

Macros

#define MAT_DEFAULT_ROUGHNESS   0.5F
 
#define MAT_DEFAULT_ALBEDO   0.0F
 
#define MAT_DEFAULT_METALLIC   0.0F
 

Enumerations

enum  { MAX_MATERIAL_CONFIG_SIZE = 2 * 1024 * 1024 }
 
enum  { MAX_MATERIAL_COUNT = 10000 , RGB_COMPONENTS = 3 }
 

Functions

static void parse_material_name (cJSON *element, PBRMaterial *mat)
 
static void parse_albedo_array (cJSON *element, PBRMaterial *mat)
 
static void parse_material_properties (cJSON *element, PBRMaterial *mat)
 
static PBRMaterialallocate_materials (int count)
 
static int parse_materials_from_json (cJSON *json_root, PBRMaterial *materials, int max_count)
 
MaterialLibmaterial_load_presets (const char *path)
 Loads a set of material presets from a configuration file. More...
 
void material_free_lib (MaterialLib *lib)
 Frees all memory associated with a material library. More...
 

Macro Definition Documentation

◆ MAT_DEFAULT_ALBEDO

#define MAT_DEFAULT_ALBEDO   0.0F

◆ MAT_DEFAULT_METALLIC

#define MAT_DEFAULT_METALLIC   0.0F

◆ MAT_DEFAULT_ROUGHNESS

#define MAT_DEFAULT_ROUGHNESS   0.5F

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
MAX_MATERIAL_CONFIG_SIZE 

◆ anonymous enum

anonymous enum
Enumerator
MAX_MATERIAL_COUNT 
RGB_COMPONENTS 

Function Documentation

◆ allocate_materials()

static PBRMaterial* allocate_materials ( int  count)
static

◆ material_free_lib()

void material_free_lib ( MaterialLib lib)

Frees all memory associated with a material library.

Parameters
libPointer to the library to destroy.

◆ material_load_presets()

MaterialLib* material_load_presets ( const char *  path)

Loads a set of material presets from a configuration file.

Parameters
pathPath to the material description file.
Returns
Pointer to the allocated library, or NULL on failure.
Here is the call graph for this function:

◆ parse_albedo_array()

static void parse_albedo_array ( cJSON *  element,
PBRMaterial mat 
)
static

◆ parse_material_name()

static void parse_material_name ( cJSON *  element,
PBRMaterial mat 
)
static

◆ parse_material_properties()

static void parse_material_properties ( cJSON *  element,
PBRMaterial mat 
)
static

◆ parse_materials_from_json()

static int parse_materials_from_json ( cJSON *  json_root,
PBRMaterial materials,
int  max_count 
)
static
Here is the call graph for this function: