(Docs) Adding Programming Guide to Toolkit
[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 built-in shader effects in Dali Toolkit:
10 - \ref Dali::Toolkit::BendyEffect "Bendy", bends the geometry around a point, useful to do a page turn effect,
11 - \ref Dali::Toolkit::DissolveEffect "Dissolve", does a dissolve effect on the actor texture,
12 - \ref Dali::Toolkit::RippleEffect "Ripple", does a concentric wave effect on the actor texture.
13
14 @image html shader-effect-ripple.png "Ripple Effect"
15
16 <br>
17 <br>
18 <h2 class="pg">Example and Usage</h2>
19 Here is an example on how to use a shader effect, using the RippleEffect.
20
21 First create the shader effect.
22 @code
23 Dali::RippleEffect effect = Dali::RippleEffect::New();
24 @endcode
25
26 Then set the values of the uniforms.
27 @code
28 // Set the radius of the bending
29 effect.SetAmplitude( 45.0f );
30 // Set the point around which the geometry will bend
31 effect.SetCenter( Vector2() );
32 // Set the direction of the bending
33 effect.SetDirection( Vector2( 1.0f, 0.0f ) );
34 @endcode
35
36 Finally apply the shader effect to an actor:
37 @code
38 actor.SetShaderEffect( effect );
39 @endcode
40
41
42 <br>
43 <br>
44 <h2 class="pg">Custom Shader Effects</h2>
45 The \ref Dali::ShaderEffect "ShaderEffect" lets the developers create their own shader effects by specifying the vertex and pixel shaders.
46
47 A custom shader effect can be created like this:
48 @code
49 String myVertexShader; // This variable would contain the code for a vertex shader.
50 Dali::ShaderEffect myEffect = Dali::ShaderEffect::New( myVertexShader,
51                                                        "" // use default pixel shader
52                                                      );
53 @endcode
54
55 The value of a uniform can be set like this:
56 @code
57 // if the uniform was declared like this in the shader: uniform float myUniform;
58 myEffect.SetUniform( "myUniform", 0.5f );
59 @endcode
60
61 The custom shader effect can be applied to an actor like any other shader:
62 @code
63 actor.SetShaderEffect( myEffect );
64 @endcode
65
66  *
67  */