frame.smokeTablehas every cloud’s center and bounds this frame.frame.worldDepthis the depth of the map alone. No players, and none of the cheat’s smoke boxes, so the outlines follow the real walls.
Step 1: How much smoke is in the way
For each pixel, take the ray from your eye to the wall behind it and measure how much of it runs through a cloud. A cloud is roughly an ellipsoid, so treat it as one inside its bounds: a ray against a stretched sphere is a quadratic, no marching. Keep this function in a string,SMOKE_BEFORE, for the
shader in step 2:
gpu-showcase script does. The ellipsoid is good enough to start.
Step 2: The map from its depth
Where enough smoke is in the way, rebuild the map fromworldDepth: four neighbouring pixels give the
normal, and jumps or bends in depth are edges.
Step 3: Wiring it up
worldDepth are only filled while some
recording uses them; frame.smokeCount reads 0 until yours does.
Tuning
- Smoke needed is how many units of smoke the ray must cross before anything shows. Raise it if the outlines pop up at the cloud’s thin edges.
- Swap
worldDepthforsolidDepthand players hide the outlines behind them, while the smoke still doesn’t. - Draw players in the smoke with scene.player and an
xraymaterial: that part is already done for you.