Z Axis about Translate Matrix

Hello Caroline, I find what problem I need to solve is. The problem is Z axis. Sometimes I use translate matrix to translate vector and lead to z value (in float3 or float4) is bigger than 1 and there is nothing on screen. So would u please give me some suggestion to avoid it?

Hi there :slight_smile: - how far into the book have you read? When you read about camera matrices and projection matrices, perhaps your problem will be solved.

The normalised device coordinates for Metal are -1 to 1 in the x axis, -1 to 1 in the y axis and 0 to 1 in the z axis. However, when you introduce a camera matrix, which might position the camera at -6 on the z axis, then everything needs to be divided by 6 to be able to show in NDC.

When you pass back the position from the vertex function, it has x, y, z, w. As it proceeds through the pipeline, there is a stage where x, y, z are divided by w which results in NDC.

So if your z coordinate is 6, and you want it to be between 0 and 1 to display on the screen, then you’ll need to have >= 6 in the w coordinate.