1 /*! \page shader-intro Shader Effects
4 <h2 class="pg">Introduction</h2>
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.
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.
14 @image html shader-effect-ripple.png "Ripple Effect"
18 <h2 class="pg">Example and Usage</h2>
19 Here is an example on how to use a shader effect, using the RippleEffect.
21 First create the shader effect.
23 Dali::RippleEffect effect = Dali::RippleEffect::New();
26 Then set the values of the uniforms.
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 ) );
36 Finally apply the shader effect to an actor:
38 actor.SetShaderEffect( effect );
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.
47 A custom shader effect can be created like this:
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
55 The value of a uniform can be set like this:
57 // if the uniform was declared like this in the shader: uniform float myUniform;
58 myEffect.SetUniform( "myUniform", 0.5f );
61 The custom shader effect can be applied to an actor like any other shader:
63 actor.SetShaderEffect( myEffect );