[UPDATED] thicknessFactor, attenuationColor, attenuationDistance, ior exporter for Blender glTF exporter

Hello.
I don’t know if it has been covered yet, but I didn’t find a straight way so I just coded an addon for Khronos Group official glTF exporter for Blender, to write KHR_materials_volume → thicknessFactor, attenuationColor and attenuationDistance, plus KHR_materials_ior.

thicknessFactor is necessary in order to compute the correct refraction of materials transmission ( that is written correctly in the glTF by Khronos exporter straight from Blender Principled BSDF material’s transmission property).

Now you can export refractive (glass) materials with the correct thickness from Blender, load the model in three.js and view correct refraction instead of very subtle one.

it relies on Principled BSDF material, and a Volume Absorption node that must be created in the node graph in order to export attenuation color and distance (this node can be left unlinked)

  • it takes KHR_materials_volume[‘thicknessFactor’] from Refraction Depth (Settings tab in Material panel)
  • it takes KHR_materials_ior[‘ior’] from Principled BSDF IOR property
  • it takes KHR_materials_volume[‘attenuationColor’] and KHR_materials_volume[‘attenuationDistance’] from a Volume Absorption node you must create in the node graph that can be unlinked. If more thank one Volume Absorption nodes are present, it takes the first created one.
  • In the export panel you can select what extension and property want to export.

The main feature missing is exporting thicknessTexture, but as I can understand we are far from “standardising” how to export this straight from Blender.

Here it is, you just have to install into Blender and activate, then you’ll find it under Extensions in the glTF exporter panel.
( In the addons panel you can find it by searching “KHR” )

5 Likes

That’s awesome! I don’t know Python all that well, but the code looks clean to me — you should consider submitting that to the Blender addon directly, see Manage KHR_materials_volume · Issue #1454 · KhronosGroup/glTF-Blender-IO · GitHub. :slight_smile:

I wrote up a similar script recently, except to process a glTF file after exporting, in Writing volumetric refraction in glTF 2.0.

3 Likes

Thanks Don.
I’ll submit this, good suggestion.

It looks the Khronos group is working on a proper implementation of the KHR_materials_volume glTF extension into their Blender exporter addon, supporting also thicknessMap, attenuationDistance and attenuationColor.
Or at least I hope so :grin:

And it wouldn’t be difficult at all for a decent Blender python coder (I’m not) to build that.
If you know someone please get me in touch.

Is this value equivalent to thickness ?

screen space reflections & refraction has to be on to visualize effect of this slider

@orion_prime yes, if you set that param, will export to thicknessFactor.
and yes, to actually see the effect in Blender you have to enable SS reflections and refraction, but for the exporter this doesn’t matter, it just takes the value in “refraction depth”

1 Like

Addon Updated.