Merge "Fix resource ready state" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / shader-effects / motion-blur-effect.h
1 #ifndef DALI_TOOLKIT_SHADER_EFFECT_MOTION_BLUR_H
2 #define DALI_TOOLKIT_SHADER_EFFECT_MOTION_BLUR_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/actors/actor.h>
23 #include <dali/public-api/object/property-map.h>
24
25 // INTERNAL INCLUDES
26 #include <dali-toolkit/public-api/dali-toolkit-common.h>
27
28 namespace Dali
29 {
30 namespace Toolkit
31 {
32 /**
33  * @brief Set the properties for the motion blur
34  *
35  * @param[in] actor The actor that registers the uniform properties
36  * @param[in] numBlurSamples Number of samples used by the shader
37  */
38 DALI_TOOLKIT_API void SetMotionBlurProperties( Actor& actor, unsigned int numBlurSamples = 8 );
39
40 /**
41  * @brief Create a new MotionBlurEffect
42  *
43  * Motion blur shader works on a per object basis. Objects will
44  * blur when they move, or if the camera moves.
45  *
46  * Animatable/Constrainable uniforms:
47  *  "uBlurTexCoordScale"      - This scales the offset for texture samples along the motion velocity vector.
48  *                              A smaller value means the samples will be spaced closer, larger value further
49  *                              apart. User should use this to get the blur to look contiguous, i.e. the blur
50  *                              texels should not be too widely spread, with gaps in between. Default 0.125.
51  *  "uGeometryStretchFactor"  - This scales the amount the geometry stretches backwards along the motion velocity
52  *                              vector. A smaller value means the geometry stretches less, larger it stretches more.
53  *                              User should use this to get the blur to 'bleed' into areas outside the physical
54  *                              bounds of the actor. We need this as the blur is only applied inside the bounds of
55  *                              the actor, but you would expect motion blur trails where the actor was previously
56  *                              but is there no longer. Default 0.05.
57  *  "uSpeedScalingFactor"     - This takes the magnitude of the motion velocity vector and scales it to produce a
58  *                              value which is used to fade the blur in / out with the speed that the actor is moving.
59  *                              As the blur fades in, more of the blur is visible and less of the original actor, and
60  *                              viceversa. This value is also used to control how much to fade the actor near the
61  *                              edges, based on the speed the actor is moving. When the actor is at rest this is not applied.
62  *                              Default 0.5.
63  *  "uObjectFadeStart"        - The displacement from the centre of the actor that the actor will start to fade towards its
64  *                              edges. This is used to prevent an unsightly hard edge between the blurred actor and the scene.
65  *                              Depends on the values of the vertices in the vertex stream. When the actor is at rest this is
66  *                              not applied. Default 0.25, which is half way towards the edge for an ImageVisual::QUAD.
67  *  "uObjectFadeEnd"          - The displacement from the centre of the actor that the actor will finish fading towards its
68  *                              edges. This is used to prevent an unsightly hard edge between the blurred actor and the scene.
69  *                              Depends on the values of the vertices in the vertex stream. When the actor is at rest this is
70  *                              not applied.Default 0.5, which is all the way towards the edge for an ImageVisual::QUAD.
71  *  "uAlphaScale"             - Global scaler applied to the alpha of the actor. Used to make the blurred actor a bit more subtle
72  *                              (helps to hide discontinuities due to limited number of texture samples) and reveal a bit of the
73  *                              background behind it as it moves. When the actor is at rest this is not applied. Default 0.75.
74  *  "uNumSamples"             - The number of texture samples to be taken. Increasing the number of samples provides better quality
75  *                              at the cost of performance.
76  *  "uModelLastFrame"         - The model to world space transformation matrix of the actor in the previous frame.
77  *
78  * @return The newly created Property::Map with the motion blur effect
79  */
80 DALI_TOOLKIT_API Property::Map CreateMotionBlurEffect();
81
82 } // namespace Toolkit
83
84 } // namespace Dali
85
86 #endif // DALI_TOOLKIT_SHADER_EFFECT_MOTION_BLUR_H