Computer graphics in Game development
Ivan Belyavtsev
23.01.2021
For rasterization we are using \(x\) and \(y\) only. Let’s store \(z\) coordinate of pixel to separated buffer. This buffer is called depth buffer (or z-buffer) [1]
bool DepthTest(unsigned short x, unsigned short y, float z)
{
return z < depth_buffer(x, y)]; //Depends on Z-axis directions
}
void SetPixel(unsigned short x, unsigned short y, float z,)
{
if (DepthTest(x, y, z))
{
frame_buffer(x, y) = pixel_shader(attributes);
depth_buffer(x, y) = z;
}
}
[1]
Due date: Friday, 5 February 2021, 12:00 AM