summaryrefslogtreecommitdiff
path: root/slideshow/opengl
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <emmanuel.peyrot@collabora.com>2015-12-09 21:39:23 +0000
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2015-12-11 15:28:59 +0100
commit566eca14481ea70c83aef30824da911ccf834b41 (patch)
tree4a48f2867bf8e054bb7d58d3ae03a899a057fc50 /slideshow/opengl
parent4fcebe9f8a69f40bb8629da69df5974851515d2e (diff)
slideshow: upload the transform matrices as uniforms
Change-Id: I2380fc7f8462514e6c032b18b44df51fbaaccb9f
Diffstat (limited to 'slideshow/opengl')
-rw-r--r--slideshow/opengl/basicVertexShader.glsl10
-rw-r--r--slideshow/opengl/reflectionVertexShader.glsl10
2 files changed, 16 insertions, 4 deletions
diff --git a/slideshow/opengl/basicVertexShader.glsl b/slideshow/opengl/basicVertexShader.glsl
index 020616fff872..a4b258c69043 100644
--- a/slideshow/opengl/basicVertexShader.glsl
+++ b/slideshow/opengl/basicVertexShader.glsl
@@ -28,14 +28,20 @@
#version 120
+uniform mat4 u_sceneTransformMatrix;
+uniform mat4 u_primitiveTransformMatrix;
+uniform mat4 u_operationsTransformMatrix;
+
varying vec2 v_texturePosition;
varying vec3 v_normal;
void main( void )
{
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+ mat4 modelViewMatrix = gl_ModelViewMatrix * u_operationsTransformMatrix * u_sceneTransformMatrix * u_primitiveTransformMatrix;
+ mat3 normalMatrix = mat3(transpose(inverse(modelViewMatrix)));
+ gl_Position = gl_ProjectionMatrix * modelViewMatrix * gl_Vertex;
v_texturePosition = gl_MultiTexCoord0.xy;
- v_normal = normalize(gl_NormalMatrix * gl_Normal);
+ v_normal = normalize(normalMatrix * gl_Normal);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/slideshow/opengl/reflectionVertexShader.glsl b/slideshow/opengl/reflectionVertexShader.glsl
index 5087b98c57b0..ad9b0330322d 100644
--- a/slideshow/opengl/reflectionVertexShader.glsl
+++ b/slideshow/opengl/reflectionVertexShader.glsl
@@ -28,15 +28,21 @@
#version 130
+uniform mat4 u_sceneTransformMatrix;
+uniform mat4 u_primitiveTransformMatrix;
+uniform mat4 u_operationsTransformMatrix;
+
varying vec2 v_texturePosition;
varying vec3 v_normal;
varying float v_isShadow;
void main( void )
{
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+ mat4 modelViewMatrix = gl_ModelViewMatrix * u_operationsTransformMatrix * u_sceneTransformMatrix * u_primitiveTransformMatrix;
+ mat3 normalMatrix = mat3(transpose(inverse(modelViewMatrix)));
+ gl_Position = gl_ProjectionMatrix * modelViewMatrix * gl_Vertex;
v_texturePosition = gl_MultiTexCoord0.xy;
- v_normal = normalize(gl_NormalMatrix * gl_Normal);
+ v_normal = normalize(normalMatrix * gl_Normal);
v_isShadow = float(gl_VertexID >= 6);
}