Skip to content

Commit

Permalink
VOXELFORMAT: VOX: support _media_type
Browse files Browse the repository at this point in the history
  • Loading branch information
mgerhardy committed Mar 6, 2024
1 parent b7c179a commit 2f9c5f1
Showing 1 changed file with 39 additions and 16 deletions.
55 changes: 39 additions & 16 deletions src/modules/voxelformat/external/ogt_vox.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,25 +291,34 @@
static const uint32_t k_ogt_vox_matl_have_g = 1 << 12;
static const uint32_t k_ogt_vox_matl_have_media = 1 << 13;

// media type for blend, glass and cloud materials
enum ogt_media_type {
ogt_media_type_absorb, // Absorb media
ogt_media_type_scatter, // Scatter media
ogt_media_type_emit, // Emissive media
ogt_media_type_sss, // Subsurface scattering media
};

// Extended Material Chunk MATL information
typedef struct ogt_vox_matl
{
uint32_t content_flags; // set of k_ogt_vox_matl_* OR together to denote contents available
ogt_matl_type type;
float metal;
float rough;
float spec;
float ior;
float att;
float flux;
float emit; // Emit * (10 ^ Power) - https://twitter.com/ephtracy/status/846084473347342336
float ldr;
float trans;
float alpha;
float d;
float sp;
float g;
float media;
uint32_t content_flags; // set of k_ogt_vox_matl_* OR together to denote contents available
ogt_media_type media_type; // media type for blend, glass and cloud materials
ogt_matl_type type;
float metal;
float rough; // roughness
float spec; // specular
float ior; // index of refraction
float att; // attenuation
float flux; // radiant flux (power)
float emit; // emissive
float ldr; // low dynamic range
float trans; // transparency
float alpha;
float d; // density
float sp;
float g;
float media;
} ogt_vox_matl;

// Extended Material Chunk MATL array of materials
Expand Down Expand Up @@ -1677,6 +1686,20 @@
materials.matl[material_id].type = ogt_matl_type_media;
}
}
materials.matl[material_id].media_type = ogt_media_type_absorb;
const char* media_type_string = _vox_dict_get_value_as_string(&dict, "_media_type", NULL);
if (media_type_string) {
if (0 == _vox_strcmp(media_type_string,"_scatter")) {
materials.matl[material_id].media_type = ogt_media_type_scatter;
}
else if (0 == _vox_strcmp(media_type_string,"_emit")) {
materials.matl[material_id].media_type = ogt_media_type_emit;
}
else if (0 == _vox_strcmp(media_type_string,"_sss")) {
materials.matl[material_id].media_type = ogt_media_type_sss;
}
}

const char* metal_string = _vox_dict_get_value_as_string(&dict, "_metal", NULL);
if (metal_string) {
materials.matl[material_id].content_flags |= k_ogt_vox_matl_have_metal;
Expand Down

0 comments on commit 2f9c5f1

Please sign in to comment.