Feed on
Posts
Comments

Wow,  Shazam was mentioned during the MIX10 keynote.  Much to my dismay however it wasn’t our beloved Shazzam pixel shader tool.  No, there is another application lurking out there with a very similar name (note the subtle difference in the spelling) .  Back when Shazzam (the pixel shader utility) was released I didn’t know there was a product with a comparable name.   This other software product, Shazam (the music recognition software) is actually an amazing tool in its niche. Play a few seconds of music into Shazam and it tells you the song title.

 

Who’s wearing the Shazzam shirt?

Here’s a few pictures of people wearing our Shazzam T-shirts during the MIX10 conference in March 2010.

image

Figure 1:  Jaime Rodriguez, Adam Kinney, Brennon Williams

 

image

Figure 2: Laurent Bugnion and Cory Plotts

Videos too

Cory was wearing his Shazzam colors during this video.

 

Feeling left out?

Want your own Shazzam shirt?   If you didn’t get a chance to go to MIX you can still get one.  Just go to the Shazzam store and pick our your own shirt.  Proceeds help support development of Shazzam.

The testing UI in Shazzam is a popular feature.  I get a lot of email commenting on how nice it is to see the shader effects applied in real time.

The top half of the Shazzam screen is where you find all the sample test items.  This includes six sample images.

image

Figure 1: Sample image tabs.

 

You can add your own image in the Custom Image tab via the File menu.

image

Figure 2:  File menu.

 

image

Figure 3: Your custom image.

 

Trying out the effect

Once you have your HLSL code ready you apply the affect by pressing the F7 key.  The shader is applied to all eight samples. Here you can see the WaveWarper effect applied to the custom image.

image

Figure 4: WaveWarper effect applied.

 

What’s new in version 1.2?

There are two new tabs added to the tab section in v1.2.  The first is a sample UI consisted of a few buttons and a listbox.  The second is a media tab, which plays a sample video.  You can add your own video via the File menu.  Yes, that’s right.  You can play an video and apply a shader while it is running.

image

Figure 5: UI sample tab.

 

image

Figure 6: Sample video tab.

 

image

Figure 7: Sample video with WaveWarper effect applied.

I get a lot of email regarding Shazzam.  One constant request from the community is to add multi-input shaders.  I’m happy to announce that you can now use up to three additional input samples in your shader definition.

First Look

I’ll start by looking at a simple example.  I’m using the MultiInput_MergeImages.fx sample included in Shazzam 1.2.

First, a little review. All shaders in Shazzam have a least one input sample.  This is typically written like this.

// this is the main input texture for the shader
sampler2D input : register(s0);

To add another input to your shader (in HLSL) you have to create a variable and load it into one of the four GPU ‘S’ registers. Since there are only four registers, that is the limit for the number of samples you can use in your shader.

In the following code snippet I am loading the second sample into register s1.

// this is the main input texture for the shader
sampler2D input : register(s0);

// this is an additional texture
// note that textures use the S registers
sampler2D Texture1 : register(s1);

Here are the two inputs that I will use for this example.

image

Figure 1 – Primary sample.

image

Figure 2 – 2nd sample.

Once we have second sample we can do any of the normal HLSL tricks. On top of the usual tricks you can also combine the pixels, from both samples, in interesting ways. This first example will merge the two images.

float Ratio : register(C0);
float4 main(float2 uv : TEXCOORD) : COLOR
{ 

 float4 inputTex = tex2D(input, uv);
 float4 otherTex = tex2D(Texture1, uv); 
 return ((inputTex * Ratio) + (otherTex * (1 - Ratio))); // mix the two images
}

Here are the results.

image

Figure 3 – Merged images.

Changes in UI

Now that Shazzam supports multiple inputs the testing interface had to be changed to accommodate selecting other images. When Shazzam detects additional sample input, like this sample HLSL,

sampler2D Texture3 :register(s2);

it automatically adds the ‘OpenImage control’ to the ‘Change shader settings ‘ tab.

image

Figure 4 – the new change Image controls

Getting fancier

I’ve recorded a video to show the new interface.  This video uses a ripple effect to morph between the two sources.

The Catalyst

I had help with this feature from Nikola Mihaylov, better known as Nokola at nokola.com.  His site is a terrific Silverlight resource.  I suggest you take a look at his work over there.

