mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 15:45:38 +00:00
8dce81d8fd
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>
24 lines
606 B
PHP
24 lines
606 B
PHP
// SPDX-License-Identifier: Unlicense OR MIT
|
|
|
|
// fboTextureTransform returns a transformation
|
|
// that cancels the implied transformation between
|
|
// the framebuffer and its texture.
|
|
// Only two rows are returned. The last is implied
|
|
// to be [0, 0, 1].
|
|
vec3[2] fboTextureTransform() {
|
|
vec3[2] t;
|
|
t[0] = vec3(1.0, 0.0, 0.0);
|
|
t[1] = vec3(0.0, 1.0, 0.0);
|
|
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));
|
|
}
|