Hello,
about Vulkan’s coordinate system,
it looks
right side = positive of x
down side = positive of z
and y is such that this coordinate system is right-handed
(that is, positive of y is toward me)
Is this correct ?
Thank you
Hello,
about Vulkan’s coordinate system,
it looks
right side = positive of x
down side = positive of z
and y is such that this coordinate system is right-handed
(that is, positive of y is toward me)
Is this correct ?
Thank you
Vulkan defaults to a left-handed coordinate system with +Y down, +Z out of the screen (behind the default view) and +X to the right.
Hello, Mark
I am searching on the internet and found something more to study
I guess Vulkan looks to have right-handed, but many people including you said “left-handed”
which I wonder
What I found is, I should motify vert shader source to use vec4 (homogeneous) format, not vec3
and need to have precise perspective projection matrix etc
When I test on vert shader file, I checked
clip volume is x (-1, 1), y (-1, 1) and z (0, 1) and when z = 0,. it is front (near) and z = 1, it is behind
(far)
anyway I am working on perspective matrix and view matrix (inverse of camera matrix)
I am using Sascha’s descripterindexing source file for my project
So, perhaps, if you can,
please help me with the precise perspective matrix I should use on the source file
I will appreciate your help
So have a nice week and thank you for your comments
Using the word “default” was sloppy. What I described is just a commonly used convention for the object space in Vulkan apps, similar to that used in OpenGL except that Y is down in Vulkan.
It is meaningless to talk about a default coordinate system for an API these days when everything is done in shaders. The vertex shader outputs vertex coordinates in clip space. The specifications only describe how to get from clip space, via NDC (normalized device coordinates) and the viewport transform, to framebuffer coordinates. In the case of Vulkan there is no default because there is no default compareOp for the depth test and the compareOp determines whether the NDC’s z coordinate goes in or out of the NDC space.
If the compareOp is VK_COMPARE_OP_LESS
then Vulkan’s NDC is right handed, X to the right, Y down and Z into the “screen”. That is probably why you have seen people saying Vulkan is right-handed.
In the case of OpenGL, LESS is the default depth test also giving Z into the “screen” but, because Y is up, its NDC space is left-handed.
You do not have to any more of a “precise perspective projection matrix etc” in Vulkan than in OpenGL. Any comments you have found about precision probably refer to the fact the Vulkan’s clip space is configured to make the near clip plane correspond to a z normalized device coordinate of 0 (as in Direct3D) potentially improving the numerical precision of the Z coordinate mapping. Your projection matrix needs to be cognizant of this. This does not help much if you have a conventional fixed-point depth buffer. It can help if you use a floating-point depth buffer and place the near and far values at 1.0 and 0.0 (reversed from the normal convention, which needs a different depth test which changes the handedness of the NDC).
Hello, Mark
Thank you very much for your detailed explanation
You are mentioning floating-point depth buffer, which I don’t know now
and I will check about it on my source files
At this moment, I finally managed to set up pretty precise camera view matrix and projection matrices (orthographic, perspective) from google search
and checked my program shows quite good 3D mathematical surface visualization
I think, you advised me to study depth buffer settings in Vulkan
so I will study them
I mostly understand your explanation above
Thank you again for your help and have a great week, Mark
See you again
Best,
You are welcome @Kyoungmun. I forgot to say that recent versions of both OpenGL and Vulkan provide controls so you can make the NDC-space of one mimic the other. For OpenGL this is done via glClipControl. For Vulkan, the NDC space origin can be made lower-left by passing a negative height value when setting the viewport and the depth range can be made -1 to +1 by setting VkPipelineViewportDepthClipControlCreateInfoEXT::negativeOneToOne
to VK_TRUE
.
Thank you again, Mark. I will check that too. See you