|
|
@@ -1,7 +1,7 @@
|
|
|
/**
|
|
|
* cgltf - a single-file glTF 2.0 parser written in C99.
|
|
|
*
|
|
|
- * Version: 1.13
|
|
|
+ * Version: 1.14
|
|
|
*
|
|
|
* Website: https://github.com/jkuhlmann/cgltf
|
|
|
*
|
|
|
@@ -505,6 +505,11 @@ typedef struct cgltf_anisotropy
|
|
|
cgltf_texture_view anisotropy_texture;
|
|
|
} cgltf_anisotropy;
|
|
|
|
|
|
+typedef struct cgltf_dispersion
|
|
|
+{
|
|
|
+ cgltf_float dispersion;
|
|
|
+} cgltf_dispersion;
|
|
|
+
|
|
|
typedef struct cgltf_material
|
|
|
{
|
|
|
char* name;
|
|
|
@@ -519,6 +524,7 @@ typedef struct cgltf_material
|
|
|
cgltf_bool has_emissive_strength;
|
|
|
cgltf_bool has_iridescence;
|
|
|
cgltf_bool has_anisotropy;
|
|
|
+ cgltf_bool has_dispersion;
|
|
|
cgltf_pbr_metallic_roughness pbr_metallic_roughness;
|
|
|
cgltf_pbr_specular_glossiness pbr_specular_glossiness;
|
|
|
cgltf_clearcoat clearcoat;
|
|
|
@@ -530,6 +536,7 @@ typedef struct cgltf_material
|
|
|
cgltf_emissive_strength emissive_strength;
|
|
|
cgltf_iridescence iridescence;
|
|
|
cgltf_anisotropy anisotropy;
|
|
|
+ cgltf_dispersion dispersion;
|
|
|
cgltf_texture_view normal_texture;
|
|
|
cgltf_texture_view occlusion_texture;
|
|
|
cgltf_texture_view emissive_texture;
|
|
|
@@ -4297,6 +4304,37 @@ static int cgltf_parse_json_anisotropy(cgltf_options* options, jsmntok_t const*
|
|
|
return i;
|
|
|
}
|
|
|
|
|
|
+static int cgltf_parse_json_dispersion(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_dispersion* out_dispersion)
|
|
|
+{
|
|
|
+ CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
|
|
|
+ int size = tokens[i].size;
|
|
|
+ ++i;
|
|
|
+
|
|
|
+
|
|
|
+ for (int j = 0; j < size; ++j)
|
|
|
+ {
|
|
|
+ CGLTF_CHECK_KEY(tokens[i]);
|
|
|
+
|
|
|
+ if (cgltf_json_strcmp(tokens + i, json_chunk, "dispersion") == 0)
|
|
|
+ {
|
|
|
+ ++i;
|
|
|
+ out_dispersion->dispersion = cgltf_json_to_float(tokens + i, json_chunk);
|
|
|
+ ++i;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ i = cgltf_skip_json(tokens, i + 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (i < 0)
|
|
|
+ {
|
|
|
+ return i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return i;
|
|
|
+}
|
|
|
+
|
|
|
static int cgltf_parse_json_image(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_image* out_image)
|
|
|
{
|
|
|
CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
|
|
|
@@ -4690,6 +4728,11 @@ static int cgltf_parse_json_material(cgltf_options* options, jsmntok_t const* to
|
|
|
out_material->has_anisotropy = 1;
|
|
|
i = cgltf_parse_json_anisotropy(options, tokens, i + 1, json_chunk, &out_material->anisotropy);
|
|
|
}
|
|
|
+ else if (cgltf_json_strcmp(tokens + i, json_chunk, "KHR_materials_dispersion") == 0)
|
|
|
+ {
|
|
|
+ out_material->has_dispersion = 1;
|
|
|
+ i = cgltf_parse_json_dispersion(tokens, i + 1, json_chunk, &out_material->dispersion);
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_material->extensions[out_material->extensions_count++]));
|