Log inGet started
Package

mediaShadow.renderFeature

Newest version

This package holds more than this page lists. See all of its files in its world.

README.md

mediaShadow

Participating media in the frame, for every view it draws. Brought up by mediaTransmittance while a medium is registered and released with the last. A fog bank or a smoke cloud in one place is the ParticipatingMedium component; adding one to an entity registers it.

WherePassWork
afterDepthPrepass, order 45media_shadow_applyFor every surface, the share of the scene's sun the media take on the way to it, written to @scene.sunOcclusion
afterLightingoverhead coverWhat stands over each point around the camera (@builtin::systems.skyVisibility.overheadCover)
medium stage, order 29vol_surroundingsThe light the surroundings hand the air at each node of the surroundings grid around the camera, once per render
medium stage, order 30media_viewMarch each view ray across the media in front of the surface: dim what is behind, add the light scattered toward the camera, the surroundings' light read from the grid
medium stage, order 30compositeLay the result over the frame

The surroundings grid, the view march and the composite declare environmentCapture = false: the sky fallback and the reflection probes the media are lit by are captured without them, so each capture holds the light of the scene as it stands, a recapture leaves the media as they were, and a reflecting surface is seen through the media in front of it. The sun occlusion stays in the captures, so the ground a capture sees under a medium is dimmed as the camera sees it.

Why the sun occlusion channel

A medium in front of the sun takes the sun's light from the surfaces under it and leaves the light arriving from every other direction. The sun occlusion channel is the scene's per-pixel answer to how much of the sun is taken; the sun's term reads it at the fragment's own pixel, the way it reads the translucent casters' colour, so the ground under a thick medium is lit by the sky and the ambient like the ground in an opaque blocker's shadow. It is written at the depth seam, against this frame's depth and for the camera being drawn, before anything shades.

What the channel holds is optical depth, not a depth to compare against:

  • Overlapping media stack. Optical depth is additive, so two volumes that intersect contribute to the same total with nothing to resolve.
  • Geometry inside a volume is lit by the part it has reached. The ray toward the sun starts at the surface, so a post standing in the middle of a fog bank is dimmed by the half between it and the sun rather than by the whole column.

Inputs

@scene.color, @scene.depth, @frame.camera, @frame.light, @scene.environment, @scene.reflectionProbes, and the media_params / media_volumes buffers packed by @builtin::systems.volumetrics.mediaTransmittance. Writes @scene.sunOcclusion.