From fa3aa2969e7ee7a889491dd4ed21c77e92ff4c9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Mon, 7 Sep 2020 07:43:26 -0700 Subject: [PATCH] Updated cgltf. --- 3rdparty/cgltf/cgltf_write.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/3rdparty/cgltf/cgltf_write.h b/3rdparty/cgltf/cgltf_write.h index 43845b095..cc4f8a273 100644 --- a/3rdparty/cgltf/cgltf_write.h +++ b/3rdparty/cgltf/cgltf_write.h @@ -75,7 +75,8 @@ cgltf_size cgltf_write(const cgltf_options* options, char* buffer, cgltf_size si #define CGLTF_EXTENSION_FLAG_LIGHTS_PUNCTUAL (1 << 3) #define CGLTF_EXTENSION_FLAG_DRACO_MESH_COMPRESSION (1 << 4) #define CGLTF_EXTENSION_FLAG_MATERIALS_CLEARCOAT (1 << 5) -#define CGLTF_EXTENSION_FLAG_MATERIALS_TRANSMISSION (1 << 6) +#define CGLTF_EXTENSION_FLAG_MATERIALS_IOR (1 << 6) +#define CGLTF_EXTENSION_FLAG_MATERIALS_TRANSMISSION (1 << 7) typedef struct { char* buffer; @@ -508,6 +509,11 @@ static void cgltf_write_material(cgltf_write_context* context, const cgltf_mater context->extension_flags |= CGLTF_EXTENSION_FLAG_MATERIALS_TRANSMISSION; } + if (material->has_ior) + { + context->extension_flags |= CGLTF_EXTENSION_FLAG_MATERIALS_IOR; + } + if (material->has_pbr_metallic_roughness) { const cgltf_pbr_metallic_roughness* params = &material->pbr_metallic_roughness; @@ -524,7 +530,7 @@ static void cgltf_write_material(cgltf_write_context* context, const cgltf_mater cgltf_write_line(context, "}"); } - if (material->unlit || material->has_pbr_specular_glossiness || material->has_clearcoat || material->has_transmission) + if (material->unlit || material->has_pbr_specular_glossiness || material->has_clearcoat || material->has_ior || material->has_transmission) { cgltf_write_line(context, "\"extensions\": {"); if (material->has_clearcoat) @@ -538,6 +544,13 @@ static void cgltf_write_material(cgltf_write_context* context, const cgltf_mater cgltf_write_floatprop(context, "clearcoatRoughnessFactor", params->clearcoat_roughness_factor, 0.0f); cgltf_write_line(context, "}"); } + if (material->has_ior) + { + const cgltf_ior* params = &material->ior; + cgltf_write_line(context, "\"KHR_materials_ior\": {"); + cgltf_write_floatprop(context, "ior", params->ior, 1.5f); + cgltf_write_line(context, "}"); + } if (material->has_transmission) { const cgltf_transmission* params = &material->transmission; @@ -914,6 +927,9 @@ static void cgltf_write_extensions(cgltf_write_context* context, uint32_t extens if (extension_flags & CGLTF_EXTENSION_FLAG_MATERIALS_CLEARCOAT) { cgltf_write_stritem(context, "KHR_materials_clearcoat"); } + if (extension_flags & CGLTF_EXTENSION_FLAG_MATERIALS_IOR) { + cgltf_write_stritem(context, "KHR_materials_ior"); + } if (extension_flags & CGLTF_EXTENSION_FLAG_MATERIALS_TRANSMISSION) { cgltf_write_stritem(context, "KHR_materials_transmission"); }