gpu/shaders: introduce toClipSpace to map to GPU native clip space

OpenGL use the [-1; 1] range for clip depths, Direct3D [0; 1].
Use toClipSpace to encapsulate the difference.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-02-27 18:00:24 +01:00
parent c34c350a52
commit 8dce81d8fd
4 changed files with 47 additions and 27 deletions
+3 -1
View File
@@ -4,6 +4,8 @@
precision highp float;
#include <common.inc>
layout(binding = 0) uniform Block {
vec4 transform;
vec4 uvTransform;
@@ -18,6 +20,6 @@ layout(location = 0) out vec2 vUV;
void main() {
vec2 p = pos*transform.xy + transform.zw;
gl_Position = vec4(p, z, 1);
gl_Position = toClipSpace(vec4(p, z, 1));
vUV = uv*uvTransform.xy + uvTransform.zw;
}