KhronosGroup / KhronosGroup/glslang
GLSL: Add a option to fix up clip space.
Open
enhancement
GLSL/ESSL
HLSL
SPIR-V
- Dominant language
- C++
- Stars
- 3.6k
- Forks
- 989
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 31
Description
OpenGL uses the NDC with z of [-1, 1], and Vulkan, DirectX, Metal use the NDC with z of [0, 1].
When we want fix a vertex shader originally written for OpenGL, we can add an extra line:
```glsl
gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;
```
Or generate SPIR-V code of this meaning.
[SPIRV-Cross has an option for it](https://github.com/KhronosGroup/SPIRV-Cross#clip-space-conventions).
Like #2936, I want use the same source code of shaders for OpenGL and Vulkan.
Contributor guide
Assessment
This issue has not been assessed yet.