2 * Copyright (c) 2021 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"
22 #include <dali/devel-api/common/stage.h>
23 #include <dali/public-api/animation/constraint.h>
24 #include <dali/public-api/animation/constraints.h>
25 #include <dali/public-api/object/property-map.h>
26 #include <dali/public-api/object/type-registry-helper.h>
27 #include <dali/public-api/object/type-registry.h>
28 #include <dali/public-api/render-tasks/render-task-list.h>
29 #include <dali/public-api/rendering/renderer.h>
34 #include <dali-toolkit/devel-api/controls/bloom-view/bloom-view.h>
35 #include <dali-toolkit/devel-api/controls/control-devel.h>
36 #include <dali-toolkit/devel-api/controls/gaussian-blur-view/gaussian-blur-view.h>
37 #include <dali-toolkit/internal/controls/control/control-renderers.h>
38 #include <dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.h>
39 #include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
53 return Toolkit::BloomView::New();
56 DALI_TYPE_REGISTRATION_BEGIN(Toolkit::BloomView, Toolkit::Control, Create)
57 DALI_TYPE_REGISTRATION_END()
60 const float BLOOM_THRESHOLD_DEFAULT = 0.25f;
61 const float BLOOM_BLUR_STRENGTH_DEFAULT = 1.0f;
62 const float BLOOM_INTENSITY_DEFAULT = 1.0f;
63 const float IMAGE_INTENSITY_DEFAULT = 1.0f;
64 const float BLOOM_SATURATION_DEFAULT = 1.0f;
65 const float IMAGE_SATURATION_DEFAULT = 1.0f;
68 const unsigned int BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_NUM_SAMPLES = 5;
69 const float BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_BLUR_BELL_CURVE_WIDTH = 1.5f;
70 const Pixel::Format BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_RENDER_TARGET_PIXEL_FORMAT = Pixel::RGBA8888;
71 const float BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_BLUR_FADE_IN = 1.0f; // default, fully blurred
72 const float BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_WIDTH_SCALE = 0.5f;
73 const float BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_HEIGHT_SCALE = 0.5f;
75 const float ARBITRARY_FIELD_OF_VIEW = Math::PI / 4.0f;
77 const char* const BLOOM_BLUR_STRENGTH_PROPERTY_NAME = "BlurStrengthProperty";
78 const char* const BLOOM_THRESHOLD_PROPERTY_NAME = "uBloomThreshold";
79 const char* const RECIP_ONE_MINUS_BLOOM_THRESHOLD_PROPERTY_NAME = "uRecipOneMinusBloomThreshold";
80 const char* const BLOOM_INTENSITY_PROPERTY_NAME = "uBloomIntensity";
81 const char* const BLOOM_SATURATION_PROPERTY_NAME = "uBloomSaturation";
82 const char* const IMAGE_INTENSITY_PROPERTY_NAME = "uImageIntensity";
83 const char* const IMAGE_SATURATION_PROPERTY_NAME = "uImageSaturation";
87 BloomView::BloomView()
88 : Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT)),
89 mBlurNumSamples(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_NUM_SAMPLES),
90 mBlurBellCurveWidth(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_BLUR_BELL_CURVE_WIDTH),
91 mPixelFormat(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_RENDER_TARGET_PIXEL_FORMAT),
92 mDownsampleWidthScale(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_WIDTH_SCALE),
93 mDownsampleHeightScale(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_HEIGHT_SCALE),
94 mDownsampledWidth(0.0f),
95 mDownsampledHeight(0.0f),
96 mTargetSize(Vector2::ZERO),
97 mLastSize(Vector2::ZERO),
98 mChildrenRoot(Actor::New()),
99 mInternalRoot(Actor::New()),
100 mBloomThresholdPropertyIndex(Property::INVALID_INDEX),
101 mBlurStrengthPropertyIndex(Property::INVALID_INDEX),
102 mBloomIntensityPropertyIndex(Property::INVALID_INDEX),
103 mBloomSaturationPropertyIndex(Property::INVALID_INDEX),
104 mImageIntensityPropertyIndex(Property::INVALID_INDEX),
105 mImageSaturationPropertyIndex(Property::INVALID_INDEX),
110 BloomView::BloomView(const unsigned int blurNumSamples, const float blurBellCurveWidth, const Pixel::Format renderTargetPixelFormat, const float downsampleWidthScale, const float downsampleHeightScale)
111 : Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT)),
112 mBlurNumSamples(blurNumSamples),
113 mBlurBellCurveWidth(blurBellCurveWidth),
114 mPixelFormat(renderTargetPixelFormat),
115 mDownsampleWidthScale(downsampleWidthScale),
116 mDownsampleHeightScale(downsampleHeightScale),
117 mDownsampledWidth(0.0f),
118 mDownsampledHeight(0.0f),
119 mTargetSize(Vector2::ZERO),
120 mLastSize(Vector2::ZERO),
121 mChildrenRoot(Actor::New()),
122 mInternalRoot(Actor::New()),
123 mBloomThresholdPropertyIndex(Property::INVALID_INDEX),
124 mBlurStrengthPropertyIndex(Property::INVALID_INDEX),
125 mBloomIntensityPropertyIndex(Property::INVALID_INDEX),
126 mBloomSaturationPropertyIndex(Property::INVALID_INDEX),
127 mImageIntensityPropertyIndex(Property::INVALID_INDEX),
128 mImageSaturationPropertyIndex(Property::INVALID_INDEX),
133 BloomView::~BloomView()
137 Toolkit::BloomView BloomView::New()
139 BloomView* impl = new BloomView();
141 Dali::Toolkit::BloomView handle = Dali::Toolkit::BloomView(*impl);
143 // Second-phase init of the implementation
144 // This can only be done after the CustomActor connection has been made...
150 Toolkit::BloomView BloomView::New(const unsigned int blurNumSamples, const float blurBellCurveWidth, const Pixel::Format renderTargetPixelFormat, const float downsampleWidthScale, const float downsampleHeightScale)
152 BloomView* impl = new BloomView(blurNumSamples, blurBellCurveWidth, renderTargetPixelFormat, downsampleWidthScale, downsampleHeightScale);
154 Dali::Toolkit::BloomView handle = Dali::Toolkit::BloomView(*impl);
156 // Second-phase init of the implementation
157 // This can only be done after the CustomActor connection has been made...
163 ///////////////////////////////////////////////////////////
168 void BloomView::OnInitialize()
170 // root actor to parent all user added actors, needed to allow us to set that subtree as exclusive for our child render task
171 mChildrenRoot.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
172 mInternalRoot.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
174 //////////////////////////////////////////////////////
177 // Create an image view for rendering from the scene texture to the bloom texture
178 mBloomExtractActor = Actor::New();
179 mBloomExtractActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
181 // Create an image view for compositing the result (scene and bloom textures) to output
182 mCompositeActor = Actor::New();
183 mCompositeActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
185 // Create an image view for holding final result, i.e. the blurred image. This will get rendered to screen later, via default / user render task
186 mTargetActor = Actor::New();
187 mTargetActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
189 // Create the Gaussian Blur object + render tasks
190 // 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
191 // render targets etc internally, so we make better use of resources
192 // Note, this also internally creates the render tasks used by the Gaussian blur, this must occur after the bloom extraction and before the compositing
193 mGaussianBlurView = Dali::Toolkit::GaussianBlurView::New(mBlurNumSamples, mBlurBellCurveWidth, mPixelFormat, mDownsampleWidthScale, mDownsampleHeightScale, true);
194 mGaussianBlurView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
196 //////////////////////////////////////////////////////
197 // Create cameras for the renders corresponding to the (potentially downsampled) render targets' size
198 mRenderDownsampledCamera = CameraActor::New();
199 mRenderDownsampledCamera.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
200 mRenderDownsampledCamera.SetInvertYAxis(true);
202 mRenderFullSizeCamera = CameraActor::New();
203 mRenderFullSizeCamera.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
204 mRenderFullSizeCamera.SetInvertYAxis(true);
206 ////////////////////////////////
207 // Connect to actor tree
208 Self().Add(mChildrenRoot);
209 Self().Add(mInternalRoot);
210 mInternalRoot.Add(mBloomExtractActor);
211 mInternalRoot.Add(mGaussianBlurView);
212 mInternalRoot.Add(mCompositeActor);
213 mInternalRoot.Add(mTargetActor);
214 mInternalRoot.Add(mRenderDownsampledCamera);
215 mInternalRoot.Add(mRenderFullSizeCamera);
217 // bind properties for / set shader constants to defaults
220 Self().SetProperty(DevelControl::Property::ACCESSIBILITY_ROLE, Dali::Accessibility::Role::ANIMATION);
223 void BloomView::OnSizeSet(const Vector3& targetSize)
225 mTargetSize = Vector2(targetSize);
226 mChildrenRoot.SetProperty(Actor::Property::SIZE, targetSize);
227 mCompositeActor.SetProperty(Actor::Property::SIZE, targetSize);
228 mTargetActor.SetProperty(Actor::Property::SIZE, targetSize);
230 // Children render camera must move when GaussianBlurView object is
231 // resized. This is since we cannot change render target size - so we need
232 // to remap the child actors' rendering accordingly so they still exactly
233 // fill the render target. Note that this means the effective resolution of
234 // the child render changes as the GaussianBlurView object changes size,
235 // this is the trade off for not being able to modify render target size
236 // Change camera z position based on GaussianBlurView actor height
237 float cameraPosConstraintScale = 0.5f / tanf(ARBITRARY_FIELD_OF_VIEW * 0.5f);
238 mRenderFullSizeCamera.SetProperty(Actor::Property::POSITION_Z, mTargetSize.height * cameraPosConstraintScale);
240 // if we have already activated the blur, need to update render target sizes now to reflect the new size of this actor
247 Control::OnSizeSet(targetSize);
250 void BloomView::OnChildAdd(Actor& child)
252 if(child != mChildrenRoot && child != mInternalRoot)
254 mChildrenRoot.Add(child);
257 Control::OnChildAdd(child);
260 void BloomView::OnChildRemove(Actor& child)
262 mChildrenRoot.Remove(child);
264 Control::OnChildRemove(child);
267 void BloomView::AllocateResources()
269 // size of render targets etc is based on the size of this actor, ignoring z
270 if(mTargetSize != mLastSize || !mActivated)
272 mLastSize = mTargetSize;
274 // get size of downsampled render targets
275 mDownsampledWidth = mTargetSize.width * mDownsampleWidthScale;
276 mDownsampledHeight = mTargetSize.height * mDownsampleHeightScale;
278 //////////////////////////////////////////////////////
281 // Create and place a camera for the renders corresponding to the (potentially downsampled) render targets' size
282 mRenderDownsampledCamera.SetFieldOfView(ARBITRARY_FIELD_OF_VIEW);
283 mRenderDownsampledCamera.SetNearClippingPlane(1.0f);
284 mRenderDownsampledCamera.SetAspectRatio(mDownsampledWidth / mDownsampledHeight);
285 mRenderDownsampledCamera.SetType(Dali::Camera::FREE_LOOK); // camera orientation based solely on actor
287 mRenderDownsampledCamera.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, ((mDownsampledHeight * 0.5f) / tanf(ARBITRARY_FIELD_OF_VIEW * 0.5f))));
289 // Create and place a camera for the children render, corresponding to its render target size
290 mRenderFullSizeCamera.SetFieldOfView(ARBITRARY_FIELD_OF_VIEW);
291 mRenderFullSizeCamera.SetNearClippingPlane(1.0f);
292 mRenderFullSizeCamera.SetAspectRatio(mTargetSize.width / mTargetSize.height);
293 mRenderFullSizeCamera.SetType(Dali::Camera::FREE_LOOK); // camera orientation based solely on actor
295 float cameraPosConstraintScale = 0.5f / tanf(ARBITRARY_FIELD_OF_VIEW * 0.5f);
296 mRenderFullSizeCamera.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, mTargetSize.height * cameraPosConstraintScale));
298 //////////////////////////////////////////////////////
299 // Pass size change onto GaussianBlurView, so it matches
300 mGaussianBlurView.SetProperty(Actor::Property::SIZE, mTargetSize);
301 GetImpl(mGaussianBlurView).AllocateResources();
303 mGaussianBlurView.SetProperty(Actor::Property::VISIBLE, true);
305 //////////////////////////////////////////////////////
306 // Create render targets
308 // create off screen buffer of new size to render our child actors to
309 mRenderTargetForRenderingChildren = FrameBuffer::New(mTargetSize.width, mTargetSize.height, FrameBuffer::Attachment::NONE);
310 Texture textureForChildren = Texture::New(TextureType::TEXTURE_2D, mPixelFormat, unsigned(mTargetSize.width), unsigned(mTargetSize.height));
311 mRenderTargetForRenderingChildren.AttachColorTexture(textureForChildren);
313 mBloomExtractTarget = FrameBuffer::New(mDownsampledWidth, mDownsampledHeight, FrameBuffer::Attachment::NONE);
314 Texture texture = Texture::New(TextureType::TEXTURE_2D, mPixelFormat, unsigned(mDownsampledWidth), unsigned(mDownsampledHeight));
315 mBloomExtractTarget.AttachColorTexture(texture);
317 FrameBuffer blurExtractTarget = FrameBuffer::New(mDownsampledWidth, mDownsampledHeight, FrameBuffer::Attachment::NONE);
318 texture = Texture::New(TextureType::TEXTURE_2D, mPixelFormat, unsigned(mDownsampledWidth), unsigned(mDownsampledHeight));
319 blurExtractTarget.AttachColorTexture(texture);
321 mOutputRenderTarget = FrameBuffer::New(mTargetSize.width, mTargetSize.height, FrameBuffer::Attachment::NONE);
322 Texture outputTexture = Texture::New(TextureType::TEXTURE_2D, mPixelFormat, unsigned(mTargetSize.width), unsigned(mTargetSize.height));
323 mOutputRenderTarget.AttachColorTexture(outputTexture);
325 //////////////////////////////////////////////////////
326 // Point actors and render tasks at new render targets
328 Renderer bloomRenderer = CreateRenderer(BASIC_VERTEX_SOURCE, SHADER_BLOOM_VIEW_EXTRACT_SHADER_FRAG);
329 SetRendererTexture(bloomRenderer, mRenderTargetForRenderingChildren);
330 mBloomExtractActor.AddRenderer(bloomRenderer);
331 mBloomExtractActor.SetProperty(Actor::Property::SIZE, Vector2(mDownsampledWidth, mDownsampledHeight)); // size needs to match render target
333 // set GaussianBlurView to blur our extracted bloom
334 mGaussianBlurView.SetUserImageAndOutputRenderTarget(mBloomExtractTarget.GetColorTexture(), blurExtractTarget);
336 // use the completed blur in the first buffer and composite with the original child actors render
337 Renderer compositeRenderer = CreateRenderer(BASIC_VERTEX_SOURCE, SHADER_BLOOM_VIEW_COMPOSITE_SHADER_FRAG);
338 SetRendererTexture(compositeRenderer, mRenderTargetForRenderingChildren);
339 TextureSet textureSet = compositeRenderer.GetTextures();
340 textureSet.SetTexture(0u, mRenderTargetForRenderingChildren.GetColorTexture());
341 textureSet.SetTexture(1u, blurExtractTarget.GetColorTexture());
342 mCompositeActor.AddRenderer(compositeRenderer);
344 // set up target actor for rendering result, i.e. the blurred image
345 Renderer targetRenderer = CreateRenderer(BASIC_VERTEX_SOURCE, BASIC_FRAGMENT_SOURCE);
346 SetRendererTexture(targetRenderer, mOutputRenderTarget);
347 mTargetActor.AddRenderer(targetRenderer);
351 void BloomView::CreateRenderTasks()
353 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
355 // create render task to render our child actors to offscreen buffer
356 mRenderChildrenTask = taskList.CreateTask();
357 mRenderChildrenTask.SetSourceActor(mChildrenRoot);
358 mRenderChildrenTask.SetExclusive(true);
359 mRenderChildrenTask.SetInputEnabled(false);
360 mRenderChildrenTask.SetClearEnabled(true);
361 mRenderChildrenTask.SetCameraActor(mRenderFullSizeCamera); // use camera that covers render target exactly
362 mRenderChildrenTask.SetFrameBuffer(mRenderTargetForRenderingChildren);
364 // 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.
365 mBloomExtractTask = taskList.CreateTask();
366 mBloomExtractTask.SetSourceActor(mBloomExtractActor);
367 mBloomExtractTask.SetExclusive(true);
368 mBloomExtractTask.SetInputEnabled(false);
369 mBloomExtractTask.SetClearEnabled(true);
370 mBloomExtractTask.SetCameraActor(mRenderDownsampledCamera);
371 mBloomExtractTask.SetFrameBuffer(mBloomExtractTarget);
373 // GaussianBlurView tasks must be created here, so they are executed in the correct order with respect to BloomView tasks
374 GetImpl(mGaussianBlurView).CreateRenderTasks();
376 // Use an image view displaying the children render and composite it with the blurred bloom buffer, targeting the output
377 mCompositeTask = taskList.CreateTask();
378 mCompositeTask.SetSourceActor(mCompositeActor);
379 mCompositeTask.SetExclusive(true);
380 mCompositeTask.SetInputEnabled(false);
381 mCompositeTask.SetClearEnabled(true);
382 mCompositeTask.SetCameraActor(mRenderFullSizeCamera);
383 mCompositeTask.SetFrameBuffer(mOutputRenderTarget);
386 void BloomView::RemoveRenderTasks()
388 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
390 taskList.RemoveTask(mRenderChildrenTask);
391 taskList.RemoveTask(mBloomExtractTask);
393 GetImpl(mGaussianBlurView).RemoveRenderTasks();
395 taskList.RemoveTask(mCompositeTask);
398 void BloomView::Activate()
400 // make sure resources are allocated and start the render tasks processing
406 void BloomView::Deactivate()
408 // stop render tasks processing
409 // Note: render target resources are automatically freed since we set the Image::Unused flag
412 mRenderTargetForRenderingChildren.Reset();
413 mBloomExtractTarget.Reset();
414 mOutputRenderTarget.Reset();
417 mBloomExtractActor.RemoveRenderer(0u);
418 mTargetActor.RemoveRenderer(0u);
419 mCompositeActor.RemoveRenderer(0u);
421 mGaussianBlurView.SetProperty(Actor::Property::VISIBLE, false);
427 * RecipOneMinusConstraint
429 * f(current, property) = property
431 struct RecipOneMinusConstraint
433 RecipOneMinusConstraint()
437 void operator()(float& current, const PropertyInputContainer& inputs)
439 current = 1.0f / (1.0f - inputs[0]->GetFloat());
443 // 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
444 // internal implementation classes
445 void BloomView::SetupProperties()
447 CustomActor self = Self();
449 ///////////////////////////////////////////
452 // set defaults, makes sure properties are registered with shader
453 mBloomExtractActor.RegisterProperty(BLOOM_THRESHOLD_PROPERTY_NAME, BLOOM_THRESHOLD_DEFAULT);
454 mBloomExtractActor.RegisterProperty(RECIP_ONE_MINUS_BLOOM_THRESHOLD_PROPERTY_NAME, 1.0f / (1.0f - BLOOM_THRESHOLD_DEFAULT));
456 // Register a property that the user can control to change the bloom threshold
457 mBloomThresholdPropertyIndex = self.RegisterProperty(BLOOM_THRESHOLD_PROPERTY_NAME, BLOOM_THRESHOLD_DEFAULT);
458 Property::Index shaderBloomThresholdPropertyIndex = mBloomExtractActor.GetPropertyIndex(BLOOM_THRESHOLD_PROPERTY_NAME);
459 Constraint bloomThresholdConstraint = Constraint::New<float>(mBloomExtractActor, shaderBloomThresholdPropertyIndex, EqualToConstraint());
460 bloomThresholdConstraint.AddSource(Source(self, mBloomThresholdPropertyIndex));
461 bloomThresholdConstraint.Apply();
463 // precalc 1.0 / (1.0 - threshold) on CPU to save shader insns, using constraint to tie to the normal threshold property
464 Property::Index shaderRecipOneMinusBloomThresholdPropertyIndex = mBloomExtractActor.GetPropertyIndex(RECIP_ONE_MINUS_BLOOM_THRESHOLD_PROPERTY_NAME);
465 Constraint thresholdConstraint = Constraint::New<float>(mBloomExtractActor, shaderRecipOneMinusBloomThresholdPropertyIndex, RecipOneMinusConstraint());
466 thresholdConstraint.AddSource(LocalSource(shaderBloomThresholdPropertyIndex));
467 thresholdConstraint.Apply();
469 ////////////////////////////////////////////
472 // Register a property that the user can control to fade the blur in / out via internal GaussianBlurView object
473 mBlurStrengthPropertyIndex = self.RegisterProperty(BLOOM_BLUR_STRENGTH_PROPERTY_NAME, BLOOM_BLUR_STRENGTH_DEFAULT);
474 Constraint blurStrengthConstraint = Constraint::New<float>(mGaussianBlurView, mGaussianBlurView.GetBlurStrengthPropertyIndex(), EqualToConstraint());
475 blurStrengthConstraint.AddSource(Source(self, mBlurStrengthPropertyIndex));
476 blurStrengthConstraint.Apply();
478 ////////////////////////////////////////////
481 // Register a property that the user can control to fade the bloom intensity via internally hidden shader
482 mBloomIntensityPropertyIndex = self.RegisterProperty(BLOOM_INTENSITY_PROPERTY_NAME, BLOOM_INTENSITY_DEFAULT);
483 mCompositeActor.RegisterProperty(BLOOM_INTENSITY_PROPERTY_NAME, BLOOM_INTENSITY_DEFAULT);
484 Property::Index shaderBloomIntensityPropertyIndex = mCompositeActor.GetPropertyIndex(BLOOM_INTENSITY_PROPERTY_NAME);
485 Constraint bloomIntensityConstraint = Constraint::New<float>(mCompositeActor, shaderBloomIntensityPropertyIndex, EqualToConstraint());
486 bloomIntensityConstraint.AddSource(Source(self, mBloomIntensityPropertyIndex));
487 bloomIntensityConstraint.Apply();
489 ////////////////////////////////////////////
492 // Register a property that the user can control to fade the bloom saturation via internally hidden shader
493 mBloomSaturationPropertyIndex = self.RegisterProperty(BLOOM_SATURATION_PROPERTY_NAME, BLOOM_SATURATION_DEFAULT);
494 mCompositeActor.RegisterProperty(BLOOM_SATURATION_PROPERTY_NAME, BLOOM_SATURATION_DEFAULT);
495 Property::Index shaderBloomSaturationPropertyIndex = mCompositeActor.GetPropertyIndex(BLOOM_SATURATION_PROPERTY_NAME);
496 Constraint bloomSaturationConstraint = Constraint::New<float>(mCompositeActor, shaderBloomSaturationPropertyIndex, EqualToConstraint());
497 bloomSaturationConstraint.AddSource(Source(self, mBloomSaturationPropertyIndex));
498 bloomSaturationConstraint.Apply();
500 ////////////////////////////////////////////
503 // Register a property that the user can control to fade the image intensity via internally hidden shader
504 mImageIntensityPropertyIndex = self.RegisterProperty(IMAGE_INTENSITY_PROPERTY_NAME, IMAGE_INTENSITY_DEFAULT);
505 mCompositeActor.RegisterProperty(IMAGE_INTENSITY_PROPERTY_NAME, IMAGE_INTENSITY_DEFAULT);
506 Property::Index shaderImageIntensityPropertyIndex = mCompositeActor.GetPropertyIndex(IMAGE_INTENSITY_PROPERTY_NAME);
507 Constraint imageIntensityConstraint = Constraint::New<float>(mCompositeActor, shaderImageIntensityPropertyIndex, EqualToConstraint());
508 imageIntensityConstraint.AddSource(Source(self, mImageIntensityPropertyIndex));
509 imageIntensityConstraint.Apply();
511 ////////////////////////////////////////////
514 // Register a property that the user can control to fade the image saturation via internally hidden shader
515 mImageSaturationPropertyIndex = self.RegisterProperty(IMAGE_SATURATION_PROPERTY_NAME, IMAGE_SATURATION_DEFAULT);
516 mCompositeActor.RegisterProperty(IMAGE_SATURATION_PROPERTY_NAME, IMAGE_SATURATION_DEFAULT);
517 Property::Index shaderImageSaturationPropertyIndex = mCompositeActor.GetPropertyIndex(IMAGE_SATURATION_PROPERTY_NAME);
518 Constraint imageSaturationConstraint = Constraint::New<float>(mCompositeActor, shaderImageSaturationPropertyIndex, EqualToConstraint());
519 imageSaturationConstraint.AddSource(Source(self, mImageSaturationPropertyIndex));
520 imageSaturationConstraint.Apply();
523 } // namespace Internal
525 } // namespace Toolkit