Using migrated Public Visual API
[platform/core/uifw/dali-demo.git] / examples / refraction-effect / refraction-effect-example.cpp
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // EXTERNAL INCLUDES
19 #include <dali/dali.h>
20 #include <dali-toolkit/dali-toolkit.h>
21 #include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
22
23 #include <fstream>
24 #include <sstream>
25 #include <limits>
26
27 // INTERNAL INCLUDES
28 #include "shared/view.h"
29 #include "shared/utility.h"
30
31 using namespace Dali;
32
33 namespace
34 {
35 const char * const APPLICATION_TITLE( "Refraction Effect" );
36 const char * const TOOLBAR_IMAGE( DEMO_IMAGE_DIR "top-bar.png" );
37 const char * const CHANGE_TEXTURE_ICON( DEMO_IMAGE_DIR "icon-change.png" );
38 const char * const CHANGE_TEXTURE_ICON_SELECTED( DEMO_IMAGE_DIR "icon-change-selected.png" );
39 const char * const CHANGE_MESH_ICON( DEMO_IMAGE_DIR "icon-replace.png" );
40 const char * const CHANGE_MESH_ICON_SELECTED( DEMO_IMAGE_DIR "icon-replace-selected.png" );
41
42 const char* MESH_FILES[] =
43 {
44  DEMO_MODEL_DIR "surface_pattern_v01.obj",
45  DEMO_MODEL_DIR "surface_pattern_v02.obj"
46 };
47 const unsigned int NUM_MESH_FILES( sizeof( MESH_FILES ) / sizeof( MESH_FILES[0] ) );
48
49 const char* TEXTURE_IMAGES[]=
50 {
51   DEMO_IMAGE_DIR "background-1.jpg",
52   DEMO_IMAGE_DIR "background-2.jpg",
53   DEMO_IMAGE_DIR "background-3.jpg",
54   DEMO_IMAGE_DIR "background-4.jpg"
55 };
56 const unsigned int NUM_TEXTURE_IMAGES( sizeof( TEXTURE_IMAGES ) / sizeof( TEXTURE_IMAGES[0] ) );
57
58 struct LightOffsetConstraint
59 {
60   LightOffsetConstraint( float radius )
61   : mRadius( radius )
62   {
63   }
64
65   void operator()( Vector2& current, const PropertyInputContainer& inputs )
66   {
67     float spinAngle = inputs[0]->GetFloat();
68     current.x = cos( spinAngle );
69     current.y = sin( spinAngle );
70
71     current *= mRadius;
72   }
73
74   float mRadius;
75 };
76
77 /**
78  * structure of the vertex in the mesh
79  */
80 struct Vertex
81 {
82   Vector3 position;
83   Vector3 normal;
84   Vector2 textureCoord;
85
86   Vertex()
87   {}
88
89   Vertex( const Vector3& position, const Vector3& normal, const Vector2& textureCoord )
90   : position( position ), normal( normal ), textureCoord( textureCoord )
91   {}
92 };
93
94 /************************************************************************************************
95  *** The shader source is used when the MeshActor is not touched***
96  ************************************************************************************************/
97 const char* VERTEX_SHADER_FLAT = DALI_COMPOSE_SHADER(
98 attribute mediump vec3    aPosition;\n
99 attribute mediump vec3    aNormal;\n
100 attribute highp   vec2    aTexCoord;\n
101 uniform   mediump mat4    uMvpMatrix;\n
102 varying   mediump vec2    vTexCoord;\n
103 void main()\n
104 {\n
105   gl_Position = uMvpMatrix * vec4( aPosition.xy, 0.0, 1.0 );\n
106   vTexCoord = aTexCoord.xy;\n
107 }\n
108 );
109
110 const char* FRAGMENT_SHADER_FLAT = DALI_COMPOSE_SHADER(
111 uniform lowp    vec4  uColor;\n
112 uniform sampler2D     sTexture;\n
113 varying mediump vec2  vTexCoord;\n
114 void main()\n
115 {\n
116   gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n
117 }\n
118 );
119
120 /************************************************************
121  ** Custom refraction effect shader***************************
122  ************************************************************/
123 const char* VERTEX_SHADER_REFRACTION = DALI_COMPOSE_SHADER(
124 attribute mediump vec3    aPosition;\n
125 attribute mediump vec3    aNormal;\n
126 attribute highp   vec2    aTexCoord;\n
127 uniform   mediump mat4    uMvpMatrix;\n
128 varying   mediump vec4    vVertex;\n
129 varying   mediump vec3    vNormal;\n
130 varying   mediump vec2    vTexCoord;\n
131 varying   mediump vec2    vTextureOffset;\n
132 void main()\n
133 {\n
134   gl_Position = uMvpMatrix * vec4( aPosition.xy, 0.0, 1.0 );\n
135   vTexCoord = aTexCoord.xy;\n
136
137   vNormal = aNormal;\n
138   vVertex = vec4( aPosition, 1.0 );\n
139   float length = max(0.01, length(aNormal.xy)) * 40.0;\n
140   vTextureOffset = aNormal.xy / length;\n
141 }\n
142 );
143
144 const char* FRAGMENT_SHADER_REFRACTION = DALI_COMPOSE_SHADER(
145 precision mediump float;\n
146 uniform   mediump float  uEffectStrength;\n
147 uniform   mediump vec3   uLightPosition;\n
148 uniform   mediump vec2   uLightXYOffset;\n
149 uniform   mediump vec2   uLightSpinOffset;\n
150 uniform   mediump float  uLightIntensity;\n
151 uniform   lowp    vec4   uColor;\n
152 uniform   sampler2D      sTexture;\n
153 varying   mediump vec4   vVertex;\n
154 varying   mediump vec3   vNormal;\n
155 varying   mediump vec2   vTexCoord;\n
156 varying   mediump vec2   vTextureOffset;\n
157
158 vec3 rgb2hsl(vec3 rgb)\n
159 {\n
160   float epsilon = 1.0e-10;\n
161   vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n
162   vec4 P = mix(vec4(rgb.bg, K.wz), vec4(rgb.gb, K.xy), step(rgb.b, rgb.g));\n
163   vec4 Q = mix(vec4(P.xyw, rgb.r), vec4(rgb.r, P.yzx), step(P.x, rgb.r));\n
164   \n
165   // RGB -> HCV
166   float value = Q.x;\n
167   float chroma = Q.x - min(Q.w, Q.y);\n
168   float hue = abs(Q.z + (Q.w-Q.y) / (6.0*chroma+epsilon));\n
169   // HCV -> HSL
170   float lightness = value - chroma*0.5;\n
171   return vec3( hue, chroma/max( 1.0-abs(lightness*2.0-1.0), 1.0e-1 ), lightness );\n
172 }\n
173
174 vec3 hsl2rgb( vec3 hsl )\n
175 {\n
176   // pure hue->RGB
177   vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n
178   vec3 p = abs(fract(hsl.xxx + K.xyz) * 6.0 - K.www);\n
179   vec3 RGB = clamp(p - K.xxx, 0.0, 1.0);\n
180   \n
181   float chroma = ( 1.0 - abs( hsl.z*2.0-1.0 ) ) * hsl.y;\n
182   return ( RGB - 0.5 ) * chroma + hsl.z;\n
183 }\n
184
185 void main()\n
186 {\n
187   vec3 normal = normalize( vNormal);\n
188
189   vec3 lightPosition = uLightPosition + vec3(uLightXYOffset+uLightSpinOffset, 0.0);\n
190   mediump vec3 vecToLight = normalize( (lightPosition - vVertex.xyz) * 0.01 );\n
191   mediump float spotEffect = pow( max(0.05, vecToLight.z ) - 0.05, 8.0);\n
192
193   spotEffect = spotEffect * uEffectStrength;\n
194   mediump float lightDiffuse = ( ( dot( vecToLight, normal )-0.75 ) *uLightIntensity  ) * spotEffect;\n
195
196   lowp vec4 color = texture2D( sTexture, vTexCoord + vTextureOffset * spotEffect );\n
197   vec3 lightedColor =  hsl2rgb( rgb2hsl(color.rgb) + vec3(0.0,0.0,lightDiffuse) );\n
198
199   gl_FragColor = vec4( lightedColor, color.a ) * uColor;\n
200 }\n
201 );
202
203 } // namespace
204
205
206 /*************************************************/
207 /*Demo using RefractionEffect*****************/
208 /*************************************************/
209 class RefractionEffectExample : public ConnectionTracker
210 {
211 public:
212   RefractionEffectExample( Application &application )
213   : mApplication( application ),
214     mContent(),
215     mTextureSet(),
216     mGeometry(),
217     mRenderer(),
218     mMeshActor(),
219     mShaderFlat(),
220     mShaderRefraction(),
221     mLightAnimation(),
222     mStrenghAnimation(),
223     mLightXYOffsetIndex( Property::INVALID_INDEX ),
224     mSpinAngleIndex( Property::INVALID_INDEX ),
225     mLightIntensityIndex( Property::INVALID_INDEX ),
226     mEffectStrengthIndex( Property::INVALID_INDEX ),
227     mChangeTextureButton(),
228     mChangeMeshButton(),
229     mCurrentTextureId( 1 ),
230     mCurrentMeshId( 0 )
231   {
232     // Connect to the Application's Init signal
233     application.InitSignal().Connect(this, &RefractionEffectExample::Create);
234   }
235
236   ~RefractionEffectExample()
237   {
238   }
239
240 private:
241
242   // The Init signal is received once (only) during the Application lifetime
243   void Create(Application& application)
244   {
245     Stage stage = Stage::GetCurrent();
246     Vector2 stageSize = stage.GetSize();
247
248     stage.KeyEventSignal().Connect(this, &RefractionEffectExample::OnKeyEvent);
249
250     // Creates a default view with a default tool bar.
251     // The view is added to the stage.
252     Toolkit::ToolBar toolBar;
253     Toolkit::Control    view;
254     mContent = DemoHelper::CreateView( application,
255         view,
256         toolBar,
257         "",
258         TOOLBAR_IMAGE,
259         APPLICATION_TITLE );
260
261     // Add a button to change background. (right of toolbar)
262     mChangeTextureButton = Toolkit::PushButton::New();
263     mChangeTextureButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, CHANGE_TEXTURE_ICON );
264     mChangeTextureButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, CHANGE_TEXTURE_ICON_SELECTED );
265     mChangeTextureButton.ClickedSignal().Connect( this, &RefractionEffectExample::OnChangeTexture );
266     toolBar.AddControl( mChangeTextureButton,
267                         DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage,
268                         Toolkit::Alignment::HorizontalRight,
269                         DemoHelper::DEFAULT_MODE_SWITCH_PADDING  );
270     // Add a button to change mesh pattern. ( left of bar )
271     mChangeMeshButton = Toolkit::PushButton::New();
272     mChangeMeshButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, CHANGE_MESH_ICON );
273     mChangeMeshButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, CHANGE_MESH_ICON_SELECTED );
274     mChangeMeshButton.ClickedSignal().Connect( this, &RefractionEffectExample::OnChangeMesh );
275     toolBar.AddControl( mChangeMeshButton,
276                         DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage,
277                         Toolkit::Alignment::HorizontalLeft,
278                         DemoHelper::DEFAULT_MODE_SWITCH_PADDING  );
279
280
281
282     // shader used when the screen is not touched, render a flat surface
283     mShaderFlat = Shader::New( VERTEX_SHADER_FLAT, FRAGMENT_SHADER_FLAT );
284     mGeometry = CreateGeometry( MESH_FILES[mCurrentMeshId] );
285
286     Texture texture = DemoHelper::LoadStageFillingTexture( TEXTURE_IMAGES[mCurrentTextureId] );
287     mTextureSet = TextureSet::New();
288     mTextureSet.SetTexture( 0u, texture );
289
290     mRenderer = Renderer::New( mGeometry, mShaderFlat );
291     mRenderer.SetTextures( mTextureSet );
292
293     mMeshActor = Actor::New();
294     mMeshActor.AddRenderer( mRenderer );
295     mMeshActor.SetSize( stageSize );
296     mMeshActor.SetParentOrigin(ParentOrigin::CENTER);
297     mContent.Add( mMeshActor );
298
299     // Connect the callback to the touch signal on the mesh actor
300     mContent.TouchSignal().Connect( this, &RefractionEffectExample::OnTouch );
301
302     // shader used when the finger is touching the screen. render refraction effect
303     mShaderRefraction = Shader::New( VERTEX_SHADER_REFRACTION, FRAGMENT_SHADER_REFRACTION );
304
305     // register uniforms
306     mLightXYOffsetIndex = mMeshActor.RegisterProperty( "uLightXYOffset", Vector2::ZERO );
307
308     mLightIntensityIndex = mMeshActor.RegisterProperty( "uLightIntensity", 2.5f );
309
310     mEffectStrengthIndex = mMeshActor.RegisterProperty( "uEffectStrength",  0.f );
311
312     Vector3 lightPosition( -stageSize.x*0.5f, -stageSize.y*0.5f, stageSize.x*0.5f ); // top_left
313     mMeshActor.RegisterProperty( "uLightPosition", lightPosition );
314
315     Property::Index lightSpinOffsetIndex = mMeshActor.RegisterProperty( "uLightSpinOffset", Vector2::ZERO );
316
317     mSpinAngleIndex = mMeshActor.RegisterProperty("uSpinAngle", 0.f );
318     Constraint constraint = Constraint::New<Vector2>( mMeshActor, lightSpinOffsetIndex, LightOffsetConstraint(stageSize.x*0.1f) );
319     constraint.AddSource( LocalSource(mSpinAngleIndex) );
320     constraint.Apply();
321
322     // the animation which spin the light around the finger touch position
323     mLightAnimation = Animation::New(2.f);
324     mLightAnimation.AnimateTo( Property( mMeshActor, mSpinAngleIndex ), Math::PI*2.f );
325     mLightAnimation.SetLooping( true );
326     mLightAnimation.Pause();
327   }
328
329   void SetLightXYOffset( const Vector2& offset )
330   {
331     mMeshActor.SetProperty( mLightXYOffsetIndex,  offset );
332   }
333
334   /**
335    * Create a mesh actor with different geometry to replace the current one
336    */
337   bool OnChangeMesh( Toolkit::Button button  )
338   {
339     mCurrentMeshId = ( mCurrentMeshId + 1 ) % NUM_MESH_FILES;
340     mGeometry = CreateGeometry( MESH_FILES[mCurrentMeshId] );
341     mRenderer.SetGeometry( mGeometry );
342
343     return true;
344   }
345
346   bool OnChangeTexture( Toolkit::Button button )
347   {
348     mCurrentTextureId = ( mCurrentTextureId + 1 ) % NUM_TEXTURE_IMAGES;
349     Texture texture = DemoHelper::LoadStageFillingTexture( TEXTURE_IMAGES[mCurrentTextureId] );
350     mTextureSet.SetTexture( 0u, texture );
351     return true;
352   }
353
354   bool OnTouch( Actor actor, const TouchData& event )
355   {
356     switch( event.GetState( 0 ) )
357     {
358       case PointState::DOWN:
359       {
360         mRenderer.SetShader( mShaderRefraction );
361
362         SetLightXYOffset( event.GetScreenPosition( 0 ) );
363
364         mLightAnimation.Play();
365
366         if( mStrenghAnimation )
367         {
368           mStrenghAnimation.Clear();
369         }
370
371         mStrenghAnimation= Animation::New(0.5f);
372         mStrenghAnimation.AnimateTo( Property( mMeshActor, mEffectStrengthIndex ), 1.f );
373         mStrenghAnimation.Play();
374
375         break;
376       }
377       case PointState::MOTION:
378       {
379         // make the light position following the finger movement
380         SetLightXYOffset( event.GetScreenPosition( 0 ) );
381         break;
382       }
383       case PointState::UP:
384       case PointState::LEAVE:
385       case PointState::INTERRUPTED:
386       {
387         mLightAnimation.Pause();
388
389         if( mStrenghAnimation )
390         {
391           mStrenghAnimation.Clear();
392         }
393         mStrenghAnimation = Animation::New(0.5f);
394         mStrenghAnimation.AnimateTo( Property( mMeshActor, mEffectStrengthIndex ), 0.f );
395         mStrenghAnimation.FinishedSignal().Connect( this, &RefractionEffectExample::OnTouchFinished );
396         mStrenghAnimation.Play();
397         break;
398       }
399       case PointState::STATIONARY:
400       {
401         break;
402       }
403     }
404
405     return true;
406   }
407
408   void OnTouchFinished( Animation& source )
409   {
410     mRenderer.SetShader( mShaderFlat );
411     SetLightXYOffset( Vector2::ZERO );
412   }
413
414   Geometry CreateGeometry(const std::string& objFileName)
415   {
416     std::vector<Vector3> vertexPositions;
417     Vector<unsigned int> faceIndices;
418     Vector<float> boundingBox;
419     // read the vertice and faces from the .obj file, and record the bounding box
420     ReadObjFile( objFileName, boundingBox, vertexPositions, faceIndices );
421
422     std::vector<Vector2> textureCoordinates;
423     // align the mesh, scale it to fit the screen size, and calculate the texture coordinate for each vertex
424     ShapeResizeAndTexureCoordinateCalculation( boundingBox, vertexPositions, textureCoordinates );
425
426     // re-organize the mesh, the vertices are duplicated, each vertex only belongs to one triangle.
427     // Without sharing vertex between triangle, so we can manipulate the texture offset on each triangle conveniently.
428     std::vector<Vertex> vertices;
429
430     std::size_t size = faceIndices.Size();
431     vertices.reserve( size );
432
433     for( std::size_t i=0; i<size; i=i+3 )
434     {
435       Vector3 edge1 = vertexPositions[ faceIndices[i+2] ] - vertexPositions[ faceIndices[i] ];
436       Vector3 edge2 = vertexPositions[ faceIndices[i+1] ] - vertexPositions[ faceIndices[i] ];
437       Vector3 normal = edge1.Cross(edge2);
438       normal.Normalize();
439
440       // make sure all the faces are front-facing
441       if( normal.z > 0 )
442       {
443         vertices.push_back( Vertex( vertexPositions[ faceIndices[i] ], normal, textureCoordinates[ faceIndices[i] ] ) );
444         vertices.push_back( Vertex( vertexPositions[ faceIndices[i+1] ], normal, textureCoordinates[ faceIndices[i+1] ] ) );
445         vertices.push_back( Vertex( vertexPositions[ faceIndices[i+2] ], normal, textureCoordinates[ faceIndices[i+2] ] ) );
446       }
447       else
448       {
449         normal *= -1.f;
450         vertices.push_back( Vertex( vertexPositions[ faceIndices[i] ], normal, textureCoordinates[ faceIndices[i] ] ) );
451         vertices.push_back( Vertex( vertexPositions[ faceIndices[i+2] ], normal, textureCoordinates[ faceIndices[i+2] ] ) );
452         vertices.push_back( Vertex( vertexPositions[ faceIndices[i+1] ], normal, textureCoordinates[ faceIndices[i+1] ] ) );
453       }
454     }
455
456     Property::Map vertexFormat;
457     vertexFormat["aPosition"] = Property::VECTOR3;
458     vertexFormat["aNormal"] = Property::VECTOR3;
459     vertexFormat["aTexCoord"] = Property::VECTOR2;
460     PropertyBuffer surfaceVertices = PropertyBuffer::New( vertexFormat );
461     surfaceVertices.SetData( &vertices[0], vertices.size() );
462
463     Geometry surface = Geometry::New();
464     surface.AddVertexBuffer( surfaceVertices );
465
466     return surface;
467   }
468
469   void ReadObjFile( const std::string& objFileName,
470       Vector<float>& boundingBox,
471       std::vector<Vector3>& vertexPositions,
472       Vector<unsigned int>& faceIndices)
473   {
474     std::ifstream ifs( objFileName.c_str(), std::ios::in );
475
476     boundingBox.Resize( 6 );
477     boundingBox[0]=boundingBox[2]=boundingBox[4] = std::numeric_limits<float>::max();
478     boundingBox[1]=boundingBox[3]=boundingBox[5] = -std::numeric_limits<float>::max();
479
480     std::string line;
481     while( std::getline( ifs, line ) )
482     {
483       if( line[0] == 'v' && std::isspace(line[1]))  // vertex
484       {
485         std::istringstream iss(line.substr(2), std::istringstream::in);
486         unsigned int i = 0;
487         Vector3 vertex;
488         while( iss >> vertex[i++] && i < 3);
489         if( vertex.x < boundingBox[0] )  boundingBox[0] = vertex.x;
490         if( vertex.x > boundingBox[1] )  boundingBox[1] = vertex.x;
491         if( vertex.y < boundingBox[2] )  boundingBox[2] = vertex.y;
492         if( vertex.y > boundingBox[3] )  boundingBox[3] = vertex.y;
493         if( vertex.z < boundingBox[4] )  boundingBox[4] = vertex.z;
494         if( vertex.z > boundingBox[5] )  boundingBox[5] = vertex.z;
495         vertexPositions.push_back( vertex );
496       }
497       else if( line[0] == 'f' ) //face
498       {
499         unsigned int numOfInt = 3;
500         while( true )
501         {
502           std::size_t found  = line.find('/');
503           if( found == std::string::npos )
504           {
505             break;
506           }
507           line[found] = ' ';
508           numOfInt++;
509         }
510
511         std::istringstream iss(line.substr(2), std::istringstream::in);
512         unsigned int indices[ numOfInt ];
513         unsigned int i=0;
514         while( iss >> indices[i++] && i < numOfInt);
515         unsigned int step = (i+1) / 3;
516         faceIndices.PushBack( indices[0]-1 );
517         faceIndices.PushBack( indices[step]-1 );
518         faceIndices.PushBack( indices[2*step]-1 );
519       }
520     }
521
522     ifs.close();
523   }
524
525   void ShapeResizeAndTexureCoordinateCalculation( const Vector<float>& boundingBox,
526       std::vector<Vector3>& vertexPositions,
527       std::vector<Vector2>& textureCoordinates)
528   {
529     Vector3 bBoxSize( boundingBox[1] - boundingBox[0], boundingBox[3] - boundingBox[2], boundingBox[5] - boundingBox[4]);
530     Vector3 bBoxMinCorner( boundingBox[0], boundingBox[2], boundingBox[4] );
531
532     Vector2 stageSize = Stage::GetCurrent().GetSize();
533     Vector3 scale( stageSize.x / bBoxSize.x, stageSize.y / bBoxSize.y, 1.f );
534     scale.z = (scale.x + scale.y)/2.f;
535
536     textureCoordinates.reserve(vertexPositions.size());
537
538     for( std::vector<Vector3>::iterator iter = vertexPositions.begin(); iter != vertexPositions.end(); iter++ )
539     {
540       Vector3 newPosition(  (*iter) - bBoxMinCorner ) ;
541
542      textureCoordinates.push_back( Vector2( newPosition.x / bBoxSize.x, newPosition.y / bBoxSize.y ) );
543
544       newPosition -= bBoxSize * 0.5f;
545       (*iter) = newPosition * scale;
546     }
547   }
548
549   /**
550    * Main key event handler
551    */
552   void OnKeyEvent(const KeyEvent& event)
553   {
554     if(event.state == KeyEvent::Down)
555     {
556       if( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) )
557       {
558         mApplication.Quit();
559       }
560     }
561   }
562
563 private:
564
565   Application&   mApplication;
566   Layer          mContent;
567   TextureSet     mTextureSet;
568   Geometry       mGeometry;
569   Renderer       mRenderer;
570   Actor          mMeshActor;
571
572   Shader         mShaderFlat;
573   Shader         mShaderRefraction;
574
575   Animation      mLightAnimation;
576   Animation      mStrenghAnimation;
577
578   Property::Index mLightXYOffsetIndex;
579   Property::Index mSpinAngleIndex;
580   Property::Index mLightIntensityIndex;
581   Property::Index mEffectStrengthIndex;
582
583   Toolkit::PushButton        mChangeTextureButton;
584   Toolkit::PushButton        mChangeMeshButton;
585   unsigned int               mCurrentTextureId;
586   unsigned int               mCurrentMeshId;
587 };
588
589 /*****************************************************************************/
590
591 static void
592 RunTest(Application& app)
593 {
594   RefractionEffectExample theApp(app);
595   app.MainLoop();
596 }
597
598 /*****************************************************************************/
599
600 int DALI_EXPORT_API main(int argc, char **argv)
601 {
602   Application app = Application::New(&argc, &argv, DEMO_THEME_PATH);
603
604   RunTest(app);
605
606   return 0;
607 }