Changed Toolkit shader effects to be a static function returning a
[platform/core/uifw/dali-toolkit.git] / docs / content / programming-guide / shader-intro.h
1 /*! \page shader-intro Shader Effects
2  *
3
4 <h2 class="pg">Introduction</h2>
5
6 The shader effects allow the developer to apply visual deformations on the actors.
7 They can affect the geometry, the colors and textures of the actor.
8
9 There are some utility functions in Dali::Toolkit to create some useful shader effects:
10 @code
11 //Bendy effect bends the geometry around a point, useful to do a page turn effect
12 Dali::ShaderEffect bendyEffect = Dali::Toolkit::CreateBendyEffect();
13
14 //Dissolve effect does a dissolve effect on the actor texture
15 Dali::ShaderEffect dissolveEffect = Dali::Toolkit::CreateDissolveEffect();
16
17 //Ripple effect does a concentric wave effect on the actor texture
18 Dali::ShaderEffect rippleEffect = Dali::Toolkit::CreateRippleEffect();
19
20 @endcode
21
22 @image html shader-effect-ripple.png "Ripple Effect"
23
24 <br>
25 <br>
26 <h2 class="pg">Example and Usage</h2>
27 Here is an example on how to use a shader effect, using the RippleEffect.
28
29 First create the shader effect.
30 @code
31 Dali::ShaderEffect effect = Dali::Toolkit::CreateRippleEffect();
32 @endcode
33
34 Then set the values of the uniforms.
35 @code
36 // Set the amplitude
37 effect.SetUniform("uAmplitude", 45.0f );
38 // Set the center
39 effect.SetUniform("uCenter", Vector2() );
40 @endcode
41
42 Finally apply the shader effect to an actor:
43 @code
44 actor.SetShaderEffect( effect );
45 @endcode
46
47
48 <br>
49 <br>
50 <h2 class="pg">Custom Shader Effects</h2>
51 The \ref Dali::ShaderEffect "ShaderEffect" lets the developers create their own shader effects by specifying the vertex and pixel shaders.
52
53 A custom shader effect can be created like this:
54 @code
55 String myVertexShader; // This variable would contain the code for a vertex shader.
56 Dali::ShaderEffect myEffect = Dali::ShaderEffect::New( myVertexShader,
57                                                        "" // use default pixel shader
58                                                      );
59 @endcode
60
61 The value of a uniform can be set like this:
62 @code
63 // if the uniform was declared like this in the shader: uniform float myUniform;
64 myEffect.SetUniform( "myUniform", 0.5f );
65 @endcode
66
67 The custom shader effect can be applied to an actor like any other shader:
68 @code
69 actor.SetShaderEffect( myEffect );
70 @endcode
71
72  *
73  */