2 * Copyright (c) 2016 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/public-api/object/type-registry-helper.h>
30 #include <dali/public-api/render-tasks/render-task-list.h>
31 #include <dali/public-api/rendering/renderer.h>
32 #include <dali/devel-api/images/texture-set-image.h>
35 #include <dali-toolkit/public-api/controls/gaussian-blur-view/gaussian-blur-view.h>
36 #include <dali-toolkit/devel-api/controls/bloom-view/bloom-view.h>
37 #include "../gaussian-blur-view/gaussian-blur-view-impl.h"
55 return Toolkit::BloomView::New();
58 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::BloomView, Toolkit::Control, Create )
59 DALI_TYPE_REGISTRATION_END()
62 const float BLOOM_THRESHOLD_DEFAULT = 0.25f;
63 const float BLOOM_BLUR_STRENGTH_DEFAULT = 1.0f;
64 const float BLOOM_INTENSITY_DEFAULT = 1.0f;
65 const float IMAGE_INTENSITY_DEFAULT = 1.0f;
66 const float BLOOM_SATURATION_DEFAULT = 1.0f;
67 const float IMAGE_SATURATION_DEFAULT = 1.0f;
70 const unsigned int BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_NUM_SAMPLES = 5;
71 const float BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_BLUR_BELL_CURVE_WIDTH = 1.5f;
72 const Pixel::Format BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_RENDER_TARGET_PIXEL_FORMAT = Pixel::RGBA8888;
73 const float BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_BLUR_FADE_IN = 1.0f; // default, fully blurred
74 const float BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_WIDTH_SCALE = 0.5f;
75 const float BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_HEIGHT_SCALE = 0.5f;
77 const float ARBITRARY_FIELD_OF_VIEW = Math::PI / 4.0f;
79 const char* const BLOOM_BLUR_STRENGTH_PROPERTY_NAME = "BlurStrengthProperty";
80 const char* const BLOOM_THRESHOLD_PROPERTY_NAME = "uBloomThreshold";
81 const char* const RECIP_ONE_MINUS_BLOOM_THRESHOLD_PROPERTY_NAME = "uRecipOneMinusBloomThreshold";
82 const char* const BLOOM_INTENSITY_PROPERTY_NAME = "uBloomIntensity";
83 const char* const BLOOM_SATURATION_PROPERTY_NAME = "uBloomSaturation";
84 const char* const IMAGE_INTENSITY_PROPERTY_NAME = "uImageIntensity";
85 const char* const IMAGE_SATURATION_PROPERTY_NAME = "uImageSaturation";
87 ///////////////////////////////////////////////////////
92 const char* const BLOOM_EXTRACT_FRAGMENT_SOURCE =
93 "varying mediump vec2 vTexCoord;\n"
94 "uniform sampler2D sTexture;\n"
95 "uniform lowp vec4 uColor;\n"
96 "uniform mediump float uBloomThreshold;\n"
97 "uniform mediump float uRecipOneMinusBloomThreshold;\n"
100 " mediump vec4 col;\n"
101 " col = texture2D(sTexture, vTexCoord);\n"
102 " col = (col - uBloomThreshold) * uRecipOneMinusBloomThreshold;\n" // remove intensities lower than the thresold and remap intensities above the threshold to [0..1]
103 " gl_FragColor = clamp(col, 0.0, 1.0);\n"
106 const char* const COMPOSITE_FRAGMENT_SOURCE =
107 "precision mediump float;\n"
108 "varying mediump vec2 vTexCoord;\n"
109 "uniform sampler2D sTexture;\n"
110 "uniform sampler2D sEffect;\n"
111 "uniform lowp vec4 uColor;\n"
112 "uniform float uBloomIntensity;\n"
113 "uniform float uImageIntensity;\n"
114 "uniform float uBloomSaturation;\n"
115 "uniform float uImageSaturation;\n"
117 "vec4 ChangeSaturation(vec4 col, float sat)\n"
119 " float grey = dot(col.rgb, vec3(0.3, 0.6, 0.1));\n"
120 " return mix(vec4(grey, grey, grey, 1.0), col, sat);\n"
125 " mediump vec4 image;\n"
126 " mediump vec4 bloom;\n"
127 " image = texture2D(sTexture, vTexCoord);\n"
128 " bloom = texture2D(sEffect, vTexCoord);\n"
129 " image = ChangeSaturation(image, uImageSaturation) * uImageIntensity;\n"
130 " bloom = ChangeSaturation(bloom, uBloomSaturation) * uBloomIntensity;\n"
131 " image *= 1.0 - clamp(bloom, 0.0, 1.0);\n" // darken base where bloom is strong, to prevent excessive burn-out of result
132 " gl_FragColor = image + bloom;\n"
139 BloomView::BloomView()
140 : Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) )
141 , mBlurNumSamples(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_NUM_SAMPLES)
142 , mBlurBellCurveWidth(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_BLUR_BELL_CURVE_WIDTH)
143 , mPixelFormat(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_RENDER_TARGET_PIXEL_FORMAT)
144 , mDownsampleWidthScale(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_WIDTH_SCALE)
145 , mDownsampleHeightScale(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_HEIGHT_SCALE)
146 , mDownsampledWidth( 0.0f )
147 , mDownsampledHeight( 0.0f )
148 , mTargetSize(Vector2::ZERO)
149 , mLastSize(Vector2::ZERO)
150 , mChildrenRoot(Actor::New())
151 , mInternalRoot(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 , mInternalRoot(Actor::New())
176 , mBloomThresholdPropertyIndex(Property::INVALID_INDEX)
177 , mBlurStrengthPropertyIndex(Property::INVALID_INDEX)
178 , mBloomIntensityPropertyIndex(Property::INVALID_INDEX)
179 , mBloomSaturationPropertyIndex(Property::INVALID_INDEX)
180 , mImageIntensityPropertyIndex(Property::INVALID_INDEX)
181 , mImageSaturationPropertyIndex(Property::INVALID_INDEX)
182 , mActivated( false )
186 BloomView::~BloomView()
190 Toolkit::BloomView BloomView::New()
192 BloomView* impl = new BloomView();
194 Dali::Toolkit::BloomView handle = Dali::Toolkit::BloomView( *impl );
196 // Second-phase init of the implementation
197 // This can only be done after the CustomActor connection has been made...
203 Toolkit::BloomView BloomView::New(const unsigned int blurNumSamples, const float blurBellCurveWidth, const Pixel::Format renderTargetPixelFormat,
204 const float downsampleWidthScale, const float downsampleHeightScale)
206 BloomView* impl = new BloomView( blurNumSamples, blurBellCurveWidth, renderTargetPixelFormat, downsampleWidthScale, downsampleHeightScale);
208 Dali::Toolkit::BloomView handle = Dali::Toolkit::BloomView( *impl );
210 // Second-phase init of the implementation
211 // This can only be done after the CustomActor connection has been made...
217 ///////////////////////////////////////////////////////////
222 void BloomView::OnInitialize()
224 // root actor to parent all user added actors, needed to allow us to set that subtree as exclusive for our child render task
225 mChildrenRoot.SetParentOrigin( ParentOrigin::CENTER );
226 mInternalRoot.SetParentOrigin( ParentOrigin::CENTER );
228 //////////////////////////////////////////////////////
231 // Create an image view for rendering from the scene texture to the bloom texture
232 mBloomExtractImageView = Toolkit::ImageView::New();
233 mBloomExtractImageView.SetParentOrigin( ParentOrigin::CENTER );
235 // Create an image view for compositing the result (scene and bloom textures) to output
236 mCompositeImageView = Toolkit::ImageView::New();
237 mCompositeImageView.SetParentOrigin( ParentOrigin::CENTER );
239 // 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
240 mTargetImageView = Toolkit::ImageView::New();
241 mTargetImageView.SetParentOrigin( ParentOrigin::CENTER );
243 // Create the Gaussian Blur object + render tasks
244 // 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
245 // render targets etc internally, so we make better use of resources
246 // Note, this also internally creates the render tasks used by the Gaussian blur, this must occur after the bloom extraction and before the compositing
247 mGaussianBlurView = Dali::Toolkit::GaussianBlurView::New(mBlurNumSamples, mBlurBellCurveWidth, mPixelFormat, mDownsampleWidthScale, mDownsampleHeightScale, true);
248 mGaussianBlurView.SetParentOrigin( ParentOrigin::CENTER );
251 //////////////////////////////////////////////////////
252 // Create cameras for the renders corresponding to the (potentially downsampled) render targets' size
253 mRenderDownsampledCamera = CameraActor::New();
254 mRenderDownsampledCamera.SetParentOrigin(ParentOrigin::CENTER);
255 mRenderDownsampledCamera.SetInvertYAxis( true );
257 mRenderFullSizeCamera = CameraActor::New();
258 mRenderFullSizeCamera.SetParentOrigin(ParentOrigin::CENTER);
259 mRenderFullSizeCamera.SetInvertYAxis( true );
262 ////////////////////////////////
263 // Connect to actor tree
264 Self().Add( mChildrenRoot );
265 Self().Add( mInternalRoot );
266 mInternalRoot.Add( mBloomExtractImageView );
267 mInternalRoot.Add( mGaussianBlurView );
268 mInternalRoot.Add( mCompositeImageView );
269 mInternalRoot.Add( mTargetImageView );
270 mInternalRoot.Add( mRenderDownsampledCamera );
271 mInternalRoot.Add( mRenderFullSizeCamera );
273 // bind properties for / set shader constants to defaults
277 void BloomView::OnSizeSet(const Vector3& targetSize)
279 Control::OnSizeSet( targetSize );
281 mTargetSize = Vector2(targetSize);
282 mChildrenRoot.SetSize(targetSize);
283 mCompositeImageView.SetSize(targetSize);
284 mTargetImageView.SetSize(targetSize);
286 // Children render camera must move when GaussianBlurView object is
287 // resized. This is since we cannot change render target size - so we need
288 // to remap the child actors' rendering accordingly so they still exactly
289 // fill the render target. Note that this means the effective resolution of
290 // the child render changes as the GaussianBlurView object changes size,
291 // this is the trade off for not being able to modify render target size
292 // Change camera z position based on GaussianBlurView actor height
293 float cameraPosConstraintScale = 0.5f / tanf(ARBITRARY_FIELD_OF_VIEW * 0.5f);
294 mRenderFullSizeCamera.SetZ( mTargetSize.height * cameraPosConstraintScale);
296 // if we have already activated the blur, need to update render target sizes now to reflect the new size of this actor
304 void BloomView::OnChildAdd( Actor& child )
306 Control::OnChildAdd( child );
308 if( child != mChildrenRoot && child != mInternalRoot)
310 mChildrenRoot.Add( child );
314 void BloomView::OnChildRemove( Actor& child )
316 mChildrenRoot.Remove( child );
318 Control::OnChildRemove( child );
321 void BloomView::AllocateResources()
323 // size of render targets etc is based on the size of this actor, ignoring z
324 if(mTargetSize != mLastSize || !mActivated)
326 mLastSize = mTargetSize;
328 // get size of downsampled render targets
329 mDownsampledWidth = mTargetSize.width * mDownsampleWidthScale;
330 mDownsampledHeight = mTargetSize.height * mDownsampleHeightScale;
333 //////////////////////////////////////////////////////
336 // Create and place a camera for the renders corresponding to the (potentially downsampled) render targets' size
337 mRenderDownsampledCamera.SetFieldOfView(ARBITRARY_FIELD_OF_VIEW);
338 // 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
339 mRenderDownsampledCamera.SetNearClippingPlane(1.0f);
340 mRenderDownsampledCamera.SetAspectRatio(mDownsampledWidth / mDownsampledHeight);
341 mRenderDownsampledCamera.SetType(Dali::Camera::FREE_LOOK); // camera orientation based solely on actor
343 mRenderDownsampledCamera.SetPosition(0.0f, 0.0f, ((mDownsampledHeight * 0.5f) / tanf(ARBITRARY_FIELD_OF_VIEW * 0.5f)));
345 // Create and place a camera for the children render, corresponding to its render target size
346 mRenderFullSizeCamera.SetFieldOfView(ARBITRARY_FIELD_OF_VIEW);
347 // 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
348 mRenderFullSizeCamera.SetNearClippingPlane(1.0f);
349 mRenderFullSizeCamera.SetAspectRatio(mTargetSize.width / mTargetSize.height);
350 mRenderFullSizeCamera.SetType(Dali::Camera::FREE_LOOK); // camera orientation based solely on actor
352 float cameraPosConstraintScale = 0.5f / tanf(ARBITRARY_FIELD_OF_VIEW * 0.5f);
353 mRenderFullSizeCamera.SetPosition(0.0f, 0.0f, mTargetSize.height * cameraPosConstraintScale);
355 //////////////////////////////////////////////////////
356 // Pass size change onto GaussianBlurView, so it matches
357 mGaussianBlurView.SetSize(mTargetSize);
358 GetImpl(mGaussianBlurView).AllocateResources();
361 //////////////////////////////////////////////////////
362 // Create render targets
364 // create off screen buffer of new size to render our child actors to
365 mRenderTargetForRenderingChildren = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat, Dali::Image::UNUSED );
366 mBloomExtractTarget = FrameBufferImage::New( mDownsampledWidth, mDownsampledHeight, mPixelFormat, Dali::Image::UNUSED );
367 FrameBufferImage mBlurExtractTarget = FrameBufferImage::New( mDownsampledWidth, mDownsampledHeight, mPixelFormat, Dali::Image::UNUSED );
368 mOutputRenderTarget = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat, Dali::Image::UNUSED);
371 //////////////////////////////////////////////////////
372 // Point actors and render tasks at new render targets
374 mBloomExtractImageView.SetImage( mRenderTargetForRenderingChildren );
375 mBloomExtractImageView.SetSize(mDownsampledWidth, mDownsampledHeight); // size needs to match render target
376 // Create shader used for extracting the bright parts of an image
377 Property::Map customShader;
378 customShader[ "fragmentShader" ] = BLOOM_EXTRACT_FRAGMENT_SOURCE;
379 Property::Map rendererMap;
380 rendererMap.Insert( "shader", customShader );
381 mBloomExtractImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap );
383 // set GaussianBlurView to blur our extracted bloom
384 mGaussianBlurView.SetUserImageAndOutputRenderTarget(mBloomExtractTarget, mBlurExtractTarget);
386 // use the completed blur in the first buffer and composite with the original child actors render
387 mCompositeImageView.SetImage( mRenderTargetForRenderingChildren );
388 // Create shader used to composite bloom and original image to output render target
389 customShader[ "fragmentShader" ] = COMPOSITE_FRAGMENT_SOURCE;
390 rendererMap[ "shader" ] = customShader;
391 mCompositeImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap );
392 TextureSet textureSet = mCompositeImageView.GetRendererAt(0).GetTextures();
393 TextureSetImage( textureSet, 1u, mBlurExtractTarget );
395 // set up target actor for rendering result, i.e. the blurred image
396 mTargetImageView.SetImage(mOutputRenderTarget);
400 void BloomView::CreateRenderTasks()
402 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
404 // create render task to render our child actors to offscreen buffer
405 mRenderChildrenTask = taskList.CreateTask();
406 mRenderChildrenTask.SetSourceActor( mChildrenRoot );
407 mRenderChildrenTask.SetExclusive(true);
408 mRenderChildrenTask.SetInputEnabled( false );
409 mRenderChildrenTask.SetClearEnabled( true );
410 mRenderChildrenTask.SetCameraActor(mRenderFullSizeCamera); // use camera that covers render target exactly
411 mRenderChildrenTask.SetTargetFrameBuffer( mRenderTargetForRenderingChildren );
413 // 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.
414 mBloomExtractTask = taskList.CreateTask();
415 mBloomExtractTask.SetSourceActor( mBloomExtractImageView );
416 mBloomExtractTask.SetExclusive(true);
417 mBloomExtractTask.SetInputEnabled( false );
418 mBloomExtractTask.SetClearEnabled( true );
419 mBloomExtractTask.SetCameraActor(mRenderDownsampledCamera);
420 mBloomExtractTask.SetTargetFrameBuffer( mBloomExtractTarget );
422 // GaussianBlurView tasks must be created here, so they are executed in the correct order with respect to BloomView tasks
423 GetImpl(mGaussianBlurView).CreateRenderTasks();
425 // Use an image view displaying the children render and composite it with the blurred bloom buffer, targeting the output
426 mCompositeTask = taskList.CreateTask();
427 mCompositeTask.SetSourceActor( mCompositeImageView );
428 mCompositeTask.SetExclusive(true);
429 mCompositeTask.SetInputEnabled( false );
430 mCompositeTask.SetClearEnabled( true );
431 mCompositeTask.SetCameraActor(mRenderFullSizeCamera);
432 mCompositeTask.SetTargetFrameBuffer( mOutputRenderTarget );
435 void BloomView::RemoveRenderTasks()
437 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
439 taskList.RemoveTask(mRenderChildrenTask);
440 taskList.RemoveTask(mBloomExtractTask);
442 GetImpl(mGaussianBlurView).RemoveRenderTasks();
444 taskList.RemoveTask(mCompositeTask);
447 void BloomView::Activate()
449 // make sure resources are allocated and start the render tasks processing
455 void BloomView::Deactivate()
457 // stop render tasks processing
458 // Note: render target resources are automatically freed since we set the Image::Unused flag
460 mRenderTargetForRenderingChildren.Reset();
461 mBloomExtractTarget.Reset();
462 mOutputRenderTarget.Reset();
467 * RecipOneMinusConstraint
469 * f(current, property) = property
471 struct RecipOneMinusConstraint
473 RecipOneMinusConstraint(){}
475 void operator()( float& current, const PropertyInputContainer& inputs )
477 current = 1.0f / ( 1.0f - inputs[0]->GetFloat() );
481 // 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
482 // internal implementation classes
483 void BloomView::SetupProperties()
485 CustomActor self = Self();
488 ///////////////////////////////////////////
491 // set defaults, makes sure properties are registered with shader
492 mBloomExtractImageView.RegisterProperty( BLOOM_THRESHOLD_PROPERTY_NAME, BLOOM_THRESHOLD_DEFAULT );
493 mBloomExtractImageView.RegisterProperty( RECIP_ONE_MINUS_BLOOM_THRESHOLD_PROPERTY_NAME, 1.0f / (1.0f - BLOOM_THRESHOLD_DEFAULT) );
495 // Register a property that the user can control to change the bloom threshold
496 mBloomThresholdPropertyIndex = self.RegisterProperty(BLOOM_THRESHOLD_PROPERTY_NAME, BLOOM_THRESHOLD_DEFAULT);
497 Property::Index shaderBloomThresholdPropertyIndex = mBloomExtractImageView.GetPropertyIndex(BLOOM_THRESHOLD_PROPERTY_NAME);
498 Constraint bloomThresholdConstraint = Constraint::New<float>( mBloomExtractImageView, shaderBloomThresholdPropertyIndex, EqualToConstraint());
499 bloomThresholdConstraint.AddSource( Source(self, mBloomThresholdPropertyIndex) );
500 bloomThresholdConstraint.Apply();
502 // precalc 1.0 / (1.0 - threshold) on CPU to save shader insns, using constraint to tie to the normal threshold property
503 Property::Index shaderRecipOneMinusBloomThresholdPropertyIndex = mBloomExtractImageView.GetPropertyIndex(RECIP_ONE_MINUS_BLOOM_THRESHOLD_PROPERTY_NAME);
504 Constraint thresholdConstraint = Constraint::New<float>( mBloomExtractImageView, shaderRecipOneMinusBloomThresholdPropertyIndex, RecipOneMinusConstraint());
505 thresholdConstraint.AddSource( LocalSource(shaderBloomThresholdPropertyIndex) );
506 thresholdConstraint.Apply();
509 ////////////////////////////////////////////
512 // Register a property that the user can control to fade the blur in / out via internal GaussianBlurView object
513 mBlurStrengthPropertyIndex = self.RegisterProperty(BLOOM_BLUR_STRENGTH_PROPERTY_NAME, BLOOM_BLUR_STRENGTH_DEFAULT);
514 Constraint blurStrengthConstraint = Constraint::New<float>( mGaussianBlurView, mGaussianBlurView.GetBlurStrengthPropertyIndex(), EqualToConstraint());
515 blurStrengthConstraint.AddSource( Source(self, mBlurStrengthPropertyIndex) );
516 blurStrengthConstraint.Apply();
519 ////////////////////////////////////////////
522 // Register a property that the user can control to fade the bloom intensity via internally hidden shader
523 mBloomIntensityPropertyIndex = self.RegisterProperty(BLOOM_INTENSITY_PROPERTY_NAME, BLOOM_INTENSITY_DEFAULT);
524 mCompositeImageView.RegisterProperty( BLOOM_INTENSITY_PROPERTY_NAME, BLOOM_INTENSITY_DEFAULT );
525 Property::Index shaderBloomIntensityPropertyIndex = mCompositeImageView.GetPropertyIndex(BLOOM_INTENSITY_PROPERTY_NAME);
526 Constraint bloomIntensityConstraint = Constraint::New<float>( mCompositeImageView, shaderBloomIntensityPropertyIndex, EqualToConstraint());
527 bloomIntensityConstraint.AddSource( Source(self, mBloomIntensityPropertyIndex) );
528 bloomIntensityConstraint.Apply();
531 ////////////////////////////////////////////
534 // Register a property that the user can control to fade the bloom saturation via internally hidden shader
535 mBloomSaturationPropertyIndex = self.RegisterProperty(BLOOM_SATURATION_PROPERTY_NAME, BLOOM_SATURATION_DEFAULT);
536 mCompositeImageView.RegisterProperty( BLOOM_SATURATION_PROPERTY_NAME, BLOOM_SATURATION_DEFAULT );
537 Property::Index shaderBloomSaturationPropertyIndex = mCompositeImageView.GetPropertyIndex(BLOOM_SATURATION_PROPERTY_NAME);
538 Constraint bloomSaturationConstraint = Constraint::New<float>( mCompositeImageView, shaderBloomSaturationPropertyIndex, EqualToConstraint());
539 bloomSaturationConstraint.AddSource( Source(self, mBloomSaturationPropertyIndex) );
540 bloomSaturationConstraint.Apply();
543 ////////////////////////////////////////////
546 // Register a property that the user can control to fade the image intensity via internally hidden shader
547 mImageIntensityPropertyIndex = self.RegisterProperty(IMAGE_INTENSITY_PROPERTY_NAME, IMAGE_INTENSITY_DEFAULT);
548 mCompositeImageView.RegisterProperty( IMAGE_INTENSITY_PROPERTY_NAME, IMAGE_INTENSITY_DEFAULT );
549 Property::Index shaderImageIntensityPropertyIndex = mCompositeImageView.GetPropertyIndex(IMAGE_INTENSITY_PROPERTY_NAME);
550 Constraint imageIntensityConstraint = Constraint::New<float>( mCompositeImageView, shaderImageIntensityPropertyIndex, EqualToConstraint());
551 imageIntensityConstraint.AddSource( Source(self, mImageIntensityPropertyIndex) );
552 imageIntensityConstraint.Apply();
555 ////////////////////////////////////////////
558 // Register a property that the user can control to fade the image saturation via internally hidden shader
559 mImageSaturationPropertyIndex = self.RegisterProperty(IMAGE_SATURATION_PROPERTY_NAME, IMAGE_SATURATION_DEFAULT);
560 mCompositeImageView.RegisterProperty( IMAGE_SATURATION_PROPERTY_NAME, IMAGE_SATURATION_DEFAULT );
561 Property::Index shaderImageSaturationPropertyIndex = mCompositeImageView.GetPropertyIndex(IMAGE_SATURATION_PROPERTY_NAME);
562 Constraint imageSaturationConstraint = Constraint::New<float>( mCompositeImageView, shaderImageSaturationPropertyIndex, EqualToConstraint());
563 imageSaturationConstraint.AddSource( Source(self, mImageSaturationPropertyIndex) );
564 imageSaturationConstraint.Apply();
567 } // namespace Internal
569 } // namespace Toolkit