Teapot example's perspective matrix maps depth to [-1, 1]
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?
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.