Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 504499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:30:11+00:00 2026-05-13T06:30:11+00:00

as a homework assignment, we’re writing a software rasterizer. I’ve noticed my z buffering

  • 0

as a homework assignment, we’re writing a software rasterizer. I’ve noticed my z buffering is not working as well as it should, so I’m trying to debug it by outputting it to the screen. (Black is near, white is far away).

However, I’m getting peculiar values for the z per vertex. This is what I use to transform the points:

float Camera::GetZToPoint(Vec3 a_Point)
{
    Vec3 camera_new = (m_MatRotation * a_Point) - m_Position;

    return (HALFSCREEN / tanf(_RadToDeg(60.f * 0.5f)) / camera_new.z);
}

m_MatRotation is a 3×3 matrix. Multiplying it by a vector returns a transformed vector.

I get maximum and minimum values between 0 and x, where x is a seemingly random number.

Am I doing this transformation right? If so, how can I normalize my Z values so it lies between two set points?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:30:12+00:00Added an answer on May 13, 2026 at 6:30 am

    To normalize the Z values you have to define a near clipping plane and a far clipping plane. Then you normalize Z such that its 0 at the near plane and 1 at the far plane.

    However, you would usually do that after projection. It looks like your last line is where projection occurs.

    A number of other things:

    • You compute the full matrix-vector multiplication but keep only the Z, this is wasteful. You should consider transforming the points and keeping all their X, Y, Z coordinates ;
    • You recompute tanf() at every vertex, but its constant ;
    • I would suggest you use a projection matrix rather than the tanf computation ;
    • Start with a simple orthogonal projection, it will be easier to debug.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Disclaimer: This is for a homework assignment, but the question is not regarding the
I'm writing some excel-like C++ console app for homework. My app should be able
First of all this is a homework assignment so I'm looking for assistance, not
I'm working on a homework assignment for my C++ class. The question I am
full disclosure - this is for a homework assignment. And I normally would not
I'm working on a homework assignment for my object oriented design class, and I'm
For a homework assignment I was given a Card class that has enumerated types
I'm doing a basic homework assignment which looks like this: While input <> -1
I'm working through some homework and a question on a previous exam paper asks
So I've decided to try to solve my physics homework by writing some python

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.