#include "utils.h"
#include "dali/dali.h"
#include "dali-toolkit/dali-toolkit.h"
+#include "generated/color-transition-controller-composite-vert.h"
+#include "generated/color-transition-controller-composite-frag.h"
using namespace Dali;
using namespace Dali::Toolkit;
const Vector4 BG_COLOR = Vector4(0.f, 0.f, 0.f, 0.f);
-const char* const COMPOSITE_VSH = DALI_COMPOSE_SHADER(
-precision mediump float;
-
-// <DALI>
-uniform mat4 uMvpMatrix;
-uniform vec3 uSize;
-// </DALI>
-
-uniform float uFlow;
-uniform vec4 uUvTransform; // rotation, scale (initial, target))
-
-attribute vec2 aPosition;
-
-varying vec2 vUv;
-varying vec2 vUvFlow;
-
-void main()
-{
- vec4 position = uMvpMatrix * vec4(aPosition * uSize.xy, 0., 1.);
-
- gl_Position = position;
-
- vec2 uv = position.xy / (position.ww * 2.);
- vUv = uv + vec2(.5);
-
- float alpha = uFlow * .5 + .5;
- vec2 uvRotationScale = mix(uUvTransform.xy, uUvTransform.zw, alpha);
- float c = cos(uvRotationScale.x) * uvRotationScale.y;
- float s = sin(uvRotationScale.x) * uvRotationScale.y;
- vec4 uvMatrix = vec4(c, -s, s, c);
- uv = vec2(dot(uvMatrix.xy, uv), dot(uvMatrix.zw, uv));
-
- // N.B. +y is down which is well aligned with the inverted y of the off-screen render,
- // however we need to flip the y of the uvs for the flow map.
- vUvFlow = vec2(uv.x + .5, .5 - uv.y);
-});
-
-const char* const COMPOSITE_FSH = DALI_COMPOSE_SHADER(
-precision mediump float;
-
-const float kStepsilon = 1e-2;
-
-uniform sampler2D sColor;
-uniform sampler2D sFlowMap;
-
-uniform float uFlow;
-uniform vec3 uRgb[2];
-
-varying vec2 vUv;
-varying vec2 vUvFlow;
-
-void main()
-{
- vec4 colorAlpha = texture2D(sColor, vUv);
- float flow = smoothstep(.5 - kStepsilon, .5 + kStepsilon, clamp(uFlow + texture2D(sFlowMap, vUvFlow).r, 0., 1.));
-
- gl_FragColor = vec4(mix(colorAlpha.rgb, mix(uRgb[0], uRgb[1], flow), colorAlpha.a), 1.);
-});
-
} // nonamespace
ColorTransitionController::ColorTransitionController(WeakHandle<RenderTaskList> window, Actor content, RenderTaskList tasks, Vector3 initialColor)
flowSampler.SetWrapMode(WrapMode::REPEAT, WrapMode::REPEAT);
tsComposite.SetSampler(1, flowSampler);
- auto shdComposite = Shader::New(COMPOSITE_VSH, COMPOSITE_FSH);
+ auto shdComposite = Shader::New(SHADER_COLOR_TRANSITION_CONTROLLER_COMPOSITE_VERT, SHADER_COLOR_TRANSITION_CONTROLLER_COMPOSITE_FRAG);
auto compositeRenderer = CreateRenderer(tsComposite, geomComposite, shdComposite);
composite.AddRenderer(compositeRenderer);