Still working on X-ray sim shaders at @LevelExGameDev
Got variable beam energy working and it's pretty neat to see how it affects the image:
This is a record of a twitter thread, originally posted in 2018
Ignore the extremely placeholder lungs lol
The actual anatomy is fairly approximate right now (bone has no marrow, heart is just a solid mass of muscle without internal details), but the materials and their interaction with the X-rays are real values:
https://physics.nist.gov/PhysRefData/XrayMassCoef/tab4.html
NIST: X-Ray Mass Attenuation Coefficients - Table 4
Thing I have learned: At lower energies, material density is the main factor in X-ray attenuation, but at higher energies the rays are more heavily scattered, so eventually scattering outpaces absorption and materials start to all look the same
Thus on the left, the spine is darker than the heart and diaphragm, because it's much denser, but on the right the two materials have much more similar attenuation, and thus the heart appears darker than bone because it's physically larger
To be clear: There are a LOT of other factors at play here. As I mentioned the anatomy itself is approximate, and tonemapping from voltages to LDR pixels is ENTIRELY subjective and user-controlled
but it's really neat to see the math actually work out like the textbooks said
(also credit to @artofblake for the geometry here. It's still very WIP in case anyone with a medical background sees it and gets mad at us for weird lungs and missing muscles lol)
The cool thing with this X-ray stuff is it's still just radiation, which means it follows the exact same rules as visible light from a rendering standpoint. Reflection, absorption, scatter
They just don't really reflect off of much, so we make images by casting shadows with them
You shine X-ray light on a person, put a detector plate on the other side, and look at the shadow. Thus, simulating fluoroscopy on a GPU is the same problem as rendering shadows through participating media. Visible light passing through volumetric smoke etc