TSL: Add exponentialHeightFogFactor().#32659
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
45dbbc5 to
7dcfefa
Compare
|
I was trying to improve this example and nicoptere mentioned that the fog was too linear. I was going to add some noise to it and then I remembered we have this other example. Do we need both? 🤔 |
|
Something like A noise driven fog is too heavy for such use cases. I would recommend to keep it as it is and do not go for just height fogs that aim for PBR style realism. The screenshot from Nicolas Barradeau clearly goes that rounte and will end up more expensive. |

Related issue: #32613 (comment)
Description
I've experimented with fog code lately and this is the simplest exponential height fog I can think of. You have a density parameter to control the global fog density (similar to
densityFogFactor()) and an additionalheightparameter in world space that defines the height (y-coordinate) threshold when fragments are affected by fog.Link for testing: https://rawcdn.githack.com/Mugen87/three.js/c0a7e5ee23e4ec5d5ef209727ed352e97aa192f1/examples/webgpu_fog_height.html
I'll temporarily update the builds for testing.