image

Figure 5 – Nokola Shock Game

Nikola and I started corresponding a few months ago while he was working on his new Silverlight application (EasyPainter).  He had a number of questions about Shazzam and many helpful suggestions regarding improvements in the Shazzam  interface. As a result, Nikola contributed some code to the project that enables multi-input shaders. I am grateful for his contribution, he is the catalyst that caused multi-input to be added to Shazzam.

As a side note, be sure and check out his easy painter application. It’s an excellent representation of what can be done in Silverlight 3.

http://nokola.com/EasyPainter/

image

Figure 6 – Easy Painter

Future additions

I’ve added a few sample multi-input  shaders to Shazzam.  I have more samples available from Microsoft.   Those will be added to a future release as soon as they are Shazzam-alized*.

 

* Shazzam-alized:  Cleaned up, commented and provided with useful default values.

Contribute your shaders

Do you have ultra hip shader you are proud to show off? There are many shaders in Shazzam that were contributed by the community. Now that you can create multi-input shaders I’d like to see what you come up with.

Submit your HLSL and see if it ends up in the next release of Shazzam.

I’ve added more shaders to the sample folder bringing the total count to nearly forty Here is a quick overview.

ParametricEdgeDetection

We’ve got more contributions from the community.  Rene Schulte (http://kodierer.blogspot.com) sent over a few of his latest creations.
image

Figure 1 – Original Image.

image

Figure 2 – ParametricEdgeDetection

Rene has posted a nice post regarding his ParametricEdgeDetection shader.

For Silverlight 3 I’ve implemented an edge detection post processing effect. It’s a parametric pixel shader, which performs a common image processing technique called convolution.

TransparentAlternatingPixels

This is another shader contributed by Rene. Read his blog post for information.

image

Figure 3- TransparentAlternatingPixels

OldMovie

This is the last contribution from Rene.  This shader makes it easy to simulate an old film, complete with scratches, noise and flickering projector light.  Once again Rene has a post explaining more.

image

Figure 4 – OldMovie shader applied to wmv file

Tiler

The Tiler effect duplicates your sample across rows and columns.  You get a result similar to the TileBrush in WPF.

From A.Boschin

image

Figure 5 – Tiler brush with 3 row and 3 columns

Splinter

This is one of my sample effects.  The idea for it came to me earler this week while testing the latest version of Shazzam.  

image

Multi Input Shaders

We’ve finally added multi-input support to Shazaam. Multi-input support has been in the top 5 feature requests for a long time and it finally is here. Look for another post soon about this popular item.   Props to nokola for providing the code that got this feature launched.

Oh, and if you have a pixel shader you want to share with the community just drop me a line and I’ll get it added to the project.

Learn more about the features available in Shazzam 1.2.

There are a handful of new WPF pixel shaders available in our Shazzam Pixel Shader Editor.

WaveWarper

WaveWarper applies a wavy pattern to the input.  This shader was contributed by Timmy Kokke (http://blog.timmykokke.com)

image

Figure 1 – Original Image.

image

Figure 2 – WaveWarper.

image

Figure 3 – Wavewarper with finer grain waves.

SketchGranite and SketchPencilStroke

These two Sketch shader apply a artistic effect, much like pencil drawings, to the input.

This shader was contributed by Ali Daneshmandi  (http://daneshmandi.spaces.live.com/)

image

Figure 4 – SketchGranite

image

Figure 5 – SketchPencilStroke

Bands

This shader divides the input into vertical bands.

This shader was contributed by Walt Ritsher (http://blog.wpfwonderland.com)

image

Figure 6 – Bands

I’ve uploaded the newest version of Shazzam to the Shazzam-Tool.com servers. The version number for this release is a minor change (1.2.0.21).  but are many interesting updates in the product.  Look for more blog posts on this site for details regarding the new features.

If you have Shazzam installed on your computer it will attempt an update the next time you run the application.  If you don’t have the Shazzam installed you can install it from this location.

http://shazzam-tool.com/publish.htm

Silverlight and WPF are different beasts.  The similarities between the two is high, but there are enough differences to foul you up now and then.

Choose your platform preference

There is a new addition to the Settings pane.  The code generation engine will consider your desired platform when generating the .NET classes.

image

Figure 1:  Target Framework setting.

As you can see from the following code examples Shazzam creates slightly different versions of the DependencyProperty registration code depending on your framework choice.  Shazzam also ignores Point3D, Vector3D, or Point4D property types when creating Silverlight classes as Silverlight 3 doesn’t support these types yet.

 

// Use UIPropertyMetaData for WPF

 public static readonly DependencyProperty AspectRatioProperty 
      = DependencyProperty.Register("AspectRatio", typeof(double), 
       typeof(BandedSwirlEffect), new UIPropertyMetadata(((double)(1.5)), 
       PixelShaderConstantCallback(3)));

// Use PropertyMetaData for Silverlight
public static readonly DependencyProperty AspectRatioProperty 
   = DependencyProperty.Register("AspectRatio", typeof(double), 
   typeof(BandedSwirlEffect), new PropertyMetadata(((double)(1.5)),
   PixelShaderConstantCallback(3)));

Constructor

Shazzam now generates a parameterless constructor that automatically loads the compiled pixel shader from an assembly resource.  If the name of your assembly is different from the name of your namespace, you’ll need to hand-edit the URI in the constructor."

The resource URI can be relative, taking the form "/AssemblyName;component/ShaderName.ps" – this new syntax works in both WPF and Silverlight.

Summary

[Shazzam 1.1 was released on October 11, 2009]

See a list of additional help pages here.

Install your own copy of the free Shazzam Pixel Shader Utility here.

Learn more about the features available in Shazzam 1.1.

 

Install your own copy of the free Shazzam Pixel Shader Utility here.

Some video tutorials are available also.

Creating shaders is fun.  But it’s more thrilling to see what your new shader can do.   Shazzam has a testing screen for just that purpose, giving you a place to experiment with your effect, just choose the ‘Change Shader Settings’ tab.

image

Figure1 : Change Shader Settings tab.

The Edit Shader Property control

What happens when you compile your HLSL code? Each input parameter in your HLSL code is converted to a DependencyProperty in the generated C#/VB code.

/// The HLSL
/// <summary>The aspect ratio (width / height) of the input.</summary>
/// <minValue>0.5</minValue>
/// <maxValue>2</maxValue>
/// <defaultValue>1.5</defaultValue>
float AspectRatio : register(C3);
/// The C# Dependency Property
public static readonly DependencyProperty AspectRatioProperty 
   = DependencyProperty.Register("AspectRatio", typeof(double), 
   typeof(BandedSwirlEffect), new UIPropertyMetadata(((double)(1.5)), 
   PixelShaderConstantCallback(3)));
    

In turn, each DependencyProperty in your generated class is assigned an editor on the test page.  See Figure 2 for an example.

image

Figure 2:  AspectRatio editor.

The Min and Max textboxes on the editor set the range for the value slider.  Move the slider to set the current value for the property (AspectRatio in this example).

Animating the Property

Manually changing the slider value is useful to see what happens to the image when a particular test value is applied.  When you find a interesting version of your effect you can jot down the detail  and use it in your Silverlight/WPF application.  But sometimes you just want to play with the settings and see what happens.  That’s why there is an animation section on the edit control.  There are several buttons (exact number depends on the property type) available for controlling the animation.

image

Figure 3: Animation controls.

When the animation is running the value slider is replaced with a status textbox.  This way you can see the current values as the animation runs and not be distracted by the slider racing dizzily back and forth on the screen.

image

Figure 4:  Current animation value as text.

Multi-value Animations

Some properties like Point and 3DPoint have multiple values in each property. The editor provides more controls for editing and adds another animation button (Circular animation).

image

Figure 5: Multiple editors and circular animation button.

Set Default Animation Duration

The Settings pane has a number of improvements in versions 1.1.  The one you are interested in for today is the Default Animation Duration setting. This specifies the default duration for all animations.  Your default is loaded in to the test page the next time you compile the shader. You can always modify the animation duration on the test screen, the default value is only used as the initial setting.

image

Figure 6:  Setting pane – Default Animation Length.

Summary

[Shazzam 1.1 was released on October 11, 2009]

See a list of additional help pages here.

Install your own copy of the free Shazzam Pixel Shader Utility here.

« Newer Posts - Older Posts »