engine
engine copied to clipboard
[Impeller] Map to Metal's NDC in the perspective projection utility
Currently the perspective transform assumes OpenGL's NDC depth range of -1 to 1. This patch switches to Metal/Vulkan's range of 0 to 1.
For GLES, the compiler is already emitting the appropriate clip space conversion. For example, when given the following vertex shader as input...
void main() {
gl_Position = vert_info.mvp * vec4(position, 1.0);
}
...the compiler emits the following when targeting GLES:
void main()
{
gl_Position = vert_info.mvp * vec4(position, 1.0);
gl_Position.z = 2.0 * gl_Position.z - gl_Position.w;
}
Noticed this problem in impeller-cmake-example.
