HiZOcclusion class final
OcclusionMode.hiZ: last frame's depths, read back from the GPU and
reprojected into this frame's view — C3.
The DepthPyramid pass reduces the surface buffer to width × height
cells, each holding the farthest view depth under it and whether every
pixel under it was drawn at all; the renderer reads that back and hands it
to accept with the camera it was seen through. A frame later prepare
carries each cell to where this frame's camera sees it and writes it into
an OcclusionBuffer, which then answers exactly as the software method's
does.
Farthest, so the reading is only ever too pessimistic. A cell's depth is at or behind every surface in it, and the encoding rounds up, so a box the reading hides is behind everything that was in the cell. A cell with one empty pixel is no occluder at all: sky through a gap hides nothing.
Moved as one plane, so only while it still is one. A cell is carried at its farthest depth, but what it saw may not have been flat: a post in front of a doorway, the doorway's depth taken from the wall beside it. Nobody saw what is behind the post, and when the camera steps sideways the post slides off it faster than the wall does. The reading also keeps each cell's nearest depth, and prepare leaves out a cell whose nearest and farthest land more than parallaxLimit of a cell apart in the new view — which a flat cell never does, and a still camera never makes any cell do. And a pixel counts as covered only when the moved cells' union covers all of it: two cells stacked over half a pixel are not one cell over the whole of it.
What it cannot know is what moved since. A door that swung open last frame still stands in the reading, so what is behind it waits a frame or two to appear — the price of an answer that costs no occluders and no CPU rasteriser, and the reason the answer is "visible" whenever the camera jumps (cutDistance, cutCosine) or the reading was taken through another camera.
Constructors
Properties
- buffer → OcclusionBuffer
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasReading → bool
-
Whether a reading has arrived since the last reset — for a caller
that wants to know whether culling is live yet or still drawing all.
no setter
- readings → int
-
Readings accepted since this was made.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
accept(
ByteData bytes, {required Matrix4 viewProjection, required Vector3 eye, required Vector3 forward, required double far, required Object camera}) → void -
Takes a reading:
bytesas the pass wrote them andreadbackreturned them, row zero at the top, four bytes a cell — depth as a 24-bit fraction offarin red, green and blue, most significant first, and alpha below 128 where some pixel under the cell was not drawn, and otherwise 128 plus the nearest depth as 127ths of the farthest. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
prepare(
Matrix4 viewProjection, {required Vector3 eye, required Vector3 forward, required Object camera}) → OcclusionTest? -
The reading carried into a frame seen through
viewProjection, or null when there is nothing to carry: no reading yet, a reading through another camera, or a cut since it was taken. -
reset(
) → void - Forgets the reading, so every answer is "visible" until the next one.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- cutCosine → const double
- The cosine of the widest turn since the reading that still reprojects: thirty degrees.
- cutDistance → const double
- How far the eye may have moved since the reading, in metres, before the reading is thrown away as a cut rather than reprojected.
- depthSteps → const int
- Steps in the 24-bit depth, which the pass writes as a fraction of the camera's far plane.
- height → const int
- parallaxLimit → const double
- How far apart, in cells of this frame's view, a cell's nearest and farthest depths may land before the cell is no occluder: the widest sliver of what the reading never saw that it may still claim.
- width → const int
-
The reading's size in cells, which is the
DepthPyramidtarget's size.