vulkano icon indicating copy to clipboard operation
vulkano copied to clipboard

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

Open LPGhatguy opened this issue 8 years ago • 5 comments

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?

LPGhatguy avatar Sep 29 '17 07:09 LPGhatguy

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.

tomaka avatar Sep 29 '17 07:09 tomaka

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.

SiebenCorgie avatar Sep 29 '17 16:09 SiebenCorgie

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.

LPGhatguy avatar Sep 29 '17 18:09 LPGhatguy

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.

Ralith avatar Oct 01 '17 01:10 Ralith

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.

David-OConnor avatar Oct 16 '18 22:10 David-OConnor