Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / effects / inc / FUiEffects_RendererEffectShader.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 /**
18  * @file        FUiEffects_RendererEffectShader.h
19  * @brief               This is the header file for the effects library shaders
20  */
21
22 #ifndef _FUI_EFFECTS_INTERNAL_RENDERER_EFFECTSHADER_H_
23 #define _FUI_EFFECTS_INTERNAL_RENDERER_EFFECTSHADER_H_
24
25 #include <string>
26
27 namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer
28 {
29
30 #ifdef _DEBUG
31 #define PRINT_DEBUG(name, str)  printstring(name, str)
32 #else
33 #define PRINT_DEBUG(name, str)
34 #endif
35
36 /**
37  * Replaces all occurrences of string "what" in "str" with new string "with"
38  *
39  * @return              void
40  */
41 void replace(std::string &str, const std::string what, const std::string with);
42
43 /**
44  * Prints string "str" to log output line by line. Each line is prefixed with "name" @n
45  * Works only in debug mode
46  *
47  * @return              void
48  */
49 void printstring(const std::string name, const std::string &str);
50
51 #define SHADER_IN_POSITION_STR                          "in_Position"
52 #define SHADER_IN_NORMAL_STR                            "in_Normal"
53 #define SHADER_IN_TEXCOORDS_STR                         "in_TexCoords"
54 #define MAIN_TEX_STR                                            "TEX_MAIN"
55
56 #define LIGHTING_AMBIENTCOLORI_STR                      "lightingParameters.ambientColorI"
57 #define LIGHTING_ATTENUATION_STR                        "lightingParameters.attenuation"
58
59 #define POINTLIGHT_DEFPOS_STR                           "/*POINTL DEF*/ \n"
60 #define POINTLIGHT_SRCPOS_STR                           "/*POINTL SRC*/ \n"
61 #define POINTLIGHT_DEF_STR                                      "uniform PointLight pointLight%n;\n"
62 #define POINTLIGHT_ATTSRC_STR                           "       lightdir = pointLight%n.position - Position; \n" \
63                                                                                         "       att = 1.0 - length(lightdir) * pointLight%n.Rk; \n" \
64                                                                                         "       if(att > 0.0) \n" \
65                                                                                         "               color += pointLight%n.colorI * max(0.0, dot(normalize(lightdir), normal)) * att; \n" \
66                                                                                         " \n"
67 #define POINTLIGHT_NOATTSRC_STR                         "       color += pointLight%n.colorI * max(0.0, dot(normalize(pointLight%n.position - Position), normal)); \n" \
68                                                                                         " \n"
69 #define POINTLIGHT_STR                                          "pointLight"
70 #define POINTLIGHT_POSITION_STR                         ".position"
71 #define POINTLIGHT_COLORI_STR                           ".colorI"
72 #define POINTLIGHT_RK_STR                                       ".Rk"
73
74
75 #define SPOTLIGHT_DEFPOS_STR                            "/*SPOTL DEF*/ \n"
76 #define SPOTLIGHT_SRCPOS_STR                            "/*SPOTL SRC*/ \n"
77 #define SPOTLIGHT_DEF_STR                                       "uniform SpotLight spotLight%n;\n"
78 #define SPOTLIGHT_ATTSRC_STR                            "       lightdir = normalize(Position - spotLight%n.position); \n" \
79                                                                                         "       att = min((dot(spotLight%n.direction, lightdir) - spotLight%n.k1) * spotLight%n.k2, 1.0) * (1.0 - length(Position - spotLight%n.position) * spotLight%n.Rk); \n" \
80                                                                                         "       if(att > 0.0) \n" \
81                                                                                         "               color += spotLight%n.colorI * att * max(0.0, dot(-lightdir, normal)); \n" \
82                                                                                         " \n"
83 #define SPOTLIGHT_NOATTSRC_STR                          "       lightdir = normalize(Position - spotLight%n.position); \n" \
84                                                                                         "       att = min((dot(spotLight%n.direction, lightdir) - spotLight%n.k1) * spotLight%n.k2, 1.0); \n" \
85                                                                                         "       if(att > 0.0) \n" \
86                                                                                         "               color += spotLight%n.colorI * att * max(0.0, dot(-lightdir, normal)); \n" \
87                                                                                         " \n"
88 #define SPOTLIGHT_STR                                           "spotLight"
89 #define SPOTLIGHT_POSITION_STR                          ".position"
90 #define SPOTLIGHT_DIRECTION_STR                         ".direction"
91 #define SPOTLIGHT_K1_STR                                        ".k1"
92 #define SPOTLIGHT_K2_STR                                        ".k2"
93 #define SPOTLIGHT_COLORI_STR                            ".colorI"
94 #define SPOTLIGHT_RK_STR                                        ".Rk"
95
96
97 #define DIRECTIOALLIGHT_DEFPOS_STR                      "/*DIRL DEF*/ \n"
98 #define DIRECTIOALLIGHT_SRCPOS_STR                      "/*DIRL SRC*/ \n"
99 #define DIRECTIOALLIGHT_DEF_STR                         "uniform DirectionalLight directionalLight%n;\n"
100 #define DIRECTIOALLIGHT_SRC_STR                         "       color += directionalLight%n.colorI * max(0.0, dot(-directionalLight%n.direction, normal)); \n" \
101                                                                                         " \n"
102 #define DIRECTIOALLIGHT_STR                                     "directionalLight"
103 #define DIRECTIOALLIGHT_DIRECTION_STR           ".direction"
104 #define DIRECTIOALLIGHTLIGHT_COLORI_STR         ".colorI"
105
106 #define MODEL_MTR_STR                                           "ModelMtr"
107 #define NORMAL_MTR_STR                                          "NormalMtr"
108 #define OPACITY_STR                                                     "opacity"
109
110 #define BLUR_WEIGHTS_N                                          20
111
112 extern const char* const EFFECT_VERTEX_SHADER_STR;
113 extern const char* const EFFECT_FRAGMENT_SHADER_STR;
114 extern const char* const EFFECT_DUMMY_FRAGMENT_SHADER_STR;
115
116 extern const char* const BLUR_VS;
117 extern const char* const BLUR_HORIZ_FS;
118 extern const char* const BLUR_VERT_FS;
119
120
121
122 } } } } // Tizen::Ui::Effects::_EffectRenderer
123
124 #endif //_FUI_EFFECTS_INTERNAL_RENDERER_EFFECTSHADER_H_