Lecture 05: Depth buffer

Computer graphics in Game development

Ivan Belyavtsev

23.01.2021

Kliment Redko. Suprematism

Kliment Redko. Suprematism

Experiment:

Rasterization with Triangles test

Depth buffer

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]

Z-buffer culling

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]

Lab: Depth buffer

Homework

  1. Make a Github repo from the template
  2. Implement rasterization labs
  3. Commit&push your implementation
  4. Make sure that the teacher has access to your repo (djbelyak)
  5. Point the repo’s URL and tag (branch, or commit hash) in Moodle

Due date: Friday, 5 February 2021, 12:00 AM

References

1.
Marschner S., Shirley P. Fundamentals of computer graphics, fourth edition. 4th ed. Natick, MA, USA: A. K. Peters, Ltd., 2016.
// reveal.js plugins