AW: AW: Dynamic change of glshader element

Christian Winkler christian at heidelbergs.de
Sun Nov 23 07:50:56 PST 2014


So, now i have a small proof of concept, which allows change of uniforms variables.
But this is obviously file based, not fast enough, and worst of all, requires the pipeline tob e stopped for changing uniforms


typedef struct _CustomData {
  GstElement *pipeline;   /* The running pipeline */
  GstElement *distortion;   /* The glshader element */
...
} CustomData;

void gst_native_set_shiftxy (JNIEnv* env, jobject thiz, jfloat shiftx, jfloat shifty) {
	CustomData *data = GET_CUSTOM_DATA (env, thiz, custom_data_field_id);
	gst_element_set_state (data->pipeline, GST_STATE_READY);
	g_object_set (G_OBJECT (data->distortion), "preset", "/data/data/com.lonestar.groundpi/files/dist.mod", NULL);
	 gst_element_set_state (data->pipeline, GST_STATE_PLAYING);
}

Actually, i want to have something like this: No interruption of running pipe, but on the fly change of shader.
After reading of tons of sites ant source code, i still dont get it.
Any help out there?

void gst_native_set_shiftxy (JNIEnv* env, jobject thiz, jfloat shiftx, jfloat shifty) {
	CustomData *data = GET_CUSTOM_DATA (env, thiz, custom_data_field_id);

.. ???

	gst_gl_shader_set_uniform_1f(G_OBJECT ( data->distortion ) , "shiftX", shiftx); // Gives an exception violation
	gst_gl_shader_set_uniform_1f(G_OBJECT ( data->distortion ) , "shiftY", shifty);

-- ???
}



-----Ursprüngliche Nachricht-----
Von: gstreamer-devel [mailto:gstreamer-devel-bounces at lists.freedesktop.org] Im Auftrag von Christian Winkler
Gesendet: Sonntag, 23. November 2014 13:05
An: 'Discussion of the development of and with GStreamer'
Betreff: AW: AW: Dynamic change of glshader element

Ok...after hours of trying to get uniforms working even in command line i have to come to a simple conclusion:
The setting of a preset file for a glshader element is broken in the windows version of gstreamer.
It works under android and ubuntu....

What a waste of time :-/

Thanks to all of you for your help.

Now lets go fort he c code...

-----Ursprüngliche Nachricht-----
Von: gstreamer-devel [mailto:gstreamer-devel-bounces at lists.freedesktop.org] Im Auftrag von Matthew Waters
Gesendet: Mittwoch, 19. November 2014 10:45
An: gstreamer-devel at lists.freedesktop.org
Betreff: Re: AW: Dynamic change of glshader element

On 19/11/14 08:18, Christian Winkler wrote:
> Dear Luc,
>
> thanks.
> I definitley have trouble setting the presets.
> Either by command line or code, they are not accepted.
>
> For instance:
> gst-launch-1.0.exe -e -v videotestsrc ! "video/x-raw, width80, 
> heightr0" ! videoconvert ! glshader location=dist.frag 
> preset=dist.preset ! glimagesink
>
>
> dist frag:
> precision mediump float;
> varying vec2 v_texcoord;
> uniform sampler2D tex;
>
> const vec4 kappa =ec4(2.75,1.7,0.5,0.5); const float screen_width 
> =920.0; const float screen_height =080.0; const vec2 leftCenter 
> =ec2(0.25, 0.4); const vec2 rightCenter =ec2(0.75, 0.4); const float 
> separation =0.025; const bool stereo_input =alse; uniform float 
> scaleFactor; .........
>
> dist.preset:
> float scaleFactor = float(0.2);
>
> or, also tried:
> float scaleFactor =.2;

The following works for me.  Note that you need the float on both sides of the assignment in the preset and they must be the same type.  Also, you could try running with the gst debug log and seeing what it outputs.

preset/vars:
float scale = float(0.2);

shader:
#ifdef GL_ES
precision mediump float;
#endif
varying vec2 v_texcoord;
uniform sampler2D tex;
uniform float scale;

void main () {
  gl_FragColor = texture2D( tex, v_texcoord ) * vec4(vec3(scale), 1.0); }

> The value 0.2 is simply ignored.
> I dont know why that happens
>
> scaleFactor iss et to 0.
>
> -----Ursprüngliche Nachricht-----
> Von: gstreamer-devel
> [mailto:gstreamer-devel-bounces at lists.freedesktop.org] Im Auftrag von 
> luc.deschenaux
> Gesendet: Montag, 17. November 2014 04:45
> An: gstreamer-devel at lists.freedesktop.org
> Betreff: Re: Dynamic change of glshader element
>
> You could also initialize the uniform variables using text values 
> (using GLSL
> syntax) with something like
>         g_object_set (G_OBJECT (glshader), "preset", str, NULL)
>
> or change their value using text values with
>         g_object_set (G_OBJECT (glshader), "vars", str, NULL)
>
> See
> https://bug600195.bugzilla-attachments.gnome.org/attachment.cgi?id661
> 9
>
> But since this rely on the gst_gl_shader_set_uniform methods (with the overhead implied for parsing the text string), calling the gst_gl_shader_set_uniforms methods directly is more efficient for modifying values dynamically.
>
>
>
> --
> View this message in context: 
> http://gstreamer-devel.966125.n4.nabble.com/Dynamic-change-of-glshader
> -element-tp4669514p4669526.html Sent from the GStreamer-devel mailing 
> list archive at Nabble.com.
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
>



_______________________________________________
gstreamer-devel mailing list
gstreamer-devel at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



More information about the gstreamer-devel mailing list