2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <dali-toolkit/devel-api/shader-effects/motion-stretch-effect.h>
21 #include <dali/public-api/actors/actor.h>
22 #include <dali/public-api/animation/constraints.h>
23 #include <dali/public-api/object/property-map.h>
24 #include <dali/public-api/rendering/shader.h>
27 #include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
28 #include <dali-toolkit/public-api/visuals/visual-properties.h>
34 void SetMotionStretchProperties(Actor& actor)
36 actor.RegisterProperty("uGeometryStretchFactor", 0.5f);
37 actor.RegisterProperty("uSpeedScalingFactor", 0.5f);
38 actor.RegisterProperty("uObjectFadeStart", Vector2(0.25f, 0.25f));
39 actor.RegisterProperty("uObjectFadeEnd", Vector2(0.5f, 0.5f));
40 actor.RegisterProperty("uAlphaScale", 0.75f);
41 Property::Index uModelProperty = actor.RegisterProperty("uModelLastFrame", Matrix::IDENTITY);
43 Constraint constraint = Constraint::New<Matrix>(actor, uModelProperty, EqualToConstraint());
44 constraint.AddSource(Source(actor, Actor::Property::WORLD_MATRIX));
48 Property::Map CreateMotionStretchEffect()
52 Property::Map customShader;
53 customShader[Visual::Shader::Property::VERTEX_SHADER] = SHADER_MOTION_STRETCH_EFFECT_VERT.data();
54 customShader[Visual::Shader::Property::FRAGMENT_SHADER] = SHADER_MOTION_STRETCH_EFFECT_FRAG.data();
56 customShader[Visual::Shader::Property::SUBDIVIDE_GRID_X] = 10;
57 customShader[Visual::Shader::Property::SUBDIVIDE_GRID_Y] = 10;
59 customShader[Visual::Shader::Property::HINTS] = Shader::Hint::OUTPUT_IS_TRANSPARENT;
61 map[Toolkit::Visual::Property::SHADER] = customShader;
65 } // namespace Toolkit