summaryrefslogtreecommitdiffstats
path: root/src/extras/shaders/gl3
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2016-08-19 08:42:54 +0200
committerPaul Lemire <paul.lemire@kdab.com>2016-08-26 05:59:44 +0000
commit918970f5f0283ebff7c0a33f4d87f88283fdbb3e (patch)
tree806e37f31d10bb4eb25cf538f558f94388630c1f /src/extras/shaders/gl3
parentca85c459cdff08a04d3d6420ea7d00c3d1eaeea7 (diff)
QSkyboxEntity: remove camera translation property
If we convert a mat4 matrix to a mat3 matrix, then back to a mat4, this removes the translation component from it. Making the skybox shaders use that property allows to remove references to the camera translation in QSkyboxEntity. This makes using a skybox neater as we don't need to care about the Camera position anymore. This also allows to render the same skybox with different cameras which required to have duplicate QSkyboxEntity previously. Change-Id: I1adddd17d151e4d26d0f19b048df88dbf738042b Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com>
Diffstat (limited to 'src/extras/shaders/gl3')
-rw-r--r--src/extras/shaders/gl3/skybox.vert10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/extras/shaders/gl3/skybox.vert b/src/extras/shaders/gl3/skybox.vert
index 17bb2b00b..b5b0c0617 100644
--- a/src/extras/shaders/gl3/skybox.vert
+++ b/src/extras/shaders/gl3/skybox.vert
@@ -3,12 +3,14 @@
in vec3 vertexPosition;
out vec3 texCoord0;
-uniform mat4 mvp;
-uniform mat4 inverseProjectionMatrix;
-uniform mat4 inverseModelView;
+uniform mat4 modelMatrix;
+uniform mat4 viewMatrix;
+uniform mat4 projectionMatrix;
void main()
{
texCoord0 = vertexPosition.xyz;
- gl_Position = vec4(mvp * vec4(vertexPosition, 1.0)).xyww;
+ // Converting the viewMatrix to a mat3, then back to a mat4
+ // removes the translation component from it
+ gl_Position = vec4(projectionMatrix * mat4(mat3(viewMatrix)) * modelMatrix * vec4(vertexPosition, 1.0)).xyww;
}