1 #ifndef __DALI_TOOLKIT_SHEAR_EFFECT_H__
2 #define __DALI_TOOLKIT_SHEAR_EFFECT_H__
5 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/devel-api/shader-effects/shader-effect.h>
31 * @brief Creates a new ShearEffect
33 * ShearEffect is a custom shader effect to achieve shear effects in Image actors
35 * Animatable/Constrainable uniforms:
36 * "uCenter" - The center point of the shear effect in screen coordinates
37 * "uAngleXAxis" - The angle of the shear effect in the X axis
38 * "uAngleYAxis" - The angle of the shear effect in the Y axis
40 * @return A handle to a newly allocated ShaderEffect
42 inline ShaderEffect CreateShearEffect()
44 // append the default version
45 std::string vertexShader(
46 "uniform mediump vec2 uCenter;\n"
47 "uniform mediump float uAngleXAxis;\n"
48 "uniform mediump float uAngleYAxis;\n"
52 "mediump vec4 world = uModelView * vec4(aPosition, 1.0);\n"
54 "world.x = world.x + tan(radians(uAngleXAxis)) * (world.y - uCenter.y * world.w);\n"
55 "world.y = world.y + tan(radians(uAngleYAxis)) * (world.x - uCenter.x * world.w);\n"
57 "gl_Position = uProjection * world;\n"
59 "vTexCoord = mix( sTextureRect.xy, sTextureRect.zw, aTexCoord );\n"
62 // Create the implementation, temporarily owned on stack,
63 ShaderEffect shaderEffect = Dali::ShaderEffect::New(
66 ShaderEffect::GeometryHints( ShaderEffect::HINT_GRID ));
69 shaderEffect.SetUniform( "uCenter", Vector2(0.0f, 0.0f), ShaderEffect::COORDINATE_TYPE_VIEWPORT_POSITION );
70 shaderEffect.SetUniform( "uAngleXAxis", 0.0f);
71 shaderEffect.SetUniform( "uAngleYAxis", 0.0f);
76 } // namespace Toolkit
80 #endif // __DALI_TOOLKIT_SHEAR_EFFECT_H__