-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve projection matrix constructors #569
Comments
Leaving this open as while the existing docs have been improved I want to consider moving the projection matrix methods out of Separate to projection matrix creation, there are a bunch of other methods that have lh and rh variants (e..g. |
Please, no traits. |
Although there's precedent in the Swizzle traits. |
Hello! I got very confused choosing the proper
Mat4::perspective_*
function. I think they could be documented a lot better. In particular, listing from what coordinate system they are mapping from, and into what coordinate system they are mapping into.I've now done the research, and the transformations are:
Where OpenGL uses
Z+ into screen [-1, 1]
, Metal/DirectX/WebGPU useZ+ into screen [0, 1]
and Vulkan usesY+ down, Z+ into screen [0, 1]
.The same issue applies to orthographic projections.
I propose the following to avoid breaking changes:
perspective_rh_vk
andorthographic_rh_vk
functions, that map fromX+ right, Y+ up, Z+ out of screen
toY+ down, Z+ into screen [0, 1]
(what Vulkan expects).perspective_rh_gl
:Z+ out of screen
-> GLperspective_rh_vk
:Z+ out of screen
-> VKperspective_rh
:Z+ out of screen
-> Metal/DX/WGPUperspective_lh
:Z+ into screen
-> Metal/DX/WGPUorthographic
functions.perspective_infinite
andperspective_infinite_reverse
.There would be no
Z+ into screen
-> VK, just like currently there is noZ+ into screen
-> GL. Maybe those two could be added? (perspective_lh_gl
,perspective_lh_vk
).Actually, I collected my thoughts while writing this issue and I think I'll write up a PR.
The text was updated successfully, but these errors were encountered: