Give a stock three.js material (scatter meshes, unit models, anything you
built yourself) the library's own distance haze, so it recedes in step with
the terrain instead of standing out against it.
This exists because scene.fog is not interchangeable here. three's fog
mixes in linear working space and the result is then tone-mapped and
sRGB-encoded, while this library's hand-rolled shaders write their values
straight out — so handing both the same haze color lands it far brighter on a
stock material than on the terrain beside it (distant trees glowing pale over
a dark hillside, and worse at night). The injected mix runs after tone
mapping and encoding instead, in the same numeric space the library writes,
so at full haze both sides reach exactly uAtmoColor and there is no seam.
Distance is the same ground-plane measure too, not view depth.
Safe to call on a material that already has an onBeforeCompile (the
existing hook still runs), and idempotent. After attaching, the material
responds to configureAtmosphere and a SkyDome's material list
exactly like the library's own shaders.
Give a stock three.js material (scatter meshes, unit models, anything you built yourself) the library's own distance haze, so it recedes in step with the terrain instead of standing out against it.
This exists because
scene.fogis not interchangeable here. three's fog mixes in linear working space and the result is then tone-mapped and sRGB-encoded, while this library's hand-rolled shaders write their values straight out — so handing both the same haze color lands it far brighter on a stock material than on the terrain beside it (distant trees glowing pale over a dark hillside, and worse at night). The injected mix runs after tone mapping and encoding instead, in the same numeric space the library writes, so at full haze both sides reach exactlyuAtmoColorand there is no seam. Distance is the same ground-plane measure too, not view depth.Safe to call on a material that already has an
onBeforeCompile(the existing hook still runs), and idempotent. After attaching, the material responds to configureAtmosphere and a SkyDome's material list exactly like the library's own shaders.