meta-digi/meta-digi-dey/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad-1.4.5/Adding-some-fragment-shader...

126 lines
3.8 KiB
Diff
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From 8489b90f5ed6b7f9b98b123b521d41aec00cc8bd Mon Sep 17 00:00:00 2001
From: Jian <Jian.Li@freescale.com>
Date: Wed, 25 Mar 2015 13:45:57 +0800
Subject: [PATCH] Adding some fragment shaders for glshader plugin
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Upstream Status: Inappropriate [i.MX specific]
Signed-off-by: Jian <Jian.Li@freescale.com>
---
ext/gl/Makefile.am | 3 +++
ext/gl/shaders/fisheye_shader.fs | 14 ++++++++++++++
ext/gl/shaders/gray_shader.fs | 12 ++++++++++++
ext/gl/shaders/tunnel_shader.fs | 14 ++++++++++++++
ext/gl/shaders/twirl_shader.fs | 21 +++++++++++++++++++++
5 files changed, 64 insertions(+)
create mode 100755 ext/gl/shaders/fisheye_shader.fs
create mode 100755 ext/gl/shaders/gray_shader.fs
create mode 100755 ext/gl/shaders/tunnel_shader.fs
create mode 100755 ext/gl/shaders/twirl_shader.fs
diff --git a/ext/gl/Makefile.am b/ext/gl/Makefile.am
index b1796f6..b8442f8 100644
--- a/ext/gl/Makefile.am
+++ b/ext/gl/Makefile.am
@@ -110,6 +110,9 @@ libgstopengl_la_LIBADD = \
$(LIBM) \
$(GRAPHENE_LIBS)
+data_DATA = shaders/gray_shader.fs shaders/fisheye_shader.fs shaders/tunnel_shader.fs shaders/twirl_shader.fs
+EXTRA_DIST = shaders/gray_shader.fs shaders/fisheye_shader.fs shaders/tunnel_shader.fs shaders/twirl_shader.fs
+
libgstopengl_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstopengl_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS)
diff --git a/ext/gl/shaders/fisheye_shader.fs b/ext/gl/shaders/fisheye_shader.fs
new file mode 100755
index 0000000..a57a203
--- /dev/null
+++ b/ext/gl/shaders/fisheye_shader.fs
@@ -0,0 +1,14 @@
+precision mediump float;
+varying vec2 v_texcoord;
+uniform sampler2D tex;
+void main () {
+ vec2 texturecoord = v_texcoord.xy;
+ vec2 normcoord;
+ normcoord = texturecoord - 0.5;
+ float r = length (normcoord);
+ normcoord *= r * 1.414;
+ texturecoord = normcoord + 0.5;
+ vec4 color = texture2D (tex, texturecoord);
+ gl_FragColor = color;
+}
+
diff --git a/ext/gl/shaders/gray_shader.fs b/ext/gl/shaders/gray_shader.fs
new file mode 100755
index 0000000..75e9790
--- /dev/null
+++ b/ext/gl/shaders/gray_shader.fs
@@ -0,0 +1,12 @@
+precision mediump float;
+varying vec2 v_texcoord;
+uniform sampler2D tex;
+void main () {
+ vec4 color = texture2D (tex, v_texcoord.xy);
+ float y = dot(color.rgb, vec3(0.2125, 0.7154, 0.0721));
+ color.r = y;
+ color.g = y;
+ color.b = y;
+ gl_FragColor = color;
+}
+
diff --git a/ext/gl/shaders/tunnel_shader.fs b/ext/gl/shaders/tunnel_shader.fs
new file mode 100755
index 0000000..5888c92
--- /dev/null
+++ b/ext/gl/shaders/tunnel_shader.fs
@@ -0,0 +1,14 @@
+precision mediump float;
+varying vec2 v_texcoord;
+uniform sampler2D tex;
+void main () {
+ vec2 texturecoord = v_texcoord.xy;
+ vec2 normcoord;
+ normcoord = (texturecoord - 0.5);
+ float r = length(normcoord);
+ normcoord *= clamp (r, 0.0, 0.275) / r;
+ texturecoord = normcoord + 0.5;
+ vec4 color = texture2D (tex, texturecoord);
+ gl_FragColor = color;
+}
+
diff --git a/ext/gl/shaders/twirl_shader.fs b/ext/gl/shaders/twirl_shader.fs
new file mode 100755
index 0000000..2b9d5fd
--- /dev/null
+++ b/ext/gl/shaders/twirl_shader.fs
@@ -0,0 +1,21 @@
+precision mediump float;
+varying vec2 v_texcoord;
+uniform sampler2D tex;
+void main () {
+ vec2 texturecoord = v_texcoord.xy;
+ vec2 normcoord;
+ normcoord = texturecoord - 0.5;
+ float r = length (normcoord);
+ // calculate rotation angle: maximum (about pi/2) at the origin and
+ // gradually decrease it up to 0.6 of each quadrant
+ float phi = (1.0 - smoothstep (0.0, 0.3, r)) * 1.6;
+ // precalculate sin phi and cos phi, save some alu
+ float s = sin(phi);
+ float c = cos(phi);
+ // rotate
+ normcoord *= mat2(c, s, -s, c);
+ texturecoord = normcoord + 0.5;
+ vec4 color = texture2D (tex, texturecoord);
+ gl_FragColor = color;
+}
+
--
1.7.9.5