[vlc-commits] opengl: apply orientation in fragment shader
Romain Vimont
git at videolan.org
Mon Mar 23 11:37:34 CET 2020
vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Tue Feb 4 11:41:48 2020 +0100| [cb16845b7e1244f3a7085276489f9dd2e01a2949] | committer: Jean-Baptiste Kempf
opengl: apply orientation in fragment shader
Apply all texture coordinates transformation in the fragment shader.
This is necessary to be able to implement a renderer independent of the
input picture (i.e. without even knowing the details) by using a single
GLSL function "vlc_texture(vec2 pic_coords)".
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=cb16845b7e1244f3a7085276489f9dd2e01a2949
---
modules/video_output/opengl/fragment_shaders.c | 8 +++++---
modules/video_output/opengl/renderer.c | 4 +---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/modules/video_output/opengl/fragment_shaders.c b/modules/video_output/opengl/fragment_shaders.c
index e245af4f9a..c228712865 100644
--- a/modules/video_output/opengl/fragment_shaders.c
+++ b/modules/video_output/opengl/fragment_shaders.c
@@ -488,7 +488,9 @@ opengl_fragment_shader_init(struct vlc_gl_renderer *renderer, GLenum tex_target,
ADDF("%s", renderer->glsl_precision_header);
- ADD("varying vec2 PicCoords;\n");
+ ADD("varying vec2 PicCoords;\n"
+ "uniform mat4 TransformMatrix;\n"
+ "uniform mat4 OrientationMatrix;\n");
for (unsigned i = 0; i < interop->tex_count; ++i)
ADDF("uniform %s Texture%u;\n"
"uniform mat3 TexCoordsMap%u;\n", sampler, i, i);
@@ -585,8 +587,8 @@ opengl_fragment_shader_init(struct vlc_gl_renderer *renderer, GLenum tex_target,
ADD("uniform vec4 FillColor;\n"
"void main(void) {\n"
- /* Homogeneous coordinates */
- " vec3 pic_hcoords = vec3(PicCoords, 1.0);\n"
+ /* Homogeneous (oriented) coordinates */
+ " vec3 pic_hcoords = vec3((TransformMatrix * OrientationMatrix * vec4(PicCoords, 0.0, 1.0)).st, 1.0);\n"
" vec2 tex_coords;\n");
unsigned color_count;
diff --git a/modules/video_output/opengl/renderer.c b/modules/video_output/opengl/renderer.c
index 53f6d4c342..6d90e7ebcb 100644
--- a/modules/video_output/opengl/renderer.c
+++ b/modules/video_output/opengl/renderer.c
@@ -178,13 +178,11 @@ BuildVertexShader(const struct vlc_gl_renderer *renderer)
"attribute vec2 PicCoordsIn;\n"
"varying vec2 PicCoords;\n"
"attribute vec3 VertexPosition;\n"
- "uniform mat4 TransformMatrix;\n"
- "uniform mat4 OrientationMatrix;\n"
"uniform mat4 ProjectionMatrix;\n"
"uniform mat4 ZoomMatrix;\n"
"uniform mat4 ViewMatrix;\n"
"void main() {\n"
- " PicCoords = vec4(TransformMatrix * OrientationMatrix * vec4(PicCoordsIn, 0.0, 1.0)).st;\n"
+ " PicCoords = PicCoordsIn;\n"
" gl_Position = ProjectionMatrix * ZoomMatrix * ViewMatrix\n"
" * vec4(VertexPosition, 1.0);\n"
"}";
More information about the vlc-commits
mailing list