Posts in Category "Hydra"

May 14, 2008

Astro Beta and new Pixel Bender Toolkit now available!

Big news tonight!

Finally, you don’t have to just hear about Pixel Bender Filters and play with them in the toolkit, now you can actually try some of them out! The beta of Astro is now available. Check out the demos to see Pixel Bender Shaders running on images, vectors and video in real time!

Also, today we released a new Pixel Bender Toolkit on our new Pixel Bender wiki pages. What is new in this release? The new name, obviously, but also some bug fixes and some new features (check out the preferences dialog box!)

More info soon!

10:47 PM Permalink
May 5, 2008

Hydra is now Pixel Bender!

Hydra is an awesome name for a language like the one we created. At the very beginning, Jonathan Shekter came up with it as a code name for this cool language that could run on different kinds of hardware efficiently. The problem is that it’s a great name for any kind of technology that does multiple things, so it is pretty popular. We didn’t want to confuse folks, so we worked with the Adobe branding team to come up with a new name that we could use moving forward. That name is Pixel Bender ™.

So from now on, if you hear me say “hydra” in a 1:1 conversation (sorry, conference talks are out), you can call me on it and I’ll give you a cool limited-edition hydra pin (while supplies last).

Along with the name change of the language, we’re also changing the name of the “AIF Toolkit” to be the “Pixel Bender Toolkit.” The file extensions will also change. We should be posting a new version of the toolkit soon with these changes.

very obscure reference/fact
It is only partially true that the name Pixel Bender won out over another internal favorite “Shektran” because I was hoping to finagle a visit to Rough Draft Studios or The Curiosity Company (joke).

5:14 PM Permalink
April 11, 2008

AIF Toolkit Preview Release #2 available now!

I’ve been promising it for a while, but it is finally available for download. The second release of the AIF Toolkit with a lot of changes under the hood (many requested by you!)

A partial list:

  • Supports both GPU and CPU execution of Hydra filters. A filter will automatically run on the CPU if your graphics card is not supported by the application.
  • Supports user preferences and their persistence across application launches.
    • Flash Warnings and Errors – with this preference checked, Hydra code will be checked for validity against the subset of Hydra that Flash Player supports.
    • Render on Idle – this setting determines if the toolkit should try to render as often as possible. You may choose to turn off this setting to conserve power when running using battery power on a laptop.
  • Supports exporting a Hydra filter as Hydra Byte Code for future use with Astro.
  • There have been some changes and additions to the Hydra language.
    • Conditionals are supported in Flash-compatible Hydra – you are now able to use ‘if’ statements in your Hydra for Flash programs.
    • A languageVersion statement is now compulsory in Hydra files
    • Images are now parameters – images are now available by name in the kernel scope instead of the evaluatePixel scope. That means that they can be used more easily in the per-frame functions like evaluateDependents and the region reasoning functions. In addition, the function signatures for the needed and changed functions have been simplified. The input_index has been replaced by an imageRef and the domain of definition array is no longer passed in. There is a new built-in function – “dod” – that returns the domain of definition of an image.
    • There are two new built-in functions in Hydra to support pixel aspect ratio (PAR): float2 pixelSize(image) float pixelAspectRatio(image) You can use these functions anywhere inside the kernel, as long as the image parameters to both functions are the declared global input or output image variables.

    There are a ton more changes big and small. This is still a preview release. There are more changes to come will be in a following preview release. Please try it out and let us know if you find any problems or have more suggestions.

3:11 PM Permalink
February 22, 2008

New Adobe Hydra Blog and update

Brian Ronan, a developer on the AIF team has just started a new blog specifically on developing Hydra kernels. Hopefully, he’ll make up some of my ample posting slack…

Some news, the long-promised technology preview 2 of the AIF Toolkit is nearing completion. Just ironing out the last few minor bugs and testing the installer now. This release will feature the final syntax of the Hydra 1.0 kernel language. Since my last post we’ve added a couple things to the language to make it more capable for advanced video and image application usage. I’ll post more details and some tips and tricks when the new version is posted.

Stay tuned because we still have some really large surprises around Hydra to announce between now and the official release…

2:48 PM Permalink
January 15, 2008

What if…

Conditionals were back in for Hydra in Astro?

