X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Fdevel-api%2Fshader-effects%2Fspot-effect.h;h=2cff9ee5fdec53da3a293c40248f938a378f8a1c;hb=413f5f72b91511a077891b3ef5531b4757f80a1a;hp=07883090fbd50695c2e9bb77f264c5a0b3941150;hpb=f58b8383147de70affa1e3949cf1c6757d705d3c;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/devel-api/shader-effects/spot-effect.h b/dali-toolkit/devel-api/shader-effects/spot-effect.h index 0788309..2cff9ee 100644 --- a/dali-toolkit/devel-api/shader-effects/spot-effect.h +++ b/dali-toolkit/devel-api/shader-effects/spot-effect.h @@ -28,58 +28,55 @@ namespace Toolkit { /** - * SpotEffect2D is a custom shader effect to achieve spot effects on Image actors + * @brief Creates a new SpotEffect + * + * SpotEffect is a custom shader effect to achieve spot effects on Image actors + * + * Animatable/Constrainable uniforms: + * "uCenter" - The center of the spot. Default value (0.0,0.0) + * "uRadius" - The radius of the spot. Default value 0.0 + * + * @return A handle to a newly allocated ShaderEffect */ -class DALI_IMPORT_API SpotEffect : public ShaderEffect +inline ShaderEffect CreateSpotEffect() { -public: - - /** - * Create an uninitialized SpotEffect; this can be initialized with SpotEffect::New() - * Calling member functions with an uninitialized Dali::Object is not allowed. - */ - SpotEffect(); - - /** - * @brief Destructor - * - * This is non-virtual since derived Handle types must not contain data or virtual methods. - */ - ~SpotEffect(); - - /** - * Create an initialized SpotEffect. - * @return A handle to a newly allocated Dali resource. - */ - static SpotEffect New(); - - /** - * Set the center of the spot. - * @param[in] center The center in Vector2. - */ - void SetCenter(const Vector2& center); - - /** - * Set the radius of the spot. - * @param[in] radius The radius in float. - */ - void SetRadius(float radius); - - /** - * Get the name for the center property - * @return A std::string containing the property name - */ - const std::string& GetCenterPropertyName() const; - - /** - * Get the name for the radius property - * @return A std::string containing the property name - */ - const std::string& GetRadiusPropertyName() const; - -private: - DALI_INTERNAL SpotEffect(ShaderEffect handle); -}; + // append the default version + std::string vertexShader( + "uniform mediump vec2 uCenter;\n" + "uniform mediump float uRadius;\n" + "varying mediump float vRange;\n" + "\n" + "void main()\n" + "{\n" + " mediump vec4 world = vec4(aPosition*uSize.xy, 0.0, 1.0);\n" + " \n" + " mediump vec2 d = vec2(world.xy - uCenter);\n" + " mediump float dist = length(d);\n" + " \n" + " mediump float range = (uRadius - dist) / (uRadius);\n" + " vRange = max(0.1, range);\n" + " \n" + " gl_Position = uMvpMatrix * world;\n" + " vTexCoord = mix( uTextureRect.xy, uTextureRect.zw, aPosition + vec2(0.5) );\n;\n" + "}"); + + std::string fragmentShader( + "varying mediump float vRange;\n" + "\n" + "void main()\n" + "{\n" + " gl_FragColor = texture2D(sTexture, vTexCoord) * vec4(vRange, vRange, vRange, 1.0) * uColor;\n" + "}" ); + + Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::New( + vertexShader, fragmentShader, + ShaderEffect::GeometryHints( ShaderEffect::HINT_GRID )); + + shaderEffect.SetUniform( "uCenter", Vector2(0.0f, 0.0f) ); + shaderEffect.SetUniform( "uRadius", 0.0f ); + + return shaderEffect; +} } // namespace Toolkit