views:

132

answers:

2

I have built a Flex application that composes image resources, color layers, blurs etc to generate images (99% of the drink images in www.absolutdrinks.com are generated by this app). One of the effects used by the app is Flash's ability to apply displacement map filter in which x- and y- offset for an image is defined by a 2D image (sy x offset in the red channel and y offset in the blue channel). This is used to get the bulge of garnishes placed in the liquid of the drink.

I am now looking for a way to do this image generation server side (and possibly in a Silverlight app). I can see ways to reproduce all features of the Image generation app except for the displacement map filter. Is there any way to do this via the controls in the Windows.Media namespace? If not: are there any other ways?

+2  A: 

You can use a Pixel Shader with normal maps to accomplish this.

Bump mapping in Silverlight 3

Timothy Lee Russell
+2  A: 

Hi Johan,

Unfortunately there is no DisplacementMap filters neither in Silverlight nor in WPF. There are two ways you could follow.

  1. Create custom pixel shader effect, and implement displacement algorithm in it. Pixel shaders are supported both by Silverligth 3.0+ and WPF.

  2. Use WriteableBitmap to get access to the pixels and again, implement the algorithm.

Anvaka