Graphics Reference
In-Depth Information
During each frame the time stamp counters are used as normal.
// Increment the global time stamp counter
tickCounter++;
// Do any and all object testing required for the frame
for (i = 0; i < MAX_OBJECTS; i++) {
if (object[i].timeStamp == tickCounter) {
// Already processed this object this frame, do nothing
continue;
} else {
// Process object for intersection here
...
// Mark object as processed
object[i].timeStamp = tickCounter;
}
}
At the end of each frame — or between rays in case of shooting rays — a subset of
all stored time stamps is cleared by marking them with the current time stamp value
(which has served its purpose for this frame).
// Reset the time stamp for all objects in the current block to be cleared
from = blockToClear * MAX_OBJECTS / MAX_COUNTER_VALUE;
to = (blockToClear + 1) * MAX_OBJECTS / MAX_COUNTER_VALUE;
for (i = from; i < to; i++)
object[i].timeStamp = tickCounter;
// Indicate that the next block should be cleared the next frame
if (++blockToClear >= NUM_BLOCKS)
blockToClear = 0;
// Wrap the global time stamp counter when it exceeds its maximum value
if (tickCounter >= MAX_COUNTER_VALUE - 1)
tickCounter = 0;
The same technique can be applied for amortized clearing of other buffers. For
example, by setting aside a few bits of the time stamp it could be used to spread the
clearing of a (software) Z-buffer over a number of frames.
7.8 Summary
Spatial partitioning is an approach to accelerating broad-phase processing by dividing
space into disjoint regions and associating scene objects with all regions they overlap.
 
Search WWH ::




Custom Search