1 #ifndef __DALI_TOOLKIT_SHADER_EFFECT_MOTION_STRETCH_H__
2 #define __DALI_TOOLKIT_SHADER_EFFECT_MOTION_STRETCH_H__
5 * Copyright (c) 2015 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/public-api/actors/renderable-actor.h>
23 #include <dali/public-api/shader-effects/shader-effect.h>
33 * Class for motion stretch shader that works on a per object basis. Objects will stretch in the direction of motion when they move, or if the camera moves. Can be applied
34 * to ImageActor or TextActor only.
38 * // Create shader used for doing motion stretch\n
39 * MotionStretchEffect MotionStretchEffect = MotionStretchEffect::New();
41 * // set actor shader to the stretch one\n
42 * Actor Actor = Actor::New( ... );\n
43 * Actor.SetShaderEffect( MotionStretchEffect );
46 class DALI_IMPORT_API MotionStretchEffect : public ShaderEffect
52 * Create an uninitialized MotionStretchEffect; this can be initialized with MotionStretchEffect::New()
53 * Calling member functions with an uninitialized Dali::Object is not allowed.
55 MotionStretchEffect();
60 * This is non-virtual since derived Handle types must not contain data or virtual methods.
62 ~MotionStretchEffect();
65 * Create an initialized MotionStretchEffect
66 * @return A handle to a newly allocated Dali resource.
68 static MotionStretchEffect New();
71 * Create a MotionStretchEffect and attach it to the specified actor
72 * @param renderable actor to apply the effect to
73 * @return A handle to a newly allocated Dali resource.
75 static MotionStretchEffect Apply( RenderableActor renderable );
78 * Set geometry stretch factor property. This scales the amount the geometry
79 * stretches along the motion velocity vector. A smaller value means the geometry
80 * stretches less, larger it stretches more. Default 0.5.
81 * @param scalingFactor The scaling factor that extrudes the geometry forwards along the motion velocity vector.
83 void SetGeometryStretchFactor( float scalingFactor );
86 * Set speed scaling factor property. This value is used to control how much
87 * to fade the actor near the edges, based on the speed the actor is moving.
88 * When the actor is at rest this is not applied. Default 0.5.
89 * @param scalingFactor The scaling factor that controls the edge fade of the actor.
91 void SetSpeedScalingFactor( float scalingFactor );
94 * Set the displacement from the centre of the actor that the actor will start to
95 * fade towards its edges. This is used to prevent an unsightly hard edge
96 * between the stretched actor and the scene. Depends on the values of the
97 * vertices in the vertex stream. When the actor is at rest this is not applied.
98 * Default Vector2(0.25, 0.25), which is half way towards the edge for an ImageRenderer::QUAD.
99 * @param displacement The displacement from the centre of the actor that the actor will start to edge fade.
101 void SetObjectFadeStart( Vector2 displacement );
104 * Set the displacement from the centre of the actor that the actor will
105 * finish fading towards its edges. This is used to prevent an unsightly hard
106 * edge between the stretched actor and the scene. Depends on the values of
107 * the vertices in the vertex stream. When the actor is at rest this is not applied.
108 * Default 0.5, which is all the way towards the edge for an ImageRenderer::QUAD.
109 * @param displacement The displacement from the centre of the actor that the actor will finish edge fading.
111 void SetObjectFadeEnd( Vector2 displacement );
114 * Set a global scaler applied to the alpha of the actor. Used to make the
115 * stretched actor a bit more subtle and reveal a bit of the background behind
116 * it as it moves. When the actor is at rest this is not applied. Default 0.75.
117 * @param alphaScale The scaling factor which multiplies the alpha of each pixel of the actor.
119 void SetAlphaScale( float alphaScale );
123 * Get the name for the texcoord scale property. Useful for animation.
124 * @return A std::string containing the property name
126 const std::string& GetTexcoordScalePropertyName() const;
129 * Get the name for the geometry stretching property. Useful for animation.
130 * @return A std::string containing the property name
132 const std::string& GetGeometryStretchFactorPropertyName() const;
135 * Get the name for the speed scaling property. Useful for animation.
136 * @return A std::string containing the property name
138 const std::string& GetSpeedScalingFactorPropertyName() const;
141 * Get the name for the fade start X property. Useful for animation.
142 * @return A std::string containing the property name
144 const std::string& GetObjectFadeStartPropertyName() const;
147 * Get the name for the fade end X property. Useful for animation.
148 * @return A std::string containing the property name
150 const std::string& GetObjectFadeEndPropertyName() const;
153 * Get the name for the alpha scale property. Useful for animation.
154 * @return A std::string containing the property name
156 const std::string& GetAlphaScalePropertyName() const;
159 // Not intended for application developers
160 DALI_INTERNAL MotionStretchEffect( ShaderEffect handle );
167 #endif //#ifndef __DALI_TOOLKIT_SHADER_EFFECT_MOTION_STRETCH_H__