Attenuation thickness not applied correctly?
See original GitHub issueAlthough KHR_materials_volume
is still in draft, I’ve been testing the implementation provided by @MiiBond in #8684.
My latest test model is DragonAttenuation. (Sample PR opened as https://github.com/KhronosGroup/glTF-Sample-Models/pull/306).
In the Khronos Sample Viewer, the model looks like this:
But, in Babylon Sandbox, I’m seeing this:
It’s hard to see in the screenshot, but the deep orange color is somewhat visible in the thicker parts of the dragon. The thin parts are opaque white/gray, possibly the color of the thickness map itself.
Maybe there’s a bug where the thickness map colors are leaking into BaseColor somehow?
This model also features a material variant, with a variant called “Surface Color” where the yellow itself comes from the baseColor and there is no attenuation. This variant appears to work correctly in the sandbox.
Issue Analytics
- State:
- Created 2 years ago
- Comments:15 (10 by maintainers)
Top GitHub Comments
On our side, we have merged the PR from @MiiBond + we pre-multiply the
thicknessFactor
with themax(abs(scaleX), abs(scaleY), abs(scaleZ))
.Just double-checking my math here, since this a new test model.
All world distance units default to meters, as per usual.
The thickness texture is normalized. The white part covers the thickest portion of the dragon’s body, where the thickness is about 2.2 in unscaled mesh space (raw vertex space).
The
thicknessFactor
was manually set to 3.5 (although in a future iteration, perhaps I should lower this to 2.2, but let’s leave that aside for now).The node’s world-to-local scale is 0.25, so the manually-assigned thickness of “white” in world-space is
3.5 * 0.25 = 0.875
. The thickest part of the scaled dragon’s body (no pun intended) should be about 0.875 in world space.The
attenuationDistance
is set to 0.239015, and this is world space. The color is a faint yellow, and that color should be reached at the attenuation distance. Longer distances should result in darker colors.So the thickest part of the dragon’s body is 3.66 times the attenuation distance, making it dark orange. Thinner parts, such as the claws, are closer to 1x the attenuation distance, making them faint yellow.
If the node scaling were not accounted for here, yes, the dragon would be considered 4 times thicker and darker than it is. The claws would be orange and the body would be a very deep dark color.
So it seems like I could tweak the model to lower both the
thicknessFactor
andattenuationDistance
by the same percentage, to get them to align to what a path tracer would calculate. But the bug here remains, the node’s general world-to-local scaling should be multiplied with thethicknessFactor
here.