Question

we have a project at university where we have to create fractals that are controllable by the user (with kinect). We are still in an early phase where we evaluate some ideas (though we already got some working prototypes). Our idea right now is to use a blackboard-image as background and draw the fractals on top of it. To make this look more natural we'd like to use some crayon effects on the lines we draw.

Our internet-research produced two main ideas to achieve this:

  1. Paint an image of a photoshop-like brush for every moueposition of a line.
  2. Use shaders on drawline-functions.

The first does work for an early test, but looks awful. I guess the latter would be the best approach, but the information in the internet seems to be lacking regarding this topic. At least I didn't find anything that really helped a lot. The Questions is: Has anyone links or general tips on how to achieve this effect, or is it not possible in C#/WPF. Might there be an even better way? And how can I apply a created shader to drawline-method/brushes?

Thanks in advance and kind regards

Michael

Was it helpful?

Solution

EDIT

Nice tip from @Bradley Uffner ! (unfortunately he deleted his answer)

There is a tutorial here on how to achieve such effect :

http://alastaira.wordpress.com/2013/11/01/hand-drawn-shaders-and-creating-tonal-art-maps/

Another thing I've found recently which might interests you :

http://blogs.msdn.com/b/hemipteran/archive/2014/03/26/generating-noise-for-applications.aspx

I've didn't read well the title of your question, Windows Forms do not support shaders at all.

Be more specific about the meaning of a crayon shader

Regarding using shaders in WPF, you cannot apply them at a line-level but on a Control level instead.

This the class representing a shader in WPF:

http://msdn.microsoft.com/en-us/library/system.windows.media.effects.effect(v=vs.110).aspx

What I suggest

  • use an Image and set its Source property to use a WriteableBitmap
  • use the excellent WriteableBitmapEx library to easily draw on it, basically it's the WriteableBitmap in WPF but with many extension methods for drawing lines, circles, rectangles etc ...
  • then apply your shader to the Effect property of Image

For developing your shader

Use Shazzam, it allows you to develop an HLSL shader for WPF in a cool interface, preview it instantly and it will generate the Effect class ready to paste on your project.

enter image description here

There might be a couple of interesting shader for you in DOSBox SVN-Daum

Here's an example of the cartoon shader :

enter image description here

enter image description here

Obviously there will be quite some work as copy-pasting the shader to Shazzam won't work right away but you'll know what are the maths behind achieving the effect.

Mark the answer as accepted if you are satisfied with it :D if not edit your question and add more details.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top