New GLGraphics release: 0.8.9   6 comments

This release of GLGraphics introduces a new and improved way of handling the parameters of the texture filters. Before 0.8.9, the parameters had to be passed to the filter with a GLTextureFilterParameters object. This object allowed only a predetermined number of parameters to be set in the shader. Furthermore, the name of these parameters was hard-coded, for example a float parameter in the shader had to be called par_flt1, for instance, in order to be recognized by the filter.

Now an arbitrary number of parameters with arbitrary names can be used. For example, if the shader has three float parameters:


uniform float exposure;
uniform float bloom;
uniform float bright;
void main()
{
vec2 st = gl_TexCoord[0].st;
...

then the filter xml configuration file has to list them as follows:

<parameter type=”float” name=”exposure” label=”Exposure level”>0.86</parameter>
<parameter type=”float” name=”bloom” label=”Bloom factor”>0.5</parameter>
<parameter type=”float” name=”bright” label=”Brightness threshold”>0.9</parameter>

Label is not currently used, and the numbers 0.86, 0.5, etc. are the default values assigned to each parameter.

Then the value of these parameters can be set in the sketch by the setParameterValue() method:


filter.setParameterValue("exposure", fy);
filtersetParameterValue("bright", fx);
filter.apply(...

Parameters of type int, float, vec2, vec3, vec4, mat2, mat3 and mat4 can be specified. For vector or matrix types, setParameterValue() is overloaded to take a float arrays. For an updated version of the html reference, please check this link.

Advertisements

Posted November 28, 2008 by ac in Programming

Tagged with , , , , , ,

6 responses to “New GLGraphics release: 0.8.9

Subscribe to comments with RSS.

  1. Processing 1.0.1 doesn’t support JARs compiled in Java 1.6 :(

    Only 1.5, I couldn’t get your examples to work under Processing 1.0.1 because of this.

  2. Hey Andrew, many thanks for the report, I’ll fix as soon as possible (but not before this Sunday, though).

  3. No problem, I downloaded the source and built it myself for Java 1.5 :)

  4. great, I’m glad that the source code was useful to you!

  5. Andres,

    does this mean that the built-in params par_vec21, etc., doesn’t work any more? If so, your examples page should be updated. The reason I’m guessing that it doesn’t work is because I’m not getting anything in the shader when I do something like:

    filter.setFilterParameter(“par_vec21”, new float[] { 1.0, 2.0 });

  6. that’s correct, but the advantage of the new approach is that now you can give the parameters any name you want. I still have to update the glgraphics home page (which I’d like to port to a wiki-style site). In the meantime, please take a look at the examples included with the latest release of the library.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: