submit method
void
submit(
- RenderItem item
Queues a draw call for item, unless it is hidden or frustum
culled.
Both opaque and translucent draws are deferred; flush sorts and emits them. A translucent instanced item is queued as one draw per instance so each can be depth-sorted independently.
Implementation
void submit(RenderItem item) {
if (!item.visible) return;
if (item.frustumCulled) {
final bounds = item.cullBounds;
if (bounds != null) {
cullScratchAabb
..copyFrom(bounds)
..transform(item.worldTransform);
if (!frustum.intersectsWithAabb3(cullScratchAabb)) return;
}
}
final pipeline = _resolvePipeline(
item.geometry.vertexShader,
item.material.fragmentShader,
);
if (item.material.isOpaque()) {
_opaqueRecords.add(
_OpaqueRecord(
item,
pipeline,
identityHashCode(pipeline),
_depthOf(item.worldTransform),
),
);
return;
}
// Translucent. Instanced items are exploded into one record per
// instance, like any other translucent draw.
final instances = item.instanceTransforms;
if (instances != null) {
for (final instanceTransform in instances) {
final worldTransform = item.worldTransform * instanceTransform;
_translucentRecords.add(
_TranslucentRecord(
worldTransform,
item.geometry,
item.material,
pipeline,
_depthOf(worldTransform),
item.windingFlipped != (instanceTransform.determinant() < 0),
),
);
}
} else {
_translucentRecords.add(
_TranslucentRecord(
item.worldTransform,
item.geometry,
item.material,
pipeline,
_depthOf(item.worldTransform),
item.windingFlipped,
),
);
}
}