<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
change it to uniform variable. "uniform vec2 leftCenter;"<br>
<br>
then you should be able to change it with
gst_gl_shader_set_uniform_2f(shader, "leftCenter", x, y);<br>
<br>
<div class="moz-cite-prefix">Dňa 15.11.2014 o 11:10 Christian
Winkler napísal(a):<br>
</div>
<blockquote
cite="mid:000301d000bc$5e6abed0$1b403c70$@heidelbergs.de"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.E-MailFormatvorlage17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal">Dear Members,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">i am trying to change a glshader element at
runtime in a native Gstreamer application.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The idea is to convert a rtsp Stream to an
side-by-side view for a android google cardboard VR device.<o:p></o:p></p>
<p class="MsoNormal">I want to implement headtracking as well
and therefore want to change the opengl fragment dynamically
based on head position.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The code below works for a static .frag
file.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="text-autospace:none">QUESTION: How
can i change for example <o:p></o:p></p>
<p class="MsoNormal" style="text-autospace:none"><u><span
style="font-size:10.0pt;font-family:"Courier
New";color:black">const</span></u><span
style="font-size:10.0pt;font-family:"Courier New"">
vec2 leftCenter = vec2(0.25, 0.4);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><u><span
style="font-size:10.0pt;font-family:"Courier
New";color:black">const</span></u><span
style="font-size:10.0pt;font-family:"Courier New"">
vec2 rightCenter = vec2(0.75, 0.4);<o:p></o:p></span></p>
<p class="MsoNormal">DYNAMICALLY during runtime in the native
code?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">There used tob o something like
gstglfiltershader, but i can not find a similar functionality
in the current 1.4.x releases.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks!!!!<o:p></o:p></p>
<p class="MsoNormal">Kind regards<o:p></o:p></p>
<p class="MsoNormal">Christian<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The current Pipeline is set up as follows
(JNI Code for an Android App).<o:p></o:p></p>
<p class="MsoNormal">This <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> ….<o:p></o:p></p>
<p class="MsoNormal"> // rtspsrc
location=<a class="moz-txt-link-freetext" href="rtsp://192.168.137.240:8554/test">rtsp://192.168.137.240:8554/test</a> latency=0
drop-on-latency=true ! application/x-rtp, payload=96 !
rtph264depay ! decodebin ! glimagesink sync=false<o:p></o:p></p>
<p class="MsoNormal"> data->source =
gst_element_factory_make ("rtspsrc","rtspsrc");<o:p></o:p></p>
<p class="MsoNormal"> g_object_set(G_OBJECT
(data->source),"location",pipelineParameterFromJava,"latency",0,"drop-on-latency",true,NULL);<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> data->pipeline =
gst_pipeline_new ("fpv-pipeline");<o:p></o:p></p>
<p class="MsoNormal">
data->filter=gst_element_factory_make("capsfilter","filter");<o:p></o:p></p>
<p class="MsoNormal"> data->depayloader =
gst_element_factory_make ("rtph264depay","rtph264depay");<o:p></o:p></p>
<p class="MsoNormal"> data->decoder =
gst_element_factory_make ("decodebin","decodebin");<o:p></o:p></p>
<p class="MsoNormal"> data->distortion =
gst_element_factory_make ("glshader","glshader");<o:p></o:p></p>
<p class="MsoNormal"> data->video_sink =
gst_element_factory_make ("glimagesink","glimagesink");<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> filtercaps =
gst_caps_new_simple ("application/x-rtp","payload",
G_TYPE_INT, 96,NULL);<o:p></o:p></p>
<p class="MsoNormal"> g_object_set (G_OBJECT
(data->filter), "caps", filtercaps, NULL);<o:p></o:p></p>
<p class="MsoNormal"> g_object_set (G_OBJECT
(data->distortion), "location",
"/data/data/com.lonestar.groundpi/files/distortion.frag",
NULL);<o:p></o:p></p>
<p class="MsoNormal"> gst_caps_unref
(filtercaps);<o:p></o:p></p>
<p class="MsoNormal"> g_object_set(G_OBJECT
(data->video_sink),"sync",false,NULL);<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> if (!data->pipeline ||
!data->source || !data->filter || !data->depayloader
|| !data->decoder || !data->video_sink ||
!data->distortion) {<o:p></o:p></p>
<p class="MsoNormal"> g_printerr ("One element
could not be created. Exiting.\n");<o:p></o:p></p>
<p class="MsoNormal"> return -1;<o:p></o:p></p>
<p class="MsoNormal"> }<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> gst_bin_add_many (GST_BIN
(data->pipeline), data->source, data->filter,
data->depayloader, data->decoder, data->video_sink,
data->distortion, NULL);<o:p></o:p></p>
<p class="MsoNormal"> gst_element_link_many
(data->filter, data->depayloader, data->decoder,
NULL);<o:p></o:p></p>
<p class="MsoNormal"> gst_element_link_many
(data->distortion, data->video_sink, NULL);<o:p></o:p></p>
<p class="MsoNormal"> g_signal_connect
(data->source, "pad-added", G_CALLBACK (cb_new_pad),
data->filter);<o:p></o:p></p>
<p class="MsoNormal"> g_signal_connect
(data->decoder, "pad-added", G_CALLBACK (cb_new_pad),
data->distortion);<o:p></o:p></p>
<p class="MsoNormal" style="text-indent:35.4pt">….<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Distortion.frag:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">#extension
GL_ARB_texture_rectangle : enable<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">precision
<u><span style="color:black">mediump</span></u> float;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">varying
vec2 v_texcoord;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">uniform
sampler2D <u><span style="color:black">tex</span></u>;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">
<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><u><span
style="font-size:10.0pt;font-family:"Courier
New";color:black">const</span></u><span
style="font-size:10.0pt;font-family:"Courier New"">
vec4 <u><span style="color:black">kappa</span></u> =
vec4(2.75,1.7,0.5,0.5);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><u><span
style="font-size:10.0pt;font-family:"Courier
New";color:black">const</span></u><span
style="font-size:10.0pt;font-family:"Courier New"">
float screen_width = 1920.0;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><u><span
style="font-size:10.0pt;font-family:"Courier
New";color:black">const</span></u><span
style="font-size:10.0pt;font-family:"Courier New"">
float screen_height = 1080.0;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><u><span
style="font-size:10.0pt;font-family:"Courier
New";color:black">const</span></u><span
style="font-size:10.0pt;font-family:"Courier New"">
float scaleFactor = 0.62;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><u><span
style="font-size:10.0pt;font-family:"Courier
New";color:black">const</span></u><span
style="font-size:10.0pt;font-family:"Courier New"">
vec2 leftCenter = vec2(0.25, 0.4);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><u><span
style="font-size:10.0pt;font-family:"Courier
New";color:black">const</span></u><span
style="font-size:10.0pt;font-family:"Courier New"">
vec2 rightCenter = vec2(0.75, 0.4);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><u><span
style="font-size:10.0pt;font-family:"Courier
New";color:black">const</span></u><span
style="font-size:10.0pt;font-family:"Courier New"">
float separation = -0.025;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><u><span
style="font-size:10.0pt;font-family:"Courier
New";color:black">const</span></u><span
style="font-size:10.0pt;font-family:"Courier New"">
<u><span style="color:black">bool</span></u> stereo_input =
false;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">
<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">//
Scales input texture coordinates for distortion.<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">vec2
hmdWarp(vec2 LensCenter, vec2 texCoord, vec2 Scale, vec2
ScaleIn) {<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">vec2
<u><span style="color:black">theta</span></u> = (texCoord -
LensCenter) * ScaleIn;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">float
rSq = theta.x * theta.x + theta.y * theta.y;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">vec2
<u><span style="color:black">rvector</span></u> = <u><span
style="color:black">theta</span></u> * (kappa.x +
kappa.y * rSq + kappa.z * rSq * rSq + kappa.w * rSq * rSq *
rSq);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">vec2
<u><span style="color:black">tc</span></u> = LensCenter +
Scale * <u><span style="color:black">rvector</span></u>;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">return
<u><span style="color:black">tc</span></u>;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">}<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">
<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><u><span
style="font-size:10.0pt;font-family:"Courier
New";color:black">bool</span></u><span
style="font-size:10.0pt;font-family:"Courier New"">
validate(vec2 <u><span style="color:black">tc</span></u>, <u><span
style="color:black">int</span></u> eye) {<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">if
( stereo_input ) {<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">//keep
within bounds of texture<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">if
((eye == 1 && (tc.x < 0.0 || tc.x > 0.5)) ||<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">(eye
== 0 && (tc.x < 0.5 || tc.x > 1.0)) ||<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">tc.y
< 0.0 || tc.y > 1.0) {<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">return
false;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">}<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">}
else {<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">if
( tc.x < 0.0 || tc.x > 1.0 ||<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">tc.y
< 0.0 || tc.y > 1.0 ) {<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">return
false;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">}<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">}<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">return
true;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">}<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">
<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">void
main() {<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">float
as = float(screen_width / 2.0) / float(screen_height);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">vec2
Scale = vec2(0.25, as);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">vec2
ScaleIn = vec2(2.0 * scaleFactor, 1.0 / as * scaleFactor);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">
<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">vec2
texCoord = v_texcoord;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">vec2
<u><span style="color:black">tc</span></u> = vec2(0);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">vec4
color = vec4(0);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">if
( texCoord.x < 0.5 ) {<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">texCoord.x
+= separation;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">texCoord
= hmdWarp(leftCenter, texCoord, Scale, ScaleIn );<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">if
( !stereo_input ) {<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">texCoord.x
*= 2.0;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">}<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">color
= texture2D(<u><span style="color:black">tex</span></u>,
texCoord);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">if
( !validate(texCoord, 0) ) {<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">color
= vec4(0);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">}<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">}
else {<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">texCoord.x
-= separation;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">texCoord
= hmdWarp(rightCenter, texCoord, Scale, ScaleIn);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">if
( !stereo_input ) {<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">texCoord.x
= (texCoord.x - 0.5) * 2.0;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">}<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">color
= texture2D(<u><span style="color:black">tex</span></u>,
texCoord);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">if
( !validate(texCoord, 1) ) {<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">color
= vec4(0);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">}<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">}<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span
style="font-size:10.0pt;font-family:"Courier New"">gl_FragColor
= color;<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Courier New"">}</span><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
gstreamer-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a>
</pre>
</blockquote>
<br>
</body>
</html>