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"
20 #include "../gaussian-blur-view/gaussian-blur-view-impl.h"
25 #include <dali/public-api/animation/constraints.h>
26 #include <dali/public-api/common/stage.h>
27 #include <dali/public-api/object/type-registry.h>
28 #include <dali/public-api/render-tasks/render-task-list.h>
31 #include <dali-toolkit/public-api/controls/gaussian-blur-view/gaussian-blur-view.h>
32 #include <dali-toolkit/public-api/controls/bloom-view/bloom-view.h>
50 return Toolkit::BloomView::New();
53 TypeRegistration mType( typeid(Toolkit::BloomView), typeid(Toolkit::Control), Create );
56 const float BLOOM_THRESHOLD_DEFAULT = 0.25f;
57 const float BLOOM_BLUR_STRENGTH_DEFAULT = 1.0f;
58 const float BLOOM_INTENSITY_DEFAULT = 1.0f;
59 const float IMAGE_INTENSITY_DEFAULT = 1.0f;
60 const float BLOOM_SATURATION_DEFAULT = 1.0f;
61 const float IMAGE_SATURATION_DEFAULT = 1.0f;
64 const unsigned int BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_NUM_SAMPLES = 5;
65 const float BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_BLUR_BELL_CURVE_WIDTH = 1.5f;
66 const Pixel::Format BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_RENDER_TARGET_PIXEL_FORMAT = Pixel::RGBA8888;
67 const float BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_BLUR_FADE_IN = 1.0f; // default, fully blurred
68 const float BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_WIDTH_SCALE = 0.5f;
69 const float BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_HEIGHT_SCALE = 0.5f;
71 const float ARBITRARY_FIELD_OF_VIEW = Math::PI / 4.0f;
73 const std::string BLOOM_BLUR_STRENGTH_PROPERTY_NAME( "BlurStrengthProperty" );
75 const std::string BLOOM_THRESHOLD_PROPERTY_NAME( "uBloomThreshold" );
76 const std::string RECIP_ONE_MINUS_BLOOM_THRESHOLD_PROPERTY_NAME( "uRecipOneMinusBloomThreshold" );
77 const std::string BLOOM_INTENSITY_PROPERTY_NAME( "uBloomIntensity" );
78 const std::string BLOOM_SATURATION_PROPERTY_NAME( "uBloomSaturation" );
79 const std::string IMAGE_INTENSITY_PROPERTY_NAME( "uImageIntensity" );
80 const std::string IMAGE_SATURATION_PROPERTY_NAME( "uImageSaturation" );
82 ///////////////////////////////////////////////////////
87 const char* const BLOOM_EXTRACT_FRAGMENT_SOURCE =
88 "uniform float uBloomThreshold;\n"
89 "uniform float uRecipOneMinusBloomThreshold;\n"
92 " mediump vec4 col;\n"
93 " col = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y));\n"
94 " col = (col - uBloomThreshold) * uRecipOneMinusBloomThreshold;\n" // remove intensities lower than the thresold and remap intensities above the threshold to [0..1]
95 " gl_FragColor = clamp(col, 0.0, 1.0);\n"
98 const char* const COMPOSITE_FRAGMENT_SOURCE =
99 "uniform float uBloomIntensity;\n"
100 "uniform float uImageIntensity;\n"
101 "uniform float uBloomSaturation;\n"
102 "uniform float uImageSaturation;\n"
104 "vec4 ChangeSaturation(vec4 col, float sat)\n"
106 " float grey = dot(col.rgb, vec3(0.3, 0.6, 0.1));\n"
107 " return mix(vec4(grey, grey, grey, 1.0), col, sat);\n"
112 " mediump vec4 image;\n"
113 " mediump vec4 bloom;\n"
114 " image = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y));\n"
115 " bloom = texture2D(sEffect, vec2(vTexCoord.x, vTexCoord.y));\n"
116 " image = ChangeSaturation(image, uImageSaturation) * uImageIntensity;\n"
117 " bloom = ChangeSaturation(bloom, uBloomSaturation) * uBloomIntensity;\n"
118 " image *= 1.0 - clamp(bloom, 0.0, 1.0);\n" // darken base where bloom is strong, to prevent excessive burn-out of result
119 " gl_FragColor = image + bloom;\n"
126 BloomView::BloomView()
127 : Control( CONTROL_BEHAVIOUR_NONE )
128 , mBlurNumSamples(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_NUM_SAMPLES)
129 , mBlurBellCurveWidth(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_BLUR_BELL_CURVE_WIDTH)
130 , mPixelFormat(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_RENDER_TARGET_PIXEL_FORMAT)
131 , mDownsampleWidthScale(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_WIDTH_SCALE)
132 , mDownsampleHeightScale(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_HEIGHT_SCALE)
133 , mDownsampledWidth( 0.0f )
134 , mDownsampledHeight( 0.0f )
135 , mTargetSize(Vector2::ZERO)
136 , mLastSize(Vector2::ZERO)
137 , mChildrenRoot(Actor::New())
138 , mBloomThresholdPropertyIndex(Property::INVALID_INDEX)
139 , mBlurStrengthPropertyIndex(Property::INVALID_INDEX)
140 , mBloomIntensityPropertyIndex(Property::INVALID_INDEX)
141 , mBloomSaturationPropertyIndex(Property::INVALID_INDEX)
142 , mImageIntensityPropertyIndex(Property::INVALID_INDEX)
143 , mImageSaturationPropertyIndex(Property::INVALID_INDEX)
147 BloomView::BloomView( const unsigned int blurNumSamples, const float blurBellCurveWidth, const Pixel::Format renderTargetPixelFormat,
148 const float downsampleWidthScale, const float downsampleHeightScale)
149 : Control( CONTROL_BEHAVIOUR_NONE )
150 , mBlurNumSamples(blurNumSamples)
151 , mBlurBellCurveWidth(blurBellCurveWidth)
152 , mPixelFormat(renderTargetPixelFormat)
153 , mDownsampleWidthScale(downsampleWidthScale)
154 , mDownsampleHeightScale(downsampleHeightScale)
155 , mDownsampledWidth( 0.0f )
156 , mDownsampledHeight( 0.0f )
157 , mTargetSize(Vector2::ZERO)
158 , mLastSize(Vector2::ZERO)
159 , mChildrenRoot(Actor::New())
160 , mBloomThresholdPropertyIndex(Property::INVALID_INDEX)
161 , mBlurStrengthPropertyIndex(Property::INVALID_INDEX)
162 , mBloomIntensityPropertyIndex(Property::INVALID_INDEX)
163 , mBloomSaturationPropertyIndex(Property::INVALID_INDEX)
164 , mImageIntensityPropertyIndex(Property::INVALID_INDEX)
165 , mImageSaturationPropertyIndex(Property::INVALID_INDEX)
169 BloomView::~BloomView()
173 Toolkit::BloomView BloomView::New()
175 BloomView* impl = new BloomView();
177 Dali::Toolkit::BloomView handle = Dali::Toolkit::BloomView( *impl );
179 // Second-phase init of the implementation
180 // This can only be done after the CustomActor connection has been made...
186 Toolkit::BloomView BloomView::New(const unsigned int blurNumSamples, const float blurBellCurveWidth, const Pixel::Format renderTargetPixelFormat,
187 const float downsampleWidthScale, const float downsampleHeightScale)
189 BloomView* impl = new BloomView( blurNumSamples, blurBellCurveWidth, renderTargetPixelFormat, downsampleWidthScale, downsampleHeightScale);
191 Dali::Toolkit::BloomView handle = Dali::Toolkit::BloomView( *impl );
193 // Second-phase init of the implementation
194 // This can only be done after the CustomActor connection has been made...
200 /////////////////////////////////////////////////////////////
201 // 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
202 // 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.
203 void BloomView::Add(Actor child)
205 mChildrenRoot.Add(child);
208 void BloomView::Remove(Actor child)
210 mChildrenRoot.Remove(child);
218 ///////////////////////////////////////////////////////////
223 void BloomView::OnInitialize()
225 // root actor to parent all user added actors, needed to allow us to set that subtree as exclusive for our child render task
226 mChildrenRoot.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
228 //////////////////////////////////////////////////////
231 // Create shader used for extracting the bright parts of an image
232 mBloomExtractShader = ShaderEffect::New( "", BLOOM_EXTRACT_FRAGMENT_SOURCE );
234 // Create shader used to composite bloom and original image to output render target
235 mCompositeShader = ShaderEffect::New( "", COMPOSITE_FRAGMENT_SOURCE );
238 //////////////////////////////////////////////////////
241 // Create an ImageActor for rendering from the scene texture to the bloom texture
242 mBloomExtractImageActor = ImageActor::New();
243 mBloomExtractImageActor.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
244 mBloomExtractImageActor.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME
245 mBloomExtractImageActor.SetShaderEffect( mBloomExtractShader );
247 // Create an ImageActor for compositing the result (scene and bloom textures) to output
248 mCompositeImageActor = ImageActor::New();
249 mCompositeImageActor.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
250 mCompositeImageActor.SetShaderEffect( mCompositeShader );
251 mCompositeImageActor.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME
253 // Create an ImageActor for holding final result, i.e. the blurred image. This will get rendered to screen later, via default / user render task
254 mTargetImageActor = ImageActor::New();
255 mTargetImageActor.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
256 mTargetImageActor.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME
259 // Create the Gaussian Blur object + render tasks
260 // 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
261 // render targets etc internally, so we make better use of resources
262 // Note, this also internally creates the render tasks used by the Gaussian blur, this must occur after the bloom extraction and before the compositing
263 mGaussianBlurView = Dali::Toolkit::GaussianBlurView::New(mBlurNumSamples, mBlurBellCurveWidth, mPixelFormat, mDownsampleWidthScale, mDownsampleHeightScale, true);
264 mGaussianBlurView.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
267 //////////////////////////////////////////////////////
268 // Create cameras for the renders corresponding to the (potentially downsampled) render targets' size
269 mRenderDownsampledCamera = CameraActor::New();
270 mRenderDownsampledCamera.SetParentOrigin(ParentOrigin::CENTER);
272 mRenderFullSizeCamera = CameraActor::New();
273 mRenderFullSizeCamera.SetParentOrigin(ParentOrigin::CENTER);
276 ////////////////////////////////
277 // Connect to actor tree
278 Self().Add( mChildrenRoot );
279 Self().Add( mBloomExtractImageActor );
280 Self().Add( mGaussianBlurView );
281 Self().Add( mCompositeImageActor );
282 Self().Add( mTargetImageActor );
283 Self().Add( mRenderDownsampledCamera );
284 Self().Add( mRenderFullSizeCamera );
286 // bind properties for / set shader constants to defaults
290 void BloomView::OnControlSizeSet(const Vector3& targetSize)
292 mTargetSize = Vector2(targetSize);
293 mChildrenRoot.SetSize(targetSize);
294 mCompositeImageActor.SetSize(targetSize);
295 mTargetImageActor.SetSize(targetSize);
297 // Children render camera must move when GaussianBlurView object is
298 // resized. This is since we cannot change render target size - so we need
299 // to remap the child actors' rendering accordingly so they still exactly
300 // fill the render target. Note that this means the effective resolution of
301 // the child render changes as the GaussianBlurView object changes size,
302 // this is the trade off for not being able to modify render target size
303 // Change camera z position based on GaussianBlurView actor height
304 float cameraPosConstraintScale = 0.5f / tanf(ARBITRARY_FIELD_OF_VIEW * 0.5f);
305 mRenderFullSizeCamera.SetZ( mTargetSize.height * cameraPosConstraintScale);
307 // if we are already on stage, need to update render target sizes now to reflect the new size of this actor
314 void BloomView::AllocateResources()
316 // size of render targets etc is based on the size of this actor, ignoring z
317 if(mTargetSize != mLastSize)
319 mLastSize = mTargetSize;
321 // get size of downsampled render targets
322 mDownsampledWidth = mTargetSize.width * mDownsampleWidthScale;
323 mDownsampledHeight = mTargetSize.height * mDownsampleHeightScale;
326 //////////////////////////////////////////////////////
329 // Create and place a camera for the renders corresponding to the (potentially downsampled) render targets' size
330 mRenderDownsampledCamera.SetFieldOfView(ARBITRARY_FIELD_OF_VIEW);
331 // 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
332 mRenderDownsampledCamera.SetNearClippingPlane(1.0f);
333 mRenderDownsampledCamera.SetAspectRatio(mDownsampledWidth / mDownsampledHeight);
334 mRenderDownsampledCamera.SetType(Dali::Camera::FREE_LOOK); // camera orientation based solely on actor
335 mRenderDownsampledCamera.SetRotation(Quaternion(M_PI, Vector3::YAXIS)); // Rotate to look at origin
337 mRenderDownsampledCamera.SetPosition(0.0f, 0.0f, ((mDownsampledHeight * 0.5f) / tanf(ARBITRARY_FIELD_OF_VIEW * 0.5f)));
339 // Create and place a camera for the children render, corresponding to its render target size
340 mRenderFullSizeCamera.SetFieldOfView(ARBITRARY_FIELD_OF_VIEW);
341 // 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
342 mRenderFullSizeCamera.SetNearClippingPlane(1.0f);
343 mRenderFullSizeCamera.SetAspectRatio(mTargetSize.width / mTargetSize.height);
344 mRenderFullSizeCamera.SetType(Dali::Camera::FREE_LOOK); // camera orientation based solely on actor
345 mRenderFullSizeCamera.SetRotation(Quaternion(M_PI, Vector3::YAXIS)); // Rotate to look at origin
347 float cameraPosConstraintScale = 0.5f / tanf(ARBITRARY_FIELD_OF_VIEW * 0.5f);
348 mRenderFullSizeCamera.SetPosition(0.0f, 0.0f, mTargetSize.height * cameraPosConstraintScale);
350 //////////////////////////////////////////////////////
351 // Pass size change onto GaussianBlurView, so it matches
352 mGaussianBlurView.SetSize(mTargetSize);
353 GetImpl(mGaussianBlurView).AllocateResources();
356 //////////////////////////////////////////////////////
357 // Create render targets
359 // create off screen buffer of new size to render our child actors to
360 mRenderTargetForRenderingChildren = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat, Dali::Image::Unused );
361 mBloomExtractTarget = FrameBufferImage::New( mDownsampledWidth, mDownsampledHeight, mPixelFormat, Dali::Image::Unused );
362 mOutputRenderTarget = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat, Dali::Image::Unused );
365 //////////////////////////////////////////////////////
366 // Point actors and render tasks at new render targets
368 mBloomExtractImageActor.SetImage( mRenderTargetForRenderingChildren );
369 mBloomExtractImageActor.SetSize(mDownsampledWidth, mDownsampledHeight); // size needs to match render target
371 // set GaussianBlurView to blur our extracted bloom
372 mGaussianBlurView.SetUserImageAndOutputRenderTarget(mBloomExtractTarget, mBloomExtractTarget);
374 // use the completed blur in the first buffer and composite with the original child actors render
375 mCompositeImageActor.SetImage( mRenderTargetForRenderingChildren );
376 mCompositeShader.SetEffectImage( mBloomExtractTarget );
378 // set up target actor for rendering result, i.e. the blurred image
379 mTargetImageActor.SetImage(mOutputRenderTarget);
383 void BloomView::CreateRenderTasks()
385 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
387 // create render task to render our child actors to offscreen buffer
388 mRenderChildrenTask = taskList.CreateTask();
389 mRenderChildrenTask.SetSourceActor( mChildrenRoot );
390 mRenderChildrenTask.SetExclusive(true);
391 mRenderChildrenTask.SetInputEnabled( false );
392 mRenderChildrenTask.SetClearEnabled( true );
394 // 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.
395 mBloomExtractTask = taskList.CreateTask();
396 mBloomExtractTask.SetSourceActor( mBloomExtractImageActor );
397 mBloomExtractTask.SetExclusive(true);
398 mBloomExtractTask.SetInputEnabled( false );
399 mBloomExtractTask.SetClearEnabled( true );
401 // GaussianBlurView tasks must be created here, so they are executed in the correct order with respect to BloomView tasks
402 GetImpl(mGaussianBlurView).CreateRenderTasks();
404 // Use an image actor displaying the children render and composite it with the blurred bloom buffer, targeting the output
405 mCompositeTask = taskList.CreateTask();
406 mCompositeTask.SetSourceActor( mCompositeImageActor );
407 mCompositeTask.SetExclusive(true);
408 mCompositeTask.SetInputEnabled( false );
409 mCompositeTask.SetClearEnabled( true );
411 mRenderChildrenTask.SetCameraActor(mRenderFullSizeCamera); // use camera that covers render target exactly
412 mBloomExtractTask.SetCameraActor(mRenderDownsampledCamera);
413 mCompositeTask.SetCameraActor(mRenderFullSizeCamera);
415 mRenderChildrenTask.SetTargetFrameBuffer( mRenderTargetForRenderingChildren );
416 mBloomExtractTask.SetTargetFrameBuffer( mBloomExtractTarget );
417 mCompositeTask.SetTargetFrameBuffer( mOutputRenderTarget );
420 void BloomView::RemoveRenderTasks()
422 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
424 taskList.RemoveTask(mRenderChildrenTask);
425 taskList.RemoveTask(mBloomExtractTask);
427 GetImpl(mGaussianBlurView).RemoveRenderTasks();
429 taskList.RemoveTask(mCompositeTask);
432 void BloomView::OnStageDisconnection()
434 // TODO: can't call this here, since SetImage() calls fails similarly to above
435 // Need to fix the stage connection so this callback can be used arbitrarily. At that point we can simplify the API by removing the need for Activate() / Deactivate()
439 void BloomView::OnControlStageConnection()
441 // TODO: can't call this here, since SetImage() calls fail to connect images to stage, since parent chain not fully on stage yet
442 // Need to fix the stage connection so this callback can be used arbitrarily. At that point we can simplify the API by removing the need for Activate() / Deactivate()
446 void BloomView::Activate()
448 // make sure resources are allocated and start the render tasks processing
453 void BloomView::Deactivate()
455 // stop render tasks processing
456 // Note: render target resources are automatically freed since we set the Image::Unused flag
461 * EqualToConstraintFloat
463 * f(current, property) = property
465 struct EqualToConstraintFloat
467 EqualToConstraintFloat(){}
469 float operator()(const float current, const PropertyInput& property) {return property.GetFloat();}
473 * RecipOneMinusConstraint
475 * f(current, property) = property
477 struct RecipOneMinusConstraint
479 RecipOneMinusConstraint(){}
481 float operator()(const float current, const PropertyInput& property)
483 return 1.0f / (1.0f - property.GetFloat());
487 // 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
488 // internal implementation classes
489 void BloomView::SetupProperties()
491 CustomActor self = Self();
494 ///////////////////////////////////////////
497 // set defaults, makes sure properties are registered with shader
498 mBloomExtractShader.SetUniform( BLOOM_THRESHOLD_PROPERTY_NAME, BLOOM_THRESHOLD_DEFAULT );
499 mBloomExtractShader.SetUniform( RECIP_ONE_MINUS_BLOOM_THRESHOLD_PROPERTY_NAME, 1.0f / (1.0f - BLOOM_THRESHOLD_DEFAULT) );
501 // Register a property that the user can control to change the bloom threshold
502 mBloomThresholdPropertyIndex = self.RegisterProperty(BLOOM_THRESHOLD_PROPERTY_NAME, BLOOM_THRESHOLD_DEFAULT);
503 Property::Index shaderBloomThresholdPropertyIndex = mBloomExtractShader.GetPropertyIndex(BLOOM_THRESHOLD_PROPERTY_NAME);
504 Constraint bloomThresholdConstraint = Constraint::New<float>(shaderBloomThresholdPropertyIndex, Source(self, mBloomThresholdPropertyIndex), EqualToConstraintFloat());
505 mBloomExtractShader.ApplyConstraint(bloomThresholdConstraint);
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 = mBloomExtractShader.GetPropertyIndex(RECIP_ONE_MINUS_BLOOM_THRESHOLD_PROPERTY_NAME);
509 Constraint thresholdConstraint = Constraint::New<float>( shaderRecipOneMinusBloomThresholdPropertyIndex, LocalSource(shaderBloomThresholdPropertyIndex), RecipOneMinusConstraint());
510 mBloomExtractShader.ApplyConstraint(thresholdConstraint);
513 ////////////////////////////////////////////
516 // Register a property that the user can control to fade the blur in / out via internal GaussianBlurView object
517 mBlurStrengthPropertyIndex = self.RegisterProperty(BLOOM_BLUR_STRENGTH_PROPERTY_NAME, BLOOM_BLUR_STRENGTH_DEFAULT);
518 Constraint blurStrengthConstraint = Constraint::New<float>( mGaussianBlurView.GetBlurStrengthPropertyIndex(), Source(self, mBlurStrengthPropertyIndex), EqualToConstraintFloat());
519 mGaussianBlurView.ApplyConstraint(blurStrengthConstraint);
522 ////////////////////////////////////////////
525 // Register a property that the user can control to fade the bloom intensity via internally hidden shader
526 mBloomIntensityPropertyIndex = self.RegisterProperty(BLOOM_INTENSITY_PROPERTY_NAME, BLOOM_INTENSITY_DEFAULT);
527 mCompositeShader.SetUniform( BLOOM_INTENSITY_PROPERTY_NAME, BLOOM_INTENSITY_DEFAULT );
528 Property::Index shaderBloomIntensityPropertyIndex = mCompositeShader.GetPropertyIndex(BLOOM_INTENSITY_PROPERTY_NAME);
529 Constraint bloomIntensityConstraint = Constraint::New<float>( shaderBloomIntensityPropertyIndex, Source(self, mBloomIntensityPropertyIndex), EqualToConstraintFloat());
530 mCompositeShader.ApplyConstraint(bloomIntensityConstraint);
533 ////////////////////////////////////////////
536 // Register a property that the user can control to fade the bloom saturation via internally hidden shader
537 mBloomSaturationPropertyIndex = self.RegisterProperty(BLOOM_SATURATION_PROPERTY_NAME, BLOOM_SATURATION_DEFAULT);
538 mCompositeShader.SetUniform( BLOOM_SATURATION_PROPERTY_NAME, BLOOM_SATURATION_DEFAULT );
539 Property::Index shaderBloomSaturationPropertyIndex = mCompositeShader.GetPropertyIndex(BLOOM_SATURATION_PROPERTY_NAME);
540 Constraint bloomSaturationConstraint = Constraint::New<float>( shaderBloomSaturationPropertyIndex, Source(self, mBloomSaturationPropertyIndex), EqualToConstraintFloat());
541 mCompositeShader.ApplyConstraint(bloomSaturationConstraint);
544 ////////////////////////////////////////////
547 // Register a property that the user can control to fade the image intensity via internally hidden shader
548 mImageIntensityPropertyIndex = self.RegisterProperty(IMAGE_INTENSITY_PROPERTY_NAME, IMAGE_INTENSITY_DEFAULT);
549 mCompositeShader.SetUniform( IMAGE_INTENSITY_PROPERTY_NAME, IMAGE_INTENSITY_DEFAULT );
550 Property::Index shaderImageIntensityPropertyIndex = mCompositeShader.GetPropertyIndex(IMAGE_INTENSITY_PROPERTY_NAME);
551 Constraint imageIntensityConstraint = Constraint::New<float>( shaderImageIntensityPropertyIndex, Source(self, mImageIntensityPropertyIndex), EqualToConstraintFloat());
552 mCompositeShader.ApplyConstraint(imageIntensityConstraint);
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 mCompositeShader.SetUniform( IMAGE_SATURATION_PROPERTY_NAME, IMAGE_SATURATION_DEFAULT );
561 Property::Index shaderImageSaturationPropertyIndex = mCompositeShader.GetPropertyIndex(IMAGE_SATURATION_PROPERTY_NAME);
562 Constraint imageSaturationConstraint = Constraint::New<float>( shaderImageSaturationPropertyIndex, Source(self, mImageSaturationPropertyIndex), EqualToConstraintFloat());
563 mCompositeShader.ApplyConstraint(imageSaturationConstraint);
566 } // namespace Internal
568 } // namespace Toolkit