Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@bdero
Copy link
Member

@bdero bdero commented Aug 13, 2022

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.

image

@bdero bdero self-assigned this Aug 13, 2022
@bdero bdero force-pushed the bdero/perspective-clip-space branch 2 times, most recently from 58de5c4 to 8171ce5 Compare August 14, 2022 07:41
@bdero bdero requested review from chinmaygarde and dnfield August 14, 2022 12:01
@bdero bdero force-pushed the bdero/perspective-clip-space branch from 8171ce5 to 02f7dd9 Compare August 15, 2022 09:40
@chinmaygarde
Copy link
Contributor

For GLES, the compiler is already emitting the appropriate clip space conversion.

Thats because of this option.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants