- DISPLACED = 0, /// Image gets displaced
- FIXED /// Image does not displace. Useful for matching lighting between areas that do not displace and those that do, e.g for backgrounds which are visible between buttons.
- }Type;
-
- /**
- * Create an uninitialized DisplacementEffect; this can be initialized with DisplacementEffect::New()
- * Calling member functions with an uninitialized Dali::Object is not allowed.
- */
- DisplacementEffect();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~DisplacementEffect();
-
- /**
- * Create an initialized DisplacementEffect
- * @param type The type of the effect, can be either DISPLACED, or FIXED.
- * @return A handle to a newly allocated Dali resource.
- */
- static DisplacementEffect New(Type type);
-
- /**
- * Get the name for the light direction property (Vector3)
- * The light direction is used in the lighting calculation. The angle of incidence directly affects the amount of light reflected.
- * Default (0.0f, 0.7070168f, 0.7071068f), i.e angled at the surface from in front and above.
- * @return A std::string containing the property name
- */
- const std::string& GetLightDirectionPropertyName() const;
-
- /**
- * Get the name for the ambient lighting color property (Vector3)
- * The ambient light is used in the lighting calculation. Care must be taken to not saturate the image by setting this value too high,
- * or the indentation will not look correct. Default 0.15.
- * @return A std::string containing the property name
- */
- const std::string& GetAmbientLightColorPropertyName() const;
-
- /**
- * Get the name for the diffuse light color property (Vector3).
- * The diffuse light is used in the lighting calculation. Default is (1.0f, 1.0f, 1.0f).
- * @return A std::string containing the property name
- */
- const std::string& GetDiffuseLightColorPropertyName() const;
-
- /**
- * Get the name for the lighting multiplier property (float).
- * The ambient and diffuse lighting is multiplied by this factor. Since a diffuse light at an angle will cause the whole image to darken,
- * this property can be used to scale the image back up closer to the pixel values of the original diffuse texture. Care must be taken to not saturate the image,
- * or the indentation will not look correct. Default 1.0
- * @return A std::string containing the property name
- */
- const std::string& GetLightingMultiplierPropertyName() const;
-
- /**
- * Get the name for the state property (float).
- * The shader can have a maximum of two end states 0 or 1, Animate between these two values to do the transitions between states.
- * Default 0.0
- * @return A std::string containing the property name.
- */
- const std::string& GetStatePropertyName() const;
-
- /**
- * Get the name for the height scale property (float).
- * The height displacement is multiplied by this factor. Tweak this to get the required level of depth.
- * Default 0.1
- * @return A std::string containing the property name.
- */
- const std::string& GetHeightScalePropertyName() const;
-
- /**
- * Get the name for the fixed normal property (Vector3).
- * Only applicable for the FIXED type shader and not for DISPLACEMENT type.
- * The Fixed normal will be used for the light calculation. Tweak this to get the required level of light.
- * Default (0.0f, 0.0f, 1.0f)
- * @return A std::string containing the property name.
- */
- const std::string& GetFixedNormalPropertyName() const;
-
- /**
- * Set the light direction property
- * The light direction is used in the lighting calculation. The angle of incidence directly affects the amount of light reflected.
- * Default (0.0f, 0.7070168f, 0.7071068f), i.e angled at the surface from in front and above.
- * @param [in] lightDirection The new light direction.
- */
- void SetLightDirection(Vector3 lightDirection);
-
- /**
- * Set the ambient light color property
- * The ambient light is used in the lighting calculation. Care must be taken to not saturate the image by setting this value too high,
- * or the indentation will not look correct. Default (0.15f, 0.15f, 0.15f).
- * @param [in] ambientLight The new ambient light value.
- */
- void SetAmbientLightColorProperty(Vector3 ambientLight);
-
- /**
- * Set the diffuse light color property.
- * The diffuse light is used in the lighting calculation. Default is (1.0f, 1.0f, 1.0f), i.e. a white light so the natural image color is shown.
- * @param [in] diffuseLight The new diffuse light value.
- */
- void SetDiffuseLightColorProperty(Vector3 diffuseLight);
-
- /**
- * Get the name for the lighting multiplier property.
- * The ambient and diffuse lighting is multiplied by this factor. Since a diffuse light at an angle will cause the whole image to darken,
- * this property can be used to scale the image back up closer to the pixel values of the original diffuse texture. Care must be taken to not saturate the image,
- * or the indentation will not look correct. Default 1.0
- * @param [in] lightMultiplier The new light multiplier value.
- */
- void SetLightingMultiplierProperty(float lightMultiplier);
-
- /**
- * Get the name for the state property.
- * The shader can only be in or in between two states 0 or 1, Animate between these two values to do the transitions between states.
- * @param [in] state The new state value.
- */
- void SetStateProperty(float state);
-
- /**
- * Set the name for the height scale property.
- * The height displacement is multiplied by this factor. Tweak this to get the required level of depth. Default 0.1
- * @param [in] heightScale The new height scale.
- */
- void SetHeightScaleProperty(float heightScale);
-
- /**
- * Set the name for fixed normal property, Only applicable for the FIXED type shader and not for DISPLACEMENT type.
- * The Fixed normal will be used for the light calculation. Tweak this to get the required level of light.
- * @param [in] fixedNormal The new normal for the fixed type shader effect.
- */
- void SetFixedNormalProperty(Vector3 fixedNormal);
-
-private:
- // Not intended for application developers
- DALI_INTERNAL DisplacementEffect(ShaderEffect handle);
-};
+ case DISPLACEMENT_EFFECT_DISPLACED:
+ shaderEffect = ShaderEffect::New( "", fragmentSourceDisplaced);
+ break;
+
+ case DISPLACEMENT_EFFECT_FIXED:
+ default:
+ shaderEffect = ShaderEffect::New( "", fragmentSourceFixed);
+ break;
+ }
+
+
+ //////////////////////////////////////
+ // Register uniform properties
+ //
+ //
+ // factors that scale the look, defaults
+ shaderEffect.SetUniform("uLightDirection",Vector3(0.0, 0.7070168f, 0.7071068f));
+ shaderEffect.SetUniform("uAmbientLightColor",Vector3(0.15f, 0.15f, 0.15f));
+ shaderEffect.SetUniform("uDiffuseLightColor",Vector3(1.0f, 1.0f, 1.0f));
+ shaderEffect.SetUniform("uLightMultiplier",1.0f);
+ shaderEffect.SetUniform("uState",0.0f);
+ shaderEffect.SetUniform("uHightScale",0.1f);
+
+ if(type == DISPLACEMENT_EFFECT_FIXED)
+ {
+ shaderEffect.SetUniform("uFixedNormal",Vector3(0.0f, 0.0f, 1.0f) );
+ }
+
+ return shaderEffect;
+}