Monday, June 19, 2017

shaders - How would one construct a realistic "infrared vision" effect?


How would you go about constructing a realistic infrared vision effect with shaders? By realistic I mean one that looks realistic, like this example.



I have an idea about making a texture to determine how much heat a material emits and then determine by using the dot product of normal and view vector how much of that heat reaches the viewer but I'm not even sure that this is how thermal vision even works so I wanted to check if there's a better approach before starting to implement something that might be entirely wrong.



Answer



There's IR, and then there's IR. The range of light wavelengths commonly called "infrared" extends from the edge of the human visual range (about 700 nm) up to 1 mm = 1,000,000 nm.


Philipp's answer is correct for "near-infrared" light (about 700 to 1,400 nm), which is basically just like normal visible light, except that it's invisible to the unaided human eye. To model near-IR vision, you'd just replace your object textures and light source colors with alternative ones that model their reflectances and light intensities at different wavelengths than usual


However, based on the wording of your question and the video you linked to, you seem to be more interested in the "thermal infrared" range (8,000 to 15,000 nm), which corresponds to the peak of the thermal radiation spectrum of most everyday objects, including the human body. This radiation still behaves in most ways like "light" and can be modeled using standard computer graphics techniques (as opposed to radio waves, where the wavelengths get long enough that standard assumptions of ray optics start to break down), but the world as seen in thermal infrared does have its peculiarities:




  • As noted above, most objects will glow in thermal IR. For visible light, you can generally assume that there are only a few actual light sources, with everything else just reflecting light emitted by other sources. For thermal IR, depending on the exact wavelength(s) chosen, the opposite is often the case.





  • Conversely, most surfaces will also absorb thermal IR pretty efficiently. This will, in turn, warm them up, causing them to re-emit more IR themselves. In effect, it's as if almost every surface was phosphorescent.




  • The thermal IR spectrum (i.e. "color") emitted by most surfaces will mainly depend on their temperature. The intrinsic emissivity of the surface material does have an effect too, but a relatively limited one.




Thus, compared to normal light vision, modeling realistic thermal infrared vision would require more emphasis on global illumination and on dynamically changing emissivity values. Depending on your setting, you might be able to cheat a bit here: for example, for static scenes, the global radiative thermal transfer functions can be precomputed once and baked into a static lightmap, just like you'd do to fake global illumination in the visible spectrum.


If you want to simulate the view through a thermographic camera in your game, I'd recommend at least the following:





  • Draw and/or compute special IR emissivity and/or reflectivity textures for your objects. Pay special attention to the emissivity of warm objects (like humans or machines), which should correspond to their surface temperature. The reflectivity is relatively less important.




  • You'll probably want to use just a single spectral channel (i.e. draw everything in monochrome) corresponding to the total thermal IR flux. You can postprocess the image by mapping the resulting grayscale values into a false color gradient to simulate the traditional density slicing used for thermal images.




  • Consider explicitly tracking the temperature of your surfaces, such that, say, a spot on the ground that a person was lying on will remain warm (and thus glowing in IR) for a while even after the person has moved away. There are several ways you could handle that (e.g. per-vertex temperature tracking, adding decals for transient local temperature changes, etc.) with different trade-offs between realism and computational cost. You probably don't need to make it very realistic, but even having this effect present at all would be a nice touch.




No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...