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 utility functions in Dali::Toolkit to create some useful shader effects:
11 //Bendy effect bends the geometry around a point, useful to do a page turn effect
12 Dali::ShaderEffect bendyEffect = Dali::Toolkit::CreateBendyEffect();
14 //Dissolve effect does a dissolve effect on the actor texture
15 Dali::ShaderEffect dissolveEffect = Dali::Toolkit::CreateDissolveEffect();
17 //Ripple effect does a concentric wave effect on the actor texture
18 Dali::ShaderEffect rippleEffect = Dali::Toolkit::CreateRippleEffect();
22 @image html shader-effect-ripple.png "Ripple Effect"
26 <h2 class="pg">Example and Usage</h2>
27 Here is an example on how to use a shader effect, using the RippleEffect.
29 First create the shader effect.
31 Dali::ShaderEffect effect = Dali::Toolkit::CreateRippleEffect();
34 Then set the values of the uniforms.
37 effect.SetUniform("uAmplitude", 45.0f );
39 effect.SetUniform("uCenter", Vector2() );
42 Finally apply the shader effect to an actor:
44 actor.SetShaderEffect( effect );
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.
53 A custom shader effect can be created like this:
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
61 The value of a uniform can be set like this:
63 // if the uniform was declared like this in the shader: uniform float myUniform;
64 myEffect.SetUniform( "myUniform", 0.5f );
67 The custom shader effect can be applied to an actor like any other shader:
69 actor.SetShaderEffect( myEffect );