question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Attenuation thickness not applied correctly?

See original GitHub issue

Although 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:

screenshot_large

But, in Babylon Sandbox, I’m seeing this:

image

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:closed
  • Created 2 years ago
  • Comments:15 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
Popov72commented, Apr 14, 2021

On our side, we have merged the PR from @MiiBond + we pre-multiply the thicknessFactor with the max(abs(scaleX), abs(scaleY), abs(scaleZ)).

3reactions
emackeycommented, Apr 7, 2021

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 and attenuationDistance 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 the thicknessFactor here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

opengl - Attenuation does not get applied correctly
It seems like it's not because the shininess of the steel frame for cube located at (-500, 100, 100) (at the left) is...
Read more >
Effect of Material Thickness on Attenuation (dB) of PTFE Using ...
The attenuation of the different thicknesses showed that the thicker the sample thickness is, the higher the attenuation of the PTFE sample is....
Read more >
Linear attenuation coefficient | Radiology Reference Article
Linear attenuation coefficient (µ) is a constant that describes the fraction of attenuated incident photons in a monoenergetic beam per unit ...
Read more >
Attenuation Correction of PET/MR Imaging - PMC - NCBI
Photon attenuation depends on the spatially varying electron density and tissue thickness. Photon attenuation can result in as high as 90% ...
Read more >
The AAPM/RSNA physics tutorial for residents. X-ray ...
Attenuation is the reduction of the intensity of an x-ray beam as it ... be used to calculate the attenuation by any thickness...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found