Well… They Are!

You’ll now be able to use if statements in your Hydra for Flash programs. The new toolkit will have that removed as an error. Thank Tinic and Bob Archer for stepping up to get this done for CS4.

This is one of the reasons why I’ve delayed releasing the Toolkit… I may have another surprise before the second preview release appears on labs.

Watch this space for more details…

11:47 AM Permalink
December 11, 2007

Hydra course at FITC Amsterdam

I thought I’d give a quick plug to Joa Ebert who is teaching a course entitled Chop The Hydra at FITC Amsterdam in February. If you’re attending FITC, you should definitely check it out.

12:03 PM Permalink
November 15, 2007

Some hydra changes for the next AIF Toolkit release

I’ve been working on the next version of the toolkit and I’m hoping it will make a bunch of you hydra developers happy. I’ve rolled in a lot of feature requests from the forums and the big news is that it should work on ALL supported platforms (OS 10.4.10+, XP, Vista) REGARDLESS OF YOUR VIDEO CARD. We’re still tuning CPU performance, so if you don’t have a supported graphics card, the performance won’t be stellar, but it will let you start playing with Hydra. I’m hoping to have it out to you all some time next month.

We have made a language change to Hydra that will be in this next release. It is small, but it will break any existing filters. Sorry about that, but at the moment, this is a technology preview after all. I’ll include a script we wrote that will fix up your hydra files automagically. The change is that images are now parameters. This is a small change, but it has a big effect. Images will now be available by name in kernel scope instead of EvaluatePixel scope and that means that they can be used in per-frame functions like EvaluateDependents and the region reasoning functions more simply.

Here’s an example of the old and new syntax:

kernel OldSyntax
{
parameter float k;

void evaluatePixel(
in image4 foreground,
in image4 background,
out pixel4 result)
{
pixel4 fp = sample( foreground, outCoord() );
pixel4 bp = sample( background, outCoord() );

result = mix( fp, bp, k );
}

region needed(
region output_region,
int input_index,
region input_DOD[])
{
if (input_index == imageIndex( background ))
return input_DOD[ imageIndex( background ) ];
else
return output_region;
}
}

kernel NewSyntax
{
parameter float k;
input image4 foreground;
input image4 background;
output pixel4 result;

void evaluatePixel()
{
pixel4 fp = sample( foreground, tCoord() );
pixel4 bp = sample( background, tCoord() );

result = mix( fp, bp, k );
}

region needed(
region output_region,
imageRef input_image)
{
if( input_image == background ) )
return dod( background );
else
return output_region;
}
}

As always, we always want to hear what you think. Either reply here or on the forum.

[Updated 11/19/07 to fix a typo made under the influence of too much caffeine]

9:38 AM Permalink
October 31, 2007

Cool hydra filters

So, I’ve been meaning to post about some of the cool hydra filters that folks have been posting to their blogs and the Hydra Filter Gallery. I’ve been pretty busy working on the next release of the AIF Toolkit, but the whole team has been really digging some of the cool filters that everyone has been posting. Here are some of my favorites so far (in no particular order)… This is just a subset of what has been posted to the gallery…

Double Plasma by Martin ‘Cifko’ Stefcek – This is just so wonderfully trippy.
Fuzz by Tyler Glaiel – This would be the start of a cool cross-disolve filter.
Colored Spotlight by Andy Zupko – I like this one because it is simple, but very effective.
Spherize by Joa Ebert – The first non-Adobe hydra developer contribution is something pretty cool: a simple, yet powerful spherize filter. Joa has posted a ton of filters, I just had to pick one to be fair.
AIF’s own Mangler mashed up two of Joa’s filters: Technodots and Twirl and came up with this beauty: TechoTwirl
http://www.quasimondo.com/hydra/sineNoise1.jpg SineNoise: The lack of a built-in noise or random function (currently) in Hydra prompted Mario Klingerman to see what he could do to create noise. Very cool. He’s also posted some great gradient generators in the gallery.
Polar Coordinates: This is another fun kernel to play with. by wf
Zeh has created an adjustable threshhold filter that is pretty cool and yet pretty simple and easy to understand.
The Vortex filter by Jan is also amazingly trippy, this thing looks awesome animated.

 

In a future post, I’ll link to some of the stuff that the hydra developers have been posting on their blogs.

 

What are your favorite filters? Also, what kinds of things would you like me to cover in future posts? Let me know in the comments or on the forum.

4:55 PM Permalink
October 23, 2007

The FadeToHistory Hydra Filter in action

I figured that the static pictures were boring, so I decided to show what the FadeToHistory might look like in action.

yes. this is a movie, not some secret feature in Flash Player 9. I left in the rewind Flash to make it explicit.

3:21 PM Permalink

Writing a FadeToHistory Hydra Filter, part 3

Previous parts to this tutorial:
Steps 1-3
Steps 4-6

At this point, we have a hydra filter which does an interactive cross-disolve from a color image to a luminance based black and white image: Download Hydra Filter

The current version of the filter is:

kernel FadeToHistory

{
parameter float crossfade;
const float3 lumMult = float3(0.3, 0.59, 0.11);

void
evaluatePixel(in image4 src, out pixel4 dst)
{
dst = sampleNearest(src,outCoord());
float luminance = dot(dst.rgb, lumMult);
dst.rgb = mix(dst.rgb, float3(luminance), crossfade);
}
}

Step 7: Adding the Sepia Conversion

We’re about halfway to being done. We are fading from color to black and white. Time to add the sepia toning so that we can finish this sucker off. There are a bunch of different methods for doing sepia conversion, but essentially the general idea is to mix the red, green and blue channels in different amounts to preserve the original image while giving it that old-time photographic feel. Unlike computing the luminance, we’ll need to produce all three color channels, so the calculation is a bit more cumbersome:

        float3 sepia = float3( dst.r * 0.4 +
dst.g * 0.769 +
dst.b * 0.189,
dst.r * 0.349 +
dst.g * 0.686 +
dst.b * 0.168,
dst.r * 0.272 +
dst.g * 0.534 +
dst.b * 0.131 );

I’ve modified the filter above so that we can test the sepia toning.

kernel FadeToHistory

{
parameter float crossfade;
const float3 lumMult = float3(0.3, 0.59, 0.11);

void
evaluatePixel(in image4 src, out pixel4 dst)
{
dst = sampleNearest(src,outCoord());
float luminance = dot(dst.rgb, lumMult);
float3 sepia = float3( dst.r * 0.4 +
dst.g * 0.769 +
dst.b * 0.189,
dst.r * 0.349 +
dst.g * 0.686 +
dst.b * 0.168,
dst.r * 0.272 +
dst.g * 0.534 +
dst.b * 0.131 );
dst.rgb = mix(dst.rgb, sepia, crossfade);
}
}

So now we’ll run the filter and made sure that it compiles without error and does something like what we want. If you set the crossfade parameter to 1.0, you should see something like this:

step 8: doing the full fade

We have black and white, we have sepia, now we want to fade from color to black and white and then to sepia. First, I’ll show how I would do this with Flash compatibility mode off and then I’ll show how I would do it with Flash compatibility on.

With Flash warnings and errors off, I would write the code like this:

kernel FadeToHistory

{
parameter float crossfade<minValue:0.0; maxValue:2.0; defaultValue:0.0;>;

const float3 lumMult = float3(0.3, 0.59, 0.11);

void
evaluatePixel(in image4 src, out pixel4 dst)
{
dst = sampleNearest(src,outCoord());
float luminance = dot(dst.rgb, lumMult);
float3 sepia = float3( dst.r * 0.4 +
dst.g * 0.769 +
dst.b * 0.189,
dst.r * 0.349 +
dst.g * 0.686 +
dst.b * 0.168,
dst.r * 0.272 +
dst.g * 0.534 +
dst.b * 0.131 );

float3 startMix = dst.rgb;
float3 endMix = float3(luminance);
float mixValue = crossfade;
if ( crossfade > 1.0 )
{
// normalize mix value to the range of 0-1
mixValue -= 1.0;
startMix = float3(luminance);
endMix = sepia;
}
dst.rgb = mix(startMix, endMix, mixValue);
}
}



If you want to try this, be sure to uncheck the
"Turn on Flash warnings and Errors" in the build menu, or you’ll get the error "ERROR: (line 30): If statements not supported in Hydra byte code"

A few things to note:

  • I’ve added metadata to the crossfade parameter to specify that its range is now from 0.0 to 2.0 instead of the default 0.0 to 1.0
  • I’ve added temporary variables for startMix, endMix and mixValue to simplify the code. By default, they are the original color, the luminance color and the crossfade value.
  • If crossfade is larger than 1.0
    • I overwrite the temporary variable mixValue to be mapped into the range of 0.0 to 1.0 so that we can use that value in the mix function
    • I overwrite the startMix value with luminance color so that is where we mix from instead of the original color
    • I overwrite the endMix value with the sepia color

Now, about that error we get if we try to compile with Flash warnings and errors on. In order to support older graphics cards, we will not support conditional branching (if statements) in Astro. That makes things a bit harder, but in no way impossible. This is how I would rewrite the above filter to get around that limitation:

 

kernel FadeToHistory

{
parameter float crossfade<minValue:0.0; maxValue:2.0; defaultValue:0.0;>;

const float3 lumMult = float3(0.3, 0.59, 0.11);

void
evaluatePixel(in image4 src, out pixel4 dst)
{
dst = sampleNearest(src,outCoord());
float3 luminance = float3( dot(dst.rgb, lumMult) );
float3 sepia = float3( dst.r * 0.4 +
dst.g * 0.769 +
dst.b * 0.189,
dst.r * 0.349 +
dst.g * 0.686 +
dst.b * 0.168,
dst.r * 0.272 +
dst.g * 0.534 +
dst.b * 0.131 );

float3 startMix = dst.rgb;
startMix = (crossfade <= 1.0) ? startMix : luminance;
float3 endMix = (crossfade <= 1.0) ? luminance : sepia;
float mixMinusOne = crossfade - 1.0;
float mixValue = (crossfade <= 1.0) ? crossfade : mixMinusOne;
dst.rgb = mix(startMix, endMix, mixValue);
}
}

Instead of doing conditional branching in Flash, I can do conditional assignments of pre-computed values. What this means is that I have to do a little more computation, but I can still get the results I want. Instead of only doing computation in an if or else statement, I do all the computation in the filter and then only assign the result to the final variables if the condition is met. Of course you can do conditional assignments in regular Hydra too to be clear.

The big changes in this version of the filter is that I have a couple of extra statements and an extra variable, but the output is exactly the same.

All we have left to do is a bit more cleanup and then we’re done!

Step 9: final cleanup

That sepia calculation is annoying. There is a lot of math there and it takes up a lot of space. Doing these kinds of calculations can be pretty common in image and video processing and there is a simpler way to do them in Hydra. Doing this kind of operation where we combine each channel of a color with a blend of all of the colors added together is exactly the same thing we do when we multiply a vector by a matrix. Matricies are built-in to Hydra and you can use them like any other type. This is how that looks:

 

kernel FadeToHistory

{
parameter float crossfade<minValue:0.0; maxValue:2.0; defaultValue:0.0;>;

const float3 lumMult = float3(0.3, 0.59, 0.11);
const float3x3 sepiaMatrix = float3x3(0.400, 0.769, 0.189,
0.349, 0.686, 0.168,
0.272, 0.534, 0.131);

void
evaluatePixel(in image4 src, out pixel4 dst)
{
dst = sampleNearest(src,outCoord());
float3 luminance = float3( dot(dst.rgb, lumMult) );
float3 sepia = dst.rgb * sepiaMatrix;

float3 startMix = dst.rgb;
startMix = (crossfade <= 1.0) ? startMix : luminance;
float3 endMix = (crossfade <= 1.0) ? luminance : sepia;
float mixMinusOne = crossfade - 1.0;
float mixValue = (crossfade <= 1.0) ? crossfade : mixMinusOne;

dst.rgb = mix(startMix, endMix, mixValue);
}
}

Once again, I’ve used a const for sepiaMatrix because it stays the same from pixel to pixel. Now everything looks cleaner and simpler. It is easier to understand and more importantly, it is easier to mess around with and make changes. Download the final version and try it for yourself!

Thanks for following this tutorial and let me know in the comments if you have questions or would like other tutorials.

12:13 PM Permalink