2 * Copyright (c) 2014 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.
19 #include "bloom-view-impl.h"
24 #include <dali/public-api/animation/constraint.h>
25 #include <dali/public-api/animation/constraints.h>
26 #include <dali/public-api/common/stage.h>
27 #include <dali/public-api/object/property-map.h>
28 #include <dali/public-api/object/type-registry.h>
29 #include <dali/devel-api/object/type-registry-helper.h>
30 #include <dali/public-api/render-tasks/render-task-list.h>
31 #include <dali/devel-api/rendering/renderer.h>
34 #include <dali-toolkit/public-api/controls/gaussian-blur-view/gaussian-blur-view.h>
35 #include <dali-toolkit/devel-api/controls/bloom-view/bloom-view.h>
36 #include "../gaussian-blur-view/gaussian-blur-view-impl.h"
54 return Toolkit::BloomView::New();
57 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::BloomView, Toolkit::Control, Create )
58 DALI_TYPE_REGISTRATION_END()
61 const float BLOOM_THRESHOLD_DEFAULT = 0.25f;
62 const float BLOOM_BLUR_STRENGTH_DEFAULT = 1.0f;
63 const float BLOOM_INTENSITY_DEFAULT = 1.0f;
64 const float IMAGE_INTENSITY_DEFAULT = 1.0f;
65 const float BLOOM_SATURATION_DEFAULT = 1.0f;
66 const float IMAGE_SATURATION_DEFAULT = 1.0f;
69 const unsigned int BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_NUM_SAMPLES = 5;
70 const float BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_BLUR_BELL_CURVE_WIDTH = 1.5f;
71 const Pixel::Format BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_RENDER_TARGET_PIXEL_FORMAT = Pixel::RGBA8888;
72 const float BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_BLUR_FADE_IN = 1.0f; // default, fully blurred
73 const float BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_WIDTH_SCALE = 0.5f;
74 const float BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_HEIGHT_SCALE = 0.5f;
76 const float ARBITRARY_FIELD_OF_VIEW = Math::PI / 4.0f;
78 const char* const BLOOM_BLUR_STRENGTH_PROPERTY_NAME = "BlurStrengthProperty";
79 const char* const BLOOM_THRESHOLD_PROPERTY_NAME = "uBloomThreshold";
80 const char* const RECIP_ONE_MINUS_BLOOM_THRESHOLD_PROPERTY_NAME = "uRecipOneMinusBloomThreshold";
81 const char* const BLOOM_INTENSITY_PROPERTY_NAME = "uBloomIntensity";
82 const char* const BLOOM_SATURATION_PROPERTY_NAME = "uBloomSaturation";
83 const char* const IMAGE_INTENSITY_PROPERTY_NAME = "uImageIntensity";
84 const char* const IMAGE_SATURATION_PROPERTY_NAME = "uImageSaturation";
86 const char* const EFFECT_IMAGE_NAME( "sEffect" );
88 ///////////////////////////////////////////////////////
93 const char* const BLOOM_EXTRACT_FRAGMENT_SOURCE =
94 "varying mediump vec2 vTexCoord;\n"
95 "uniform sampler2D sTexture;\n"
96 "uniform lowp vec4 uColor;\n"
97 "uniform mediump float uBloomThreshold;\n"
98 "uniform mediump float uRecipOneMinusBloomThreshold;\n"
101 " mediump vec4 col;\n"
102 " col = texture2D(sTexture, vTexCoord);\n"
103 " col = (col - uBloomThreshold) * uRecipOneMinusBloomThreshold;\n" // remove intensities lower than the thresold and remap intensities above the threshold to [0..1]
104 " gl_FragColor = clamp(col, 0.0, 1.0);\n"
107 const char* const COMPOSITE_FRAGMENT_SOURCE =
108 "precision mediump float;\n"
109 "varying mediump vec2 vTexCoord;\n"
110 "uniform sampler2D sTexture;\n"
111 "uniform sampler2D sEffect;\n"
112 "uniform lowp vec4 uColor;\n"
113 "uniform float uBloomIntensity;\n"
114 "uniform float uImageIntensity;\n"
115 "uniform float uBloomSaturation;\n"
116 "uniform float uImageSaturation;\n"
118 "vec4 ChangeSaturation(vec4 col, float sat)\n"
120 " float grey = dot(col.rgb, vec3(0.3, 0.6, 0.1));\n"
121 " return mix(vec4(grey, grey, grey, 1.0), col, sat);\n"
126 " mediump vec4 image;\n"
127 " mediump vec4 bloom;\n"
128 " image = texture2D(sTexture, vTexCoord);\n"
129 " bloom = texture2D(sEffect, vTexCoord);\n"
130 " image = ChangeSaturation(image, uImageSaturation) * uImageIntensity;\n"
131 " bloom = ChangeSaturation(bloom, uBloomSaturation) * uBloomIntensity;\n"
132 " image *= 1.0 - clamp(bloom, 0.0, 1.0);\n" // darken base where bloom is strong, to prevent excessive burn-out of result
133 " gl_FragColor = image + bloom;\n"
140 BloomView::BloomView()
141 : Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) )
142 , mBlurNumSamples(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_NUM_SAMPLES)
143 , mBlurBellCurveWidth(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_BLUR_BELL_CURVE_WIDTH)
144 , mPixelFormat(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_RENDER_TARGET_PIXEL_FORMAT)
145 , mDownsampleWidthScale(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_WIDTH_SCALE)
146 , mDownsampleHeightScale(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_HEIGHT_SCALE)
147 , mDownsampledWidth( 0.0f )
148 , mDownsampledHeight( 0.0f )
149 , mTargetSize(Vector2::ZERO)
150 , mLastSize(Vector2::ZERO)
151 , mChildrenRoot(Actor::New())
152 , mBloomThresholdPropertyIndex(Property::INVALID_INDEX)
153 , mBlurStrengthPropertyIndex(Property::INVALID_INDEX)
154 , mBloomIntensityPropertyIndex(Property::INVALID_INDEX)
155 , mBloomSaturationPropertyIndex(Property::INVALID_INDEX)
156 , mImageIntensityPropertyIndex(Property::INVALID_INDEX)
157 , mImageSaturationPropertyIndex(Property::INVALID_INDEX)
158 , mActivated( false )
162 BloomView::BloomView( const unsigned int blurNumSamples, const float blurBellCurveWidth, const Pixel::Format renderTargetPixelFormat,
163 const float downsampleWidthScale, const float downsampleHeightScale)
164 : Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) )
165 , mBlurNumSamples(blurNumSamples)
166 , mBlurBellCurveWidth(blurBellCurveWidth)
167 , mPixelFormat(renderTargetPixelFormat)
168 , mDownsampleWidthScale(downsampleWidthScale)
169 , mDownsampleHeightScale(downsampleHeightScale)
170 , mDownsampledWidth( 0.0f )
171 , mDownsampledHeight( 0.0f )
172 , mTargetSize(Vector2::ZERO)
173 , mLastSize(Vector2::ZERO)
174 , mChildrenRoot(Actor::New())
175 , mBloomThresholdPropertyIndex(Property::INVALID_INDEX)
176 , mBlurStrengthPropertyIndex(Property::INVALID_INDEX)
177 , mBloomIntensityPropertyIndex(Property::INVALID_INDEX)
178 , mBloomSaturationPropertyIndex(Property::INVALID_INDEX)
179 , mImageIntensityPropertyIndex(Property::INVALID_INDEX)
180 , mImageSaturationPropertyIndex(Property::INVALID_INDEX)
181 , mActivated( false )
185 BloomView::~BloomView()
189 Toolkit::BloomView BloomView::New()
191 BloomView* impl = new BloomView();
193 Dali::Toolkit::BloomView handle = Dali::Toolkit::BloomView( *impl );
195 // Second-phase init of the implementation
196 // This can only be done after the CustomActor connection has been made...
202 Toolkit::BloomView BloomView::New(const unsigned int blurNumSamples, const float blurBellCurveWidth, const Pixel::Format renderTargetPixelFormat,
203 const float downsampleWidthScale, const float downsampleHeightScale)
205 BloomView* impl = new BloomView( blurNumSamples, blurBellCurveWidth, renderTargetPixelFormat, downsampleWidthScale, downsampleHeightScale);
207 Dali::Toolkit::BloomView handle = Dali::Toolkit::BloomView( *impl );
209 // Second-phase init of the implementation
210 // This can only be done after the CustomActor connection has been made...
216 /////////////////////////////////////////////////////////////
217 // for creating a subtree for all user added child actors, so that we can have them exclusive to the mRenderChildrenTask and our other actors exclusive to our other tasks
218 // TODO: overloading Actor::Add()/Remove() not nice since breaks polymorphism. Need another method to pass ownership of added child actors to our internal actor root.
219 void BloomView::Add(Actor child)
221 mChildrenRoot.Add(child);
224 void BloomView::Remove(Actor child)
226 mChildrenRoot.Remove(child);
234 ///////////////////////////////////////////////////////////
239 void BloomView::OnInitialize()
241 // root actor to parent all user added actors, needed to allow us to set that subtree as exclusive for our child render task
242 mChildrenRoot.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
244 //////////////////////////////////////////////////////
247 // Create an ImageActor for rendering from the scene texture to the bloom texture
248 mBloomExtractImageActor = Toolkit::ImageView::New();
249 mBloomExtractImageActor.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
251 // Create shader used for extracting the bright parts of an image
252 Property::Map customShader;
253 customShader[ "fragmentShader" ] = BLOOM_EXTRACT_FRAGMENT_SOURCE;
254 Property::Map rendererMap;
255 rendererMap.Insert( "rendererType", "imageRenderer" );
256 rendererMap.Insert( "shader", customShader );
257 mBloomExtractImageActor.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap );
259 // Create an ImageActor for compositing the result (scene and bloom textures) to output
260 mCompositeImageActor = Toolkit::ImageView::New();
261 mCompositeImageActor.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
263 // Create shader used to composite bloom and original image to output render target
264 customShader[ "fragmentShader" ] = COMPOSITE_FRAGMENT_SOURCE;
265 rendererMap[ "shader" ] = customShader;
266 mCompositeImageActor.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap );
268 // Create an ImageActor for holding final result, i.e. the blurred image. This will get rendered to screen later, via default / user render task
269 mTargetImageActor = Toolkit::ImageView::New();
270 mTargetImageActor.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
273 // Create the Gaussian Blur object + render tasks
274 // Note that we use mBloomExtractTarget as the source image and also re-use this as the gaussian blur final render target. This saves the gaussian blur code from creating it
275 // render targets etc internally, so we make better use of resources
276 // Note, this also internally creates the render tasks used by the Gaussian blur, this must occur after the bloom extraction and before the compositing
277 mGaussianBlurView = Dali::Toolkit::GaussianBlurView::New(mBlurNumSamples, mBlurBellCurveWidth, mPixelFormat, mDownsampleWidthScale, mDownsampleHeightScale, true);
278 mGaussianBlurView.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
281 //////////////////////////////////////////////////////
282 // Create cameras for the renders corresponding to the (potentially downsampled) render targets' size
283 mRenderDownsampledCamera = CameraActor::New();
284 mRenderDownsampledCamera.SetParentOrigin(ParentOrigin::CENTER);
285 mRenderDownsampledCamera.SetInvertYAxis( true );
287 mRenderFullSizeCamera = CameraActor::New();
288 mRenderFullSizeCamera.SetParentOrigin(ParentOrigin::CENTER);
289 mRenderFullSizeCamera.SetInvertYAxis( true );
292 ////////////////////////////////
293 // Connect to actor tree
294 Self().Add( mChildrenRoot );
295 Self().Add( mBloomExtractImageActor );
296 Self().Add( mGaussianBlurView );
297 Self().Add( mCompositeImageActor );
298 Self().Add( mTargetImageActor );
299 Self().Add( mRenderDownsampledCamera );
300 Self().Add( mRenderFullSizeCamera );
302 // bind properties for / set shader constants to defaults
306 void BloomView::OnSizeSet(const Vector3& targetSize)
308 mTargetSize = Vector2(targetSize);
309 mChildrenRoot.SetSize(targetSize);
310 mCompositeImageActor.SetSize(targetSize);
311 mTargetImageActor.SetSize(targetSize);
313 // Children render camera must move when GaussianBlurView object is
314 // resized. This is since we cannot change render target size - so we need
315 // to remap the child actors' rendering accordingly so they still exactly
316 // fill the render target. Note that this means the effective resolution of
317 // the child render changes as the GaussianBlurView object changes size,
318 // this is the trade off for not being able to modify render target size
319 // Change camera z position based on GaussianBlurView actor height
320 float cameraPosConstraintScale = 0.5f / tanf(ARBITRARY_FIELD_OF_VIEW * 0.5f);
321 mRenderFullSizeCamera.SetZ( mTargetSize.height * cameraPosConstraintScale);
323 // if we have already activated the blur, need to update render target sizes now to reflect the new size of this actor
331 void BloomView::AllocateResources()
333 // size of render targets etc is based on the size of this actor, ignoring z
334 if(mTargetSize != mLastSize)
336 mLastSize = mTargetSize;
338 // get size of downsampled render targets
339 mDownsampledWidth = mTargetSize.width * mDownsampleWidthScale;
340 mDownsampledHeight = mTargetSize.height * mDownsampleHeightScale;
343 //////////////////////////////////////////////////////
346 // Create and place a camera for the renders corresponding to the (potentially downsampled) render targets' size
347 mRenderDownsampledCamera.SetFieldOfView(ARBITRARY_FIELD_OF_VIEW);
348 // TODO: how do we pick a reasonable value for near clip? Needs to relate to normal camera the user renders with, but we don't have a handle on it
349 mRenderDownsampledCamera.SetNearClippingPlane(1.0f);
350 mRenderDownsampledCamera.SetAspectRatio(mDownsampledWidth / mDownsampledHeight);
351 mRenderDownsampledCamera.SetType(Dali::Camera::FREE_LOOK); // camera orientation based solely on actor
353 mRenderDownsampledCamera.SetPosition(0.0f, 0.0f, ((mDownsampledHeight * 0.5f) / tanf(ARBITRARY_FIELD_OF_VIEW * 0.5f)));
355 // Create and place a camera for the children render, corresponding to its render target size
356 mRenderFullSizeCamera.SetFieldOfView(ARBITRARY_FIELD_OF_VIEW);
357 // TODO: how do we pick a reasonable value for near clip? Needs to relate to normal camera the user renders with, but we don't have a handle on it
358 mRenderFullSizeCamera.SetNearClippingPlane(1.0f);
359 mRenderFullSizeCamera.SetAspectRatio(mTargetSize.width / mTargetSize.height);
360 mRenderFullSizeCamera.SetType(Dali::Camera::FREE_LOOK); // camera orientation based solely on actor
362 float cameraPosConstraintScale = 0.5f / tanf(ARBITRARY_FIELD_OF_VIEW * 0.5f);
363 mRenderFullSizeCamera.SetPosition(0.0f, 0.0f, mTargetSize.height * cameraPosConstraintScale);
365 //////////////////////////////////////////////////////
366 // Pass size change onto GaussianBlurView, so it matches
367 mGaussianBlurView.SetSize(mTargetSize);
368 GetImpl(mGaussianBlurView).AllocateResources();
371 //////////////////////////////////////////////////////
372 // Create render targets
374 // create off screen buffer of new size to render our child actors to
375 mRenderTargetForRenderingChildren = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat, Dali::Image::UNUSED );
376 mBloomExtractTarget = FrameBufferImage::New( mDownsampledWidth, mDownsampledHeight, mPixelFormat, Dali::Image::UNUSED );
377 FrameBufferImage mBlurExtractTarget = FrameBufferImage::New( mDownsampledWidth, mDownsampledHeight, mPixelFormat, Dali::Image::UNUSED );
378 mOutputRenderTarget = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat, Dali::Image::UNUSED);
381 //////////////////////////////////////////////////////
382 // Point actors and render tasks at new render targets
384 mBloomExtractImageActor.SetImage( mRenderTargetForRenderingChildren );
385 mBloomExtractImageActor.SetSize(mDownsampledWidth, mDownsampledHeight); // size needs to match render target
387 // set GaussianBlurView to blur our extracted bloom
388 mGaussianBlurView.SetUserImageAndOutputRenderTarget(mBloomExtractTarget, mBlurExtractTarget);
390 // use the completed blur in the first buffer and composite with the original child actors render
391 mCompositeImageActor.SetImage( mRenderTargetForRenderingChildren );
392 Material material = mCompositeImageActor.GetRendererAt(0).GetMaterial();
393 int textureIndex = material.GetTextureIndex( EFFECT_IMAGE_NAME );
394 if( textureIndex == -1 )
396 material.AddTexture( mBlurExtractTarget, EFFECT_IMAGE_NAME );
400 material.SetTextureImage( textureIndex, mBlurExtractTarget );
403 // set up target actor for rendering result, i.e. the blurred image
404 mTargetImageActor.SetImage(mOutputRenderTarget);
408 void BloomView::CreateRenderTasks()
410 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
412 // create render task to render our child actors to offscreen buffer
413 mRenderChildrenTask = taskList.CreateTask();
414 mRenderChildrenTask.SetSourceActor( mChildrenRoot );
415 mRenderChildrenTask.SetExclusive(true);
416 mRenderChildrenTask.SetInputEnabled( false );
417 mRenderChildrenTask.SetClearEnabled( true );
418 mRenderChildrenTask.SetCameraActor(mRenderFullSizeCamera); // use camera that covers render target exactly
419 mRenderChildrenTask.SetTargetFrameBuffer( mRenderTargetForRenderingChildren );
421 // Extract the bright part of the image and render to a new buffer. Downsampling also occurs at this stage to save pixel fill, if it is set up.
422 mBloomExtractTask = taskList.CreateTask();
423 mBloomExtractTask.SetSourceActor( mBloomExtractImageActor );
424 mBloomExtractTask.SetExclusive(true);
425 mBloomExtractTask.SetInputEnabled( false );
426 mBloomExtractTask.SetClearEnabled( true );
427 mBloomExtractTask.SetCameraActor(mRenderDownsampledCamera);
428 mBloomExtractTask.SetTargetFrameBuffer( mBloomExtractTarget );
430 // GaussianBlurView tasks must be created here, so they are executed in the correct order with respect to BloomView tasks
431 GetImpl(mGaussianBlurView).CreateRenderTasks();
433 // Use an image actor displaying the children render and composite it with the blurred bloom buffer, targeting the output
434 mCompositeTask = taskList.CreateTask();
435 mCompositeTask.SetSourceActor( mCompositeImageActor );
436 mCompositeTask.SetExclusive(true);
437 mCompositeTask.SetInputEnabled( false );
438 mCompositeTask.SetClearEnabled( true );
439 mCompositeTask.SetCameraActor(mRenderFullSizeCamera);
440 mCompositeTask.SetTargetFrameBuffer( mOutputRenderTarget );
443 void BloomView::RemoveRenderTasks()
445 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
447 taskList.RemoveTask(mRenderChildrenTask);
448 taskList.RemoveTask(mBloomExtractTask);
450 GetImpl(mGaussianBlurView).RemoveRenderTasks();
452 taskList.RemoveTask(mCompositeTask);
455 void BloomView::Activate()
457 // make sure resources are allocated and start the render tasks processing
463 void BloomView::Deactivate()
465 // stop render tasks processing
466 // Note: render target resources are automatically freed since we set the Image::Unused flag
472 * RecipOneMinusConstraint
474 * f(current, property) = property
476 struct RecipOneMinusConstraint
478 RecipOneMinusConstraint(){}
480 void operator()( float& current, const PropertyInputContainer& inputs )
482 current = 1.0f / ( 1.0f - inputs[0]->GetFloat() );
486 // create properties and constraints to tie internal shader etc settings to BloomView object. User can therefore animate / set them via BloomView object without knowing about
487 // internal implementation classes
488 void BloomView::SetupProperties()
490 CustomActor self = Self();
493 ///////////////////////////////////////////
496 // set defaults, makes sure properties are registered with shader
497 mBloomExtractImageActor.RegisterProperty( BLOOM_THRESHOLD_PROPERTY_NAME, BLOOM_THRESHOLD_DEFAULT );
498 mBloomExtractImageActor.RegisterProperty( RECIP_ONE_MINUS_BLOOM_THRESHOLD_PROPERTY_NAME, 1.0f / (1.0f - BLOOM_THRESHOLD_DEFAULT) );
500 // Register a property that the user can control to change the bloom threshold
501 mBloomThresholdPropertyIndex = self.RegisterProperty(BLOOM_THRESHOLD_PROPERTY_NAME, BLOOM_THRESHOLD_DEFAULT);
502 Property::Index shaderBloomThresholdPropertyIndex = mBloomExtractImageActor.GetPropertyIndex(BLOOM_THRESHOLD_PROPERTY_NAME);
503 Constraint bloomThresholdConstraint = Constraint::New<float>( mBloomExtractImageActor, shaderBloomThresholdPropertyIndex, EqualToConstraint());
504 bloomThresholdConstraint.AddSource( Source(self, mBloomThresholdPropertyIndex) );
505 bloomThresholdConstraint.Apply();
507 // precalc 1.0 / (1.0 - threshold) on CPU to save shader insns, using constraint to tie to the normal threshold property
508 Property::Index shaderRecipOneMinusBloomThresholdPropertyIndex = mBloomExtractImageActor.GetPropertyIndex(RECIP_ONE_MINUS_BLOOM_THRESHOLD_PROPERTY_NAME);
509 Constraint thresholdConstraint = Constraint::New<float>( mBloomExtractImageActor, shaderRecipOneMinusBloomThresholdPropertyIndex, RecipOneMinusConstraint());
510 thresholdConstraint.AddSource( LocalSource(shaderBloomThresholdPropertyIndex) );
511 thresholdConstraint.Apply();
514 ////////////////////////////////////////////
517 // Register a property that the user can control to fade the blur in / out via internal GaussianBlurView object
518 mBlurStrengthPropertyIndex = self.RegisterProperty(BLOOM_BLUR_STRENGTH_PROPERTY_NAME, BLOOM_BLUR_STRENGTH_DEFAULT);
519 Constraint blurStrengthConstraint = Constraint::New<float>( mGaussianBlurView, mGaussianBlurView.GetBlurStrengthPropertyIndex(), EqualToConstraint());
520 blurStrengthConstraint.AddSource( Source(self, mBlurStrengthPropertyIndex) );
521 blurStrengthConstraint.Apply();
524 ////////////////////////////////////////////
527 // Register a property that the user can control to fade the bloom intensity via internally hidden shader
528 mBloomIntensityPropertyIndex = self.RegisterProperty(BLOOM_INTENSITY_PROPERTY_NAME, BLOOM_INTENSITY_DEFAULT);
529 mCompositeImageActor.RegisterProperty( BLOOM_INTENSITY_PROPERTY_NAME, BLOOM_INTENSITY_DEFAULT );
530 Property::Index shaderBloomIntensityPropertyIndex = mCompositeImageActor.GetPropertyIndex(BLOOM_INTENSITY_PROPERTY_NAME);
531 Constraint bloomIntensityConstraint = Constraint::New<float>( mCompositeImageActor, shaderBloomIntensityPropertyIndex, EqualToConstraint());
532 bloomIntensityConstraint.AddSource( Source(self, mBloomIntensityPropertyIndex) );
533 bloomIntensityConstraint.Apply();
536 ////////////////////////////////////////////
539 // Register a property that the user can control to fade the bloom saturation via internally hidden shader
540 mBloomSaturationPropertyIndex = self.RegisterProperty(BLOOM_SATURATION_PROPERTY_NAME, BLOOM_SATURATION_DEFAULT);
541 mCompositeImageActor.RegisterProperty( BLOOM_SATURATION_PROPERTY_NAME, BLOOM_SATURATION_DEFAULT );
542 Property::Index shaderBloomSaturationPropertyIndex = mCompositeImageActor.GetPropertyIndex(BLOOM_SATURATION_PROPERTY_NAME);
543 Constraint bloomSaturationConstraint = Constraint::New<float>( mCompositeImageActor, shaderBloomSaturationPropertyIndex, EqualToConstraint());
544 bloomSaturationConstraint.AddSource( Source(self, mBloomSaturationPropertyIndex) );
545 bloomSaturationConstraint.Apply();
548 ////////////////////////////////////////////
551 // Register a property that the user can control to fade the image intensity via internally hidden shader
552 mImageIntensityPropertyIndex = self.RegisterProperty(IMAGE_INTENSITY_PROPERTY_NAME, IMAGE_INTENSITY_DEFAULT);
553 mCompositeImageActor.RegisterProperty( IMAGE_INTENSITY_PROPERTY_NAME, IMAGE_INTENSITY_DEFAULT );
554 Property::Index shaderImageIntensityPropertyIndex = mCompositeImageActor.GetPropertyIndex(IMAGE_INTENSITY_PROPERTY_NAME);
555 Constraint imageIntensityConstraint = Constraint::New<float>( mCompositeImageActor, shaderImageIntensityPropertyIndex, EqualToConstraint());
556 imageIntensityConstraint.AddSource( Source(self, mImageIntensityPropertyIndex) );
557 imageIntensityConstraint.Apply();
560 ////////////////////////////////////////////
563 // Register a property that the user can control to fade the image saturation via internally hidden shader
564 mImageSaturationPropertyIndex = self.RegisterProperty(IMAGE_SATURATION_PROPERTY_NAME, IMAGE_SATURATION_DEFAULT);
565 mCompositeImageActor.RegisterProperty( IMAGE_SATURATION_PROPERTY_NAME, IMAGE_SATURATION_DEFAULT );
566 Property::Index shaderImageSaturationPropertyIndex = mCompositeImageActor.GetPropertyIndex(IMAGE_SATURATION_PROPERTY_NAME);
567 Constraint imageSaturationConstraint = Constraint::New<float>( mCompositeImageActor, shaderImageSaturationPropertyIndex, EqualToConstraint());
568 imageSaturationConstraint.AddSource( Source(self, mImageSaturationPropertyIndex) );
569 imageSaturationConstraint.Apply();
572 } // namespace Internal
574 } // namespace Toolkit