Vulkano: Teapot example's perspective matrix maps depth to [-1, 1]

Created on 29 Sep 2017  路  5Comments  路  Source: vulkano-rs/vulkano

The current teapot example's projection matrix uses cgmath::perspective, which expects a depth range of [-1, 1], but Vulkan uses depth in [0, 1].

When the example is moved over to vulkano-examples, should it include its own perspective matrix function?

enhancement

Most helpful comment

It's worth note that you can quite reasonably want a depth range of [1, 0] instead, as well; there's no one right value even within a single API.

All 5 comments

When the example is moved over to vulkano-examples, should it include its own perspective matrix function?

That's a good question. It's cumbersome to have your own function.

I had a similar problem with my projection matrix.
I still use cgmath, but I multiply it with a special matrix to solve the depth and the "+y is down" problem.

Might be the easiest way here.

It might be a good idea to open an issue with cgmath about this as well. It seems odd to me that it doesn't acknowledge depth range, since D3D uses [0, 1] depth too. This also makes me wonder if gfx users hit this problem much.

It's worth note that you can quite reasonably want a depth range of [1, 0] instead, as well; there's no one right value even within a single API.

Agreed. Of note:

CGMath's documentation is minimal.
Vulkano's best documentation for 3d graphics is the teapot example. Failing more thorough docs or a tutorial, replacing the CGMath calls in the teapot example with manual matrices would help.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Craig-Macomber picture Craig-Macomber  路  11Comments

semicoleon picture semicoleon  路  5Comments

Vengarioth picture Vengarioth  路  7Comments

norru picture norru  路  11Comments

tomaka picture tomaka  路  12Comments