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
+6
View File
@@ -12,6 +12,12 @@ vec3[2] fboTextureTransform() {
return t;
}
// toClipSpace converts an OpenGL gl_Position value to a
// native GPU position.
vec4 toClipSpace(vec4 pos) {
return pos;
}
vec3 transform3x2(vec3[2] t, vec3 v) {
return vec3(dot(t[0], v), dot(t[1], v), dot(vec3(0.0, 0.0, 1.0), v));
}