Commit d8770c7db2a214deb95d8051ca5c46c306499e94
1 parent
5b74d885
ShaderEffect changes
Signed-off-by: Ferran Sole <ferran.sole@samsung.com> Change-Id: I609dac012a4f1eba1d0838311e4abdc9f768e568
Showing
5 changed files
with
51 additions
and
41 deletions
demo/dali-table-view.cpp
| ... | ... | @@ -528,7 +528,7 @@ ImageActor DaliTableView::NewStencilImage() |
| 528 | 528 | stencilActor.SetAnchorPoint( AnchorPoint::CENTER ); |
| 529 | 529 | stencilActor.SetDrawMode( DrawMode::STENCIL ); |
| 530 | 530 | |
| 531 | - Dali::ShaderEffect shaderEffect = AlphaDiscardEffect::New(); | |
| 531 | + Dali::ShaderEffect shaderEffect = CreateAlphaDiscardEffect(); | |
| 532 | 532 | stencilActor.SetShaderEffect( shaderEffect ); |
| 533 | 533 | |
| 534 | 534 | return stencilActor; |
| ... | ... | @@ -766,11 +766,11 @@ void DaliTableView::AddBackgroundActors( Actor layer, int count, BufferImage dis |
| 766 | 766 | dfActor.SetSize( Vector2( randSize, randSize ) ); |
| 767 | 767 | dfActor.SetParentOrigin( ParentOrigin::CENTER ); |
| 768 | 768 | |
| 769 | - Toolkit::DistanceFieldEffect effect = Toolkit::DistanceFieldEffect::New(); | |
| 769 | + ShaderEffect effect = Toolkit::CreateDistanceFieldEffect(); | |
| 770 | 770 | dfActor.SetShaderEffect( effect ); |
| 771 | 771 | dfActor.SetColor( randColour ); |
| 772 | - effect.SetOutlineParams( Vector2( 0.55f, 0.00f ) ); | |
| 773 | - effect.SetSmoothingEdge( 0.5f ); | |
| 772 | + effect.SetUniform("uOutlineParams", Vector2( 0.55f, 0.00f ) ); | |
| 773 | + effect.SetUniform("uSmoothing", 0.5f ); | |
| 774 | 774 | layer.Add( dfActor ); |
| 775 | 775 | } |
| 776 | 776 | ... | ... |
examples/cluster/cluster-example.cpp
| ... | ... | @@ -551,22 +551,22 @@ public: |
| 551 | 551 | */ |
| 552 | 552 | void SetMotionBlurEffect( Actor actor ) |
| 553 | 553 | { |
| 554 | - /* | |
| 554 | + | |
| 555 | 555 | // only do something if the actor and effect are valid |
| 556 | 556 | if( actor ) |
| 557 | 557 | { |
| 558 | 558 | // first remove from this actor |
| 559 | - RenderableActor renderable = RenderableActor::DownCast( actor ); | |
| 560 | - if( renderable ) | |
| 559 | + ImageActor imageActor = ImageActor::DownCast( actor ); | |
| 560 | + if( imageActor ) | |
| 561 | 561 | { |
| 562 | - MotionBlurEffect shaderEffect = MotionBlurEffect::New(); | |
| 563 | - shaderEffect.SetSpeedScalingFactor(0.1f); | |
| 562 | + ShaderEffect shaderEffect = Toolkit::CreateMotionBlurEffect(); | |
| 563 | + shaderEffect.SetUniform("uSpeedScalingFactor",0.1f); | |
| 564 | 564 | |
| 565 | 565 | Dali::Property::Index uModelProperty = shaderEffect.GetPropertyIndex( "uModelLastFrame" ); |
| 566 | 566 | Constraint constraint = Constraint::New<Matrix>( shaderEffect, uModelProperty, EqualToConstraint() ); |
| 567 | - constraint.AddSource( Source( actor , Actor::Property::WORLD_MATRIX ) ); | |
| 567 | + constraint.AddSource( Source( imageActor , Actor::Property::WORLD_MATRIX ) ); | |
| 568 | 568 | constraint.Apply(); |
| 569 | - renderable.SetShaderEffect( shaderEffect ); | |
| 569 | + imageActor.SetShaderEffect( shaderEffect ); | |
| 570 | 570 | } |
| 571 | 571 | // then all children recursively |
| 572 | 572 | const unsigned int count = actor.GetChildCount(); |
| ... | ... | @@ -575,7 +575,7 @@ public: |
| 575 | 575 | Actor child( actor.GetChildAt( index ) ); |
| 576 | 576 | SetMotionBlurEffect( child ); |
| 577 | 577 | } |
| 578 | - }*/ | |
| 578 | + } | |
| 579 | 579 | } |
| 580 | 580 | |
| 581 | 581 | /** |
| ... | ... | @@ -650,8 +650,8 @@ public: |
| 650 | 650 | case CAROUSEL_EFFECT: |
| 651 | 651 | { |
| 652 | 652 | // Apply Carousel Shader Effect to scrollView |
| 653 | - CarouselEffect shaderEffect = CarouselEffect::New(); | |
| 654 | - shaderEffect.SetRadius( -CAROUSEL_EFFECT_RADIUS ); | |
| 653 | + ShaderEffect shaderEffect = Toolkit::CreateCarouselEffect(); | |
| 654 | + shaderEffect.SetUniform( "uRadius", -CAROUSEL_EFFECT_RADIUS ); | |
| 655 | 655 | // dont apply shader effect to scrollview as it might override internal shaders for bounce effect etc |
| 656 | 656 | for( std::vector<ClusterInfo>::iterator i = mClusterInfo.begin(); i != mClusterInfo.end(); ++i ) |
| 657 | 657 | { |
| ... | ... | @@ -663,7 +663,7 @@ public: |
| 663 | 663 | const Vector2 angleSweep( CAROUSEL_EFFECT_ANGLE_SWEEP / stageSize.width, |
| 664 | 664 | CAROUSEL_EFFECT_ANGLE_SWEEP / stageSize.width ); |
| 665 | 665 | |
| 666 | - Property::Index anglePerUnit = shaderEffect.GetPropertyIndex( shaderEffect.GetAnglePerUnitPropertyName() ); | |
| 666 | + Property::Index anglePerUnit = shaderEffect.GetPropertyIndex( "uAnglePerUnit" ); | |
| 667 | 667 | Constraint constraint = Constraint::New<Vector2>( shaderEffect, anglePerUnit, CarouselEffectOrientationConstraint( angleSweep ) ); |
| 668 | 668 | constraint.AddSource( Source(mView, Actor::Property::ORIENTATION) ); |
| 669 | 669 | constraint.Apply(); |
| ... | ... | @@ -685,10 +685,10 @@ public: |
| 685 | 685 | mScrollView.SetRulerY(rulerY); |
| 686 | 686 | |
| 687 | 687 | // Apply Carousel Shader Effect to scrollView (Spherical style) |
| 688 | - CarouselEffect shaderEffect = CarouselEffect::New(); | |
| 688 | + ShaderEffect shaderEffect = Toolkit::CreateCarouselEffect(); | |
| 689 | 689 | |
| 690 | - shaderEffect.SetRadius( SPHERE_EFFECT_RADIUS ); | |
| 691 | - shaderEffect.SetAnglePerUnit( Vector2( SPHERE_EFFECT_ANGLE_SWEEP / stageSize.y, SPHERE_EFFECT_ANGLE_SWEEP / stageSize.y ) ); | |
| 690 | + shaderEffect.SetUniform( "uRadius", SPHERE_EFFECT_RADIUS ); | |
| 691 | + shaderEffect.SetUniform( "uAnglePerUnit", Vector2( SPHERE_EFFECT_ANGLE_SWEEP / stageSize.y, SPHERE_EFFECT_ANGLE_SWEEP / stageSize.y ) ); | |
| 692 | 692 | // dont apply shader effect to scrollview as it might override internal shaders for bounce effect etc |
| 693 | 693 | for( std::vector<ClusterInfo>::iterator i = mClusterInfo.begin(); i != mClusterInfo.end(); ++i ) |
| 694 | 694 | { | ... | ... |
examples/dissolve-effect/dissolve-effect-example.cpp
| ... | ... | @@ -162,8 +162,8 @@ private: |
| 162 | 162 | ImageActor mNextImage; |
| 163 | 163 | unsigned int mIndex; |
| 164 | 164 | |
| 165 | - Toolkit::DissolveEffect mCurrentImageEffect; | |
| 166 | - Toolkit::DissolveEffect mNextImageEffect; | |
| 165 | + ShaderEffect mCurrentImageEffect; | |
| 166 | + ShaderEffect mNextImageEffect; | |
| 167 | 167 | bool mUseHighPrecision; |
| 168 | 168 | Animation mAnimation; |
| 169 | 169 | |
| ... | ... | @@ -235,8 +235,8 @@ void DissolveEffectApp::OnInit( Application& application ) |
| 235 | 235 | mPanGestureDetector.DetectedSignal().Connect( this, &DissolveEffectApp::OnPanGesture ); |
| 236 | 236 | |
| 237 | 237 | // create the dissolve effect object |
| 238 | - mCurrentImageEffect = Toolkit::DissolveEffect::New(mUseHighPrecision); | |
| 239 | - mNextImageEffect = Toolkit::DissolveEffect::New(mUseHighPrecision); | |
| 238 | + mCurrentImageEffect = Toolkit::CreateDissolveEffect(mUseHighPrecision); | |
| 239 | + mNextImageEffect = Toolkit::CreateDissolveEffect(mUseHighPrecision); | |
| 240 | 240 | |
| 241 | 241 | mViewTimer = Timer::New( VIEWINGTIME ); |
| 242 | 242 | mViewTimer.TickSignal().Connect( this, &DissolveEffectApp::OnTimerTick ); |
| ... | ... | @@ -294,20 +294,20 @@ void DissolveEffectApp::StartTransition(Vector2 position, Vector2 displacement) |
| 294 | 294 | { |
| 295 | 295 | mAnimation = Animation::New(TRANSITION_DURATION); |
| 296 | 296 | |
| 297 | - mCurrentImageEffect.SetCentralLine(position,displacement); | |
| 298 | - mCurrentImageEffect.SetDistortion(0.0f); | |
| 297 | + Dali::Toolkit::DissolveEffectSetCentralLine( mCurrentImageEffect, position, displacement ); | |
| 298 | + mCurrentImageEffect.SetUniform("uPercentage", 0.0f); | |
| 299 | 299 | mCurrentImage.SetShaderEffect(mCurrentImageEffect); |
| 300 | - mAnimation.AnimateTo( Property(mCurrentImageEffect, mCurrentImageEffect.GetDistortionPropertyName()), 1.0f, AlphaFunction::LINEAR ); | |
| 300 | + mAnimation.AnimateTo( Property(mCurrentImageEffect, "uPercentage"), 1.0f, AlphaFunction::LINEAR ); | |
| 301 | 301 | |
| 302 | 302 | mNextImage.SetOpacity(0.0f); |
| 303 | 303 | mAnimation.AnimateTo( Property( mNextImage, Actor::Property::COLOR_ALPHA ), 1.0f, AlphaFunction::LINEAR ); |
| 304 | 304 | |
| 305 | 305 | if(mUseHighPrecision) |
| 306 | 306 | { |
| 307 | - mNextImageEffect.SetCentralLine(position,-displacement); | |
| 308 | - mNextImageEffect.SetDistortion(1.0f); | |
| 307 | + Dali::Toolkit::DissolveEffectSetCentralLine( mNextImageEffect, position, displacement ); | |
| 308 | + mNextImageEffect.SetUniform("uPercentage", 1.0f); | |
| 309 | 309 | mNextImage.SetShaderEffect(mNextImageEffect); |
| 310 | - mAnimation.AnimateTo( Property(mNextImageEffect, mNextImageEffect.GetDistortionPropertyName()), 0.0f, AlphaFunction::LINEAR ); | |
| 310 | + mAnimation.AnimateTo( Property(mNextImageEffect, "uPercentage"), 0.0f, AlphaFunction::LINEAR ); | |
| 311 | 311 | } |
| 312 | 312 | else |
| 313 | 313 | { |
| ... | ... | @@ -333,7 +333,7 @@ void DissolveEffectApp::OnKeyEvent(const KeyEvent& event) |
| 333 | 333 | bool DissolveEffectApp::OnEffectButtonClicked( Toolkit::Button button ) |
| 334 | 334 | { |
| 335 | 335 | mUseHighPrecision = !mUseHighPrecision; |
| 336 | - mCurrentImageEffect = Toolkit::DissolveEffect::New(mUseHighPrecision); | |
| 336 | + mCurrentImageEffect = Dali::Toolkit::CreateDissolveEffect(mUseHighPrecision); | |
| 337 | 337 | if(mUseHighPrecision) |
| 338 | 338 | { |
| 339 | 339 | mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_HIGHP) ); | ... | ... |
examples/motion-blur/motion-blur-example.cpp
| ... | ... | @@ -212,7 +212,12 @@ public: |
| 212 | 212 | mContentLayer.Add( mMotionBlurImageActor ); |
| 213 | 213 | |
| 214 | 214 | // Create shader used for doing motion blur |
| 215 | - mMotionBlurEffect = MotionBlurEffect::Apply(mMotionBlurImageActor); | |
| 215 | + mMotionBlurEffect = Toolkit::CreateMotionBlurEffect(); | |
| 216 | + Dali::Property::Index uModelProperty = mMotionBlurEffect.GetPropertyIndex( "uModelLastFrame" ); | |
| 217 | + Constraint constraint = Constraint::New<Matrix>( mMotionBlurEffect, uModelProperty, EqualToConstraint() ); | |
| 218 | + constraint.AddSource( Source( mMotionBlurImageActor , Actor::Property::WORLD_MATRIX ) ); | |
| 219 | + constraint.Apply(); | |
| 220 | + mMotionBlurImageActor.SetShaderEffect( mMotionBlurEffect ); | |
| 216 | 221 | |
| 217 | 222 | |
| 218 | 223 | #ifdef MULTIPLE_MOTION_BLURRED_ACTORS |
| ... | ... | @@ -229,7 +234,7 @@ public: |
| 229 | 234 | mMotionBlurImageActor.Add( mMotionBlurImageActor2 ); |
| 230 | 235 | |
| 231 | 236 | // Create shader used for doing motion blur |
| 232 | - mMotionBlurEffect2 = MotionBlurEffect::New(MOTION_BLUR_NUM_SAMPLES); | |
| 237 | + mMotionBlurEffect2 = CreateMotionBlurEffect(MOTION_BLUR_NUM_SAMPLES); | |
| 233 | 238 | |
| 234 | 239 | // set actor shader to the blur one |
| 235 | 240 | mMotionBlurImageActor2.SetShaderEffect( mMotionBlurEffect2 ); |
| ... | ... | @@ -247,7 +252,7 @@ public: |
| 247 | 252 | mMotionBlurImageActor.Add( mMotionBlurImageActor3 ); |
| 248 | 253 | |
| 249 | 254 | // Create shader used for doing motion blur |
| 250 | - mMotionBlurEffect3 = MotionBlurEffect::New(MOTION_BLUR_NUM_SAMPLES); | |
| 255 | + mMotionBlurEffect3 = CreateMotionBlurEffect(MOTION_BLUR_NUM_SAMPLES); | |
| 251 | 256 | |
| 252 | 257 | // set actor shader to the blur one |
| 253 | 258 | mMotionBlurImageActor3.SetShaderEffect( mMotionBlurEffect3 ); |
| ... | ... | @@ -265,7 +270,7 @@ public: |
| 265 | 270 | mMotionBlurImageActor.Add( mMotionBlurImageActor4 ); |
| 266 | 271 | |
| 267 | 272 | // Create shader used for doing motion blur |
| 268 | - mMotionBlurEffect4 = MotionBlurEffect::New(MOTION_BLUR_NUM_SAMPLES); | |
| 273 | + mMotionBlurEffect4 = CreateMotionBlurEffect(MOTION_BLUR_NUM_SAMPLES); | |
| 269 | 274 | |
| 270 | 275 | // set actor shader to the blur one |
| 271 | 276 | mMotionBlurImageActor4.SetShaderEffect( mMotionBlurEffect4 ); |
| ... | ... | @@ -283,7 +288,7 @@ public: |
| 283 | 288 | mMotionBlurImageActor.Add( mMotionBlurImageActor5 ); |
| 284 | 289 | |
| 285 | 290 | // Create shader used for doing motion blur |
| 286 | - mMotionBlurEffect5 = MotionBlurEffect::New(MOTION_BLUR_NUM_SAMPLES); | |
| 291 | + mMotionBlurEffect5 = CreateMotionBlurEffect(MOTION_BLUR_NUM_SAMPLES); | |
| 287 | 292 | |
| 288 | 293 | // set actor shader to the blur one |
| 289 | 294 | mMotionBlurImageActor5.SetShaderEffect( mMotionBlurEffect5 ); |
| ... | ... | @@ -513,15 +518,15 @@ private: |
| 513 | 518 | PushButton mActorEffectsButton; ///< The actor effects toggling Button. |
| 514 | 519 | |
| 515 | 520 | // Motion blur |
| 516 | - MotionBlurEffect mMotionBlurEffect; | |
| 521 | + ShaderEffect mMotionBlurEffect; | |
| 517 | 522 | ImageActor mMotionBlurImageActor; |
| 518 | 523 | Size mMotionBlurActorSize; |
| 519 | 524 | |
| 520 | 525 | #ifdef MULTIPLE_MOTION_BLURRED_ACTORS |
| 521 | - MotionBlurEffect mMotionBlurEffect2; | |
| 522 | - MotionBlurEffect mMotionBlurEffect3; | |
| 523 | - MotionBlurEffect mMotionBlurEffect4; | |
| 524 | - MotionBlurEffect mMotionBlurEffect5; | |
| 526 | + ShaderEffect mMotionBlurEffect2; | |
| 527 | + ShaderEffect mMotionBlurEffect3; | |
| 528 | + ShaderEffect mMotionBlurEffect4; | |
| 529 | + ShaderEffect mMotionBlurEffect5; | |
| 525 | 530 | |
| 526 | 531 | ImageActor mMotionBlurImageActor2; |
| 527 | 532 | ImageActor mMotionBlurImageActor3; | ... | ... |
examples/motion-stretch/motion-stretch-example.cpp
| ... | ... | @@ -185,7 +185,12 @@ public: |
| 185 | 185 | mContentLayer.Add( mMotionStretchImageActor ); |
| 186 | 186 | |
| 187 | 187 | // Create shader used for doing motion stretch |
| 188 | - mMotionStretchEffect = MotionStretchEffect::Apply(mMotionStretchImageActor); | |
| 188 | + mMotionStretchEffect = Toolkit::CreateMotionStretchEffect(); | |
| 189 | + Dali::Property::Index uModelProperty = mMotionStretchEffect.GetPropertyIndex( "uModelLastFrame" ); | |
| 190 | + Constraint constraint = Constraint::New<Matrix>( mMotionStretchEffect, uModelProperty, EqualToConstraint() ); | |
| 191 | + constraint.AddSource( Source( mMotionStretchImageActor , Actor::Property::WORLD_MATRIX ) ); | |
| 192 | + constraint.Apply(); | |
| 193 | + mMotionStretchImageActor.SetShaderEffect( mMotionStretchEffect ); | |
| 189 | 194 | } |
| 190 | 195 | |
| 191 | 196 | ////////////////////////////////////////////////////////////// |
| ... | ... | @@ -409,7 +414,7 @@ private: |
| 409 | 414 | PushButton mActorEffectsButton; ///< The actor effects toggling Button. |
| 410 | 415 | |
| 411 | 416 | // Motion stretch |
| 412 | - MotionStretchEffect mMotionStretchEffect; | |
| 417 | + ShaderEffect mMotionStretchEffect; | |
| 413 | 418 | ImageActor mMotionStretchImageActor; |
| 414 | 419 | |
| 415 | 420 | // animate actor to position where user taps screen | ... | ... |