meshActor.SetAffectedByLighting(false);
Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::New( "", MESH_FRAGMENT_SHADER,
- GEOMETRY_TYPE_MESH,
+ GEOMETRY_TYPE_UNTEXTURED_MESH,
Dali::ShaderEffect::HINT_BLENDING );
meshActor.SetShaderEffect(shaderEffect);
BouncingEffect BouncingEffect::New( const Vector4& color )
{
std::string fragmentShader = MAKE_STRING(
+ precision mediump float;\n
uniform float uProgressRate;\n
uniform vec4 uAssignedColor;\n
void main()\n
);
ShaderEffect shaderEffect;
- shaderEffect = ShaderEffect::New( "", fragmentShader, GeometryType( GEOMETRY_TYPE_IMAGE),
+ shaderEffect = ShaderEffect::New( "", fragmentShader,
+ GeometryType( GEOMETRY_TYPE_IMAGE),
ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING ) );
BouncingEffect handle( shaderEffect );
ImageRegionEffect ImageRegionEffect::New()
{
std::string vertexShader(
- "uniform vec2 uTopLeft;\n"
- "uniform vec2 uBottomRight;\n"
+ "uniform mediump vec2 uTopLeft;\n"
+ "uniform mediump vec2 uBottomRight;\n"
"void main()\n"
"{\n"
- " vec4 position = vec4(aPosition,1.0);\n"
+ " mediump vec4 position = vec4(aPosition,1.0);\n"
" gl_Position = uMvpMatrix * position;\n"
// The line below is doing the same as the following commented lines:
//" vec2 imageSize = sTextureRect.zw - sTextureRect.xy;\n"
} // namespace Toolkit
} // namespace Dali
-
const float ARBITRARY_FIELD_OF_VIEW = Math::PI / 4.0f;
const char* const GAUSSIAN_BLUR_FRAGMENT_SOURCE =
- "uniform vec2 uSampleOffsets[NUM_SAMPLES];\n"
- "uniform float uSampleWeights[NUM_SAMPLES];\n"
+ "uniform mediump vec2 uSampleOffsets[NUM_SAMPLES];\n"
+ "uniform mediump float uSampleWeights[NUM_SAMPLES];\n"
"void main()\n"
"{\n"
const char* BLUR_TWO_PASS_FRAGMENT_SOURCE =
{
+ "precision highp float;\n"
"uniform vec2 uSampleOffsets[NUM_SAMPLES];\n"
"uniform float uSampleWeights[NUM_SAMPLES];\n"
"void main()\n"
const char* EMBOSS_FRAGMENT_SOURCE1 =
{
+ "precision highp float;\n"
"uniform vec2 uTexScale;\n"
"\n"
"void main()\n"
const char* EMBOSS_FRAGMENT_SOURCE2 =
{
+ "precision highp float;\n"
"uniform vec2 uTexScale;\n"
"\n"
"void main()\n"
const char* const SPREAD_FRAGMENT_SOURCE =
{
+ "precision highp float;\n"
"uniform float uSpread;\n"
"uniform vec2 uTexScale;\n"
"void main()\n"
* ([3][2]) float curveHeight: The height of the interpolated hermite curve.
* ([3][3]) float currentLength: The length from the current center to the curveEnd.
*/
+ precision mediump float;\n
uniform mat4 uCommonParameters;\n
\n
uniform vec2 uPageSize;\n
std::string vertexShaderEnd("}");
std::string fragmentShaderPartOne = MAKE_STRING(
+ precision mediump float;\n
uniform vec2 uPageSize;\n
uniform vec2 uSpineShadowParameter;\n
varying vec3 vNormal;\n
static FullAreaImageCreator New()
{
std::string vertexShader(
- "uniform vec4 uRegion; \n"
+ "uniform mediump vec4 uRegion; \n"
"void main() \n"
"{\n"
" gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\n"
);
std::string fragmentShader(
- "uniform vec4 uRegion; \n"
+ "uniform mediump vec4 uRegion; \n"
"void main() \n"
"{\n"
" if( vTexCoord.s > 0.0 && vTexCoord.s < 1.0 && vTexCoord.t > 0.0 && vTexCoord.t < 1.0) \n"
const char* ALPHA_DISCARD_FRAGMENT_SHADER_SOURCE =
"void main() \n"
"{ \n"
- " vec4 color = texture2D( sTexture, vTexCoord ); \n"
+ " mediump vec4 color = texture2D( sTexture, vTexCoord ); \n"
" if(color.a <= 0.0001) \n"
" { \n"
" discard; \n"
BlindEffect BlindEffect::New()
{
std::string fragmentShader(
- "uniform float uStep; \n"
+ "uniform mediump float uStep; \n"
"void main() \n"
"{ \n"
- " vec4 alphaColor; \n"
- " vec4 baseColor; \n"
+ " mediump vec4 alphaColor; \n"
+ " mediump vec4 baseColor; \n"
" baseColor = texture2D( sTexture, vTexCoord); \n"
" alphaColor = vec4(0.1,0.1,0.1,1.0); \n"
- " float index = 0.0; \n"
+ " lowp float index = 0.0; \n"
" index = floor(vTexCoord.y/0.1); \n"
" if((vTexCoord.y < (index * 0.1 + uStep * 0.005)) && (vTexCoord.y > index * 0.1))\n"
" { \n"
std::ostringstream vertexShaderStringStream;
vertexShaderStringStream << "#define NUMBER_OF_BUBBLE "<< numberOfBubble << "\n";
std::string vertexShader(
+ " precision mediump float;\n"
// the gravity applied to the y direction
" uniform float uGravity; \n"
// Width of the texture in pixels
vertexShaderStringStream << vertexShader;
std::string fragmentShader(
+ " precision mediump float;\n"
" varying float vPercentage;\n"
" varying vec2 vEffectTexCoord;\n"
"\n"
" gl_FragColor = fragColor;\n"
" }\n");
- ShaderEffect shaderEffect = ShaderEffect::New( vertexShaderStringStream.str(), fragmentShader,
- GeometryType( GEOMETRY_TYPE_TEXTURED_MESH),
- ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING ) );
+ ShaderEffect shaderEffect = ShaderEffect::New(
+ vertexShaderStringStream.str(),
+ fragmentShader,
+ GeometryType( GEOMETRY_TYPE_TEXTURED_MESH),
+ ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING ) );
+
BubbleEffect handle( shaderEffect );
handle.mNumberOfBubbles = numberOfBubble;
handle.SetMovementArea( Stage::GetCurrent().GetSize() );
-
handle.SetUniform( "uGravity", 50.f );
handle.SetUniform( "uMagnification", 1.f );
handle.SetUniform( "uDynamicScale", 1.f );
"\n"
"void main()\n"
"{\n"
- " vec4 world = uModelView * vec4(aPosition,1.0);\n"
- " vec2 d = (world.xy - uCenter) * uAnglePerUnit;\n"
- " float a = length(d);\n"
- " float cs = cos(radians(a));\n"
+ " mediump vec4 world = uModelView * vec4(aPosition,1.0);\n"
+ " mediump vec2 d = (world.xy - uCenter) * uAnglePerUnit;\n"
+ " mediump float a = length(d);\n"
+ " mediump float cs = cos(radians(a));\n"
" world.z -= cs * uRadius;\n"
" gl_Position = uProjection * world;\n"
" \n"
"void main()\n"
"{\n"
- " vec4 col = texture2D(sTexture, vTexCoord);\n"
+ " vec4 col = texture2D(sTexture, vTexCoord);\n"
// calc lighting
" float intensity = dot(uLightDirection, uFixedNormal);"
" vec3 lighting = (intensity * uDiffuseLightColor) + uAmbientLightColor;\n"
}
}
-
Dali::ShaderEffect shaderEffectCustom;
if( useHighPrecision )
{
- shaderEffectCustom = Dali::ShaderEffect::New( vertexShader, prefixHighPrecision + fragmentShader,
+ shaderEffectCustom = Dali::ShaderEffect::New( prefixHighPrecision+vertexShader, prefixHighPrecision + fragmentShader,
GeometryType( GEOMETRY_TYPE_IMAGE),
ShaderEffect::GeometryHints( ShaderEffect::HINT_GRID | ShaderEffect::HINT_BLENDING ) );
}
else
{
- shaderEffectCustom = Dali::ShaderEffect::New( vertexShader, prefixMediumPrecision + fragmentShader,
+ shaderEffectCustom = Dali::ShaderEffect::New( prefixMediumPrecision+vertexShader, prefixMediumPrecision + fragmentShader,
GeometryType( GEOMETRY_TYPE_IMAGE),
ShaderEffect::GeometryHints( ShaderEffect::HINT_GRID | ShaderEffect::HINT_BLENDING ) );
}
std::ostringstream vertexShaderStringStream;
vertexShaderStringStream << "#define NUMBER_OF_DIMPLE "<< numberOfDimples << "\n";
std::string vertexShader(
+ "precision highp float;\n"
"uniform vec2 uCenter[ NUMBER_OF_DIMPLE ];\n"
"uniform float uRadius[ NUMBER_OF_DIMPLE ]; \n"
"uniform float uPercentage[ NUMBER_OF_DIMPLE ]; \n"
"\n"
" else // (uDoShadow > 0.0)\n"
" {\n"
- " float shadowDistance = texture2D(sTexture, vTexCoord - uShadowOffset).a;\n"
+ " mediump float shadowDistance = texture2D(sTexture, vTexCoord - uShadowOffset).a;\n"
" mediump float inText = alphaFactor;\n"
" mediump float inShadow = smoothstep(uSmoothing - smoothWidth, uSmoothing + smoothWidth, shadowDistance);\n"
"\n"
// append the default version
std::string vertexShader(
"uniform mediump vec2 uCenter;\n"
- "varying vec2 vRelativePosition;\n"
+ "varying mediump vec2 vRelativePosition;\n"
"\n"
"void main()\n"
"{\n"
- " vec4 world = uModelView * vec4(aPosition,1.0);\n"
+ " mediump vec4 world = uModelView * vec4(aPosition,1.0);\n"
" gl_Position = uProjection * world;\n"
" \n"
" vTexCoord = aTexCoord;\n"
"}\n");
std::string fragmentShader(
- "uniform float uRadius; \n"
- "uniform float uBlendFactor; \n"
- "varying vec2 vRelativePosition; \n"
+ "uniform mediump float uRadius; \n"
+ "uniform mediump float uBlendFactor; \n"
+ "varying mediump vec2 vRelativePosition; \n"
"void main() \n"
"{ \n"
- " float delta = (length(vRelativePosition) - uRadius); \n"
+ " mediump float delta = (length(vRelativePosition) - uRadius); \n"
" delta = clamp(0.0 - delta * uBlendFactor, 0.0, 1.0); \n"
" gl_FragColor = texture2D(sTexture, vTexCoord) * uColor; \n"
" gl_FragColor.a *= delta; \n"
}
}
-
MirrorEffect MirrorEffect::New()
{
- std::string vertextShader(
- "precision mediump float; \n"
+ std::string vertexShader(
"void main() \n"
"{ \n"
- " vec3 pos = aPosition; \n"
+ " mediump vec3 pos = aPosition; \n"
" pos.y = pos.y * 3.0; \n"
- " vec4 world = uModelView * vec4(pos,1.0); \n"
+ " mediump vec4 world = uModelView * vec4(pos,1.0); \n"
" gl_Position = uProjection * world; \n"
" vTexCoord = aTexCoord; \n"
"} \n" );
std::string fragmentShader(
- "uniform float uDepth; \n"
- "uniform float uAlpha; \n"
+ "uniform mediump float uDepth; \n"
+ "uniform mediump float uAlpha; \n"
"void main() \n"
"{ \n"
" if(vTexCoord.y < 1.0 / 3.0) \n"
" } \n"
" else \n"
" { \n"
- " float darkness = 3.0 - vTexCoord.y * 3.0; \n"
+ " highp float darkness = 3.0 - vTexCoord.y * 3.0; \n"
" darkness = (1.0 - 1.0 / uDepth + darkness * 1.0/ uDepth) * 0.65; \n"
- " vec4 color = texture2D(sTexture, vec2(vTexCoord.x, -vTexCoord.y *3.0 + 3.0)) * uColor; \n"
+ " highp vec4 color = texture2D(sTexture, vec2(vTexCoord.x, -vTexCoord.y *3.0 + 3.0)) * uColor; \n"
" color.a *= uAlpha; \n"
" gl_FragColor = color * vec4(darkness, darkness, darkness, darkness); \n"
" } \n"
// Create the implementation, temporarily owned on stack,
Dali::ShaderEffect shaderEffectCustom = Dali::ShaderEffect::New(
- vertextShader,
+ vertexShader,
fragmentShader,
GeometryType( GEOMETRY_TYPE_IMAGE ),
ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING ));
// varying vec2 vTexCoord;
std::string vertexSource;
vertexSource =
+ "precision mediump float;\n"
"uniform mat4 uModelLastFrame;\n"
"uniform float uTimeDelta;\n"
std::string fragmentSource;
fragmentSource =
"precision mediump float;\n"
-
"uniform vec2 uObjectFadeStart;\n"
"uniform vec2 uObjectFadeEnd;\n"
"uniform float uAlphaScale;\n"
"}\n";
// NOTE: we must turn on alpha blending for the actor (HINT_BLENDING)
- ShaderEffect shader = ShaderEffect::New( vertexSource,
- fragmentSource,
+ ShaderEffect shader = ShaderEffect::New( vertexSource, fragmentSource,
GEOMETRY_TYPE_IMAGE,
ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING | ShaderEffect::HINT_GRID) );
}
}
-
// varying vec2 vTexCoord;
std::string vertexSource;
vertexSource =
+ "precision mediump float;\n"
"uniform mat4 uModelLastFrame;\n"
"uniform float uTimeDelta;\n"
"}";
// NOTE: we must turn on alpha blending for the actor (HINT_BLENDING)
- ShaderEffect shader = ShaderEffect::New( vertexSource,
- fragmentSource,
- GeometryType( GEOMETRY_TYPE_IMAGE ),
- ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING | ShaderEffect::HINT_GRID ) );
+ ShaderEffect shader = ShaderEffect::New(
+ vertexSource, fragmentSource, GeometryType( GEOMETRY_TYPE_IMAGE ),
+ ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING | ShaderEffect::HINT_GRID ) );
}
}
-
static void DoApply( ImageActor actor, const std::string& maskImage, const Vector2& maskSize, Vector4 maskBorder )
{
const char* ALPHA_MASK_VERTEX_SHADER_SOURCE =
+ "precision mediump float;\n"
"uniform vec2 uImageSize; \n"
"uniform vec2 uMaskSize; \n"
"varying vec2 vMaskTexCoord; \n"
"} \n";
const char* ALPHA_MASK_FRAGMENT_SHADER_SOURCE =
- "varying vec2 vMaskTexCoord; \n"
+ "varying mediump vec2 vMaskTexCoord; \n"
" \n"
"void main() \n"
"{ \n"
" gl_FragColor = texture2D(sTexture, vTexCoord) * uColor * vec4(1,1,1,mask.a); \n"
"} \n";
- ShaderEffect maskEffect = ShaderEffect::New( ALPHA_MASK_VERTEX_SHADER_SOURCE,
- ALPHA_MASK_FRAGMENT_SHADER_SOURCE,
- GeometryType( GEOMETRY_TYPE_IMAGE ),
- ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING ) );
+ ShaderEffect maskEffect = ShaderEffect::New(
+ ALPHA_MASK_VERTEX_SHADER_SOURCE,
+ ALPHA_MASK_FRAGMENT_SHADER_SOURCE,
+ GeometryType( GEOMETRY_TYPE_IMAGE ),
+ ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING ) );
maskEffect.SetEffectImage( Image::New( maskImage ) );
PageTurnBookSpineEffect PageTurnBookSpineEffect::New()
{
std::string vertexSource(
+ "precision mediump float;\n"
"uniform float uShadowWidth;\n"
" void main()\n"
" {\n"
// the simplified version of the fragment shader of page turn effect
std::string fragmentSource(
+ "precision mediump float;\n"
"uniform float uIsBackImageVisible;\n"
"uniform float uPageWidth;\n"
"uniform vec2 uSpineShadowParameter;\n"
" }" );
ShaderEffect shader;
- shader = ShaderEffect::New( vertexSource,fragmentSource );
+ shader = ShaderEffect::New( vertexSource, fragmentSource );
PageTurnBookSpineEffect handle( shader );
handle.SetUniform( IS_BACK_IMAGE_VISIBLE_PROPERTY_NAME, -1.f );
handle.SetUniform( SHADOW_WIDTH_PROPERTY_NAME, DEFAULT_SHADOW_WIDTH );
{
// append the default version
std::string fragmentShader(
+ "precision mediump float;\n"
"uniform float uAmplitude;\n"
"uniform float uTime;\n"
"void main()\n"
// Create the implementation, temporarily owned on stack
Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::New(
- "",
- fragmentShader,
- Dali::GeometryType( GEOMETRY_TYPE_IMAGE ),
- ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING | ShaderEffect::HINT_GRID ));
+ "", fragmentShader,
+ Dali::GeometryType( GEOMETRY_TYPE_IMAGE ),
+ ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING | ShaderEffect::HINT_GRID ));
/* Pass ownership to Ripple2DEffect through overloaded constructor, So that it now has access to the
Dali::ShaderEffect implementation */
"\n"
"void main()\n"
"{\n"
- " vec4 world = vec4(aPosition, 1.0);\n"
+ " mediump vec4 world = vec4(aPosition, 1.0);\n"
" \n"
- " vec2 d = vec2(world.xy - uCenter);\n"
- " float dist = length(d);\n"
+ " mediump vec2 d = vec2(world.xy - uCenter);\n"
+ " mediump float dist = length(d);\n"
" \n"
- " float range = (uRadius - dist) / (uRadius);\n"
+ " mediump float range = (uRadius - dist) / (uRadius);\n"
" vRange = max(0.1, range);\n"
" \n"
" gl_Position = uMvpMatrix * world;\n"
{
// variable "uStep" range scope : [0.0, 1.0]
std::string fragmentShader(
- "uniform vec2 texSize; \n"
- "uniform float uStep; \n"
- "uniform float uRows; \n"
- "uniform float uColumns; \n"
- "void main() \n"
- "{ \n"
- " vec2 mosaicSize = vec2(1.0 / uRows, 1.0 / uColumns); \n"
- " vec2 intXY = vec2(vTexCoord.x * texSize.x, vTexCoord.y * texSize.y); \n"
- " vec2 XYMosaic = vec2(floor(intXY.x / mosaicSize.x) * mosaicSize.x, floor(intXY.y / mosaicSize.y) * mosaicSize.y); \n"
- " vec2 UVMosaic = vec2(XYMosaic.x /texSize.x, XYMosaic.y / texSize.y); \n"
- " vec4 noiseVec = texture2D(sEffect, UVMosaic); \n"
- " float intensity = (noiseVec[0] + noiseVec[1] + noiseVec[2] + noiseVec[3]) / 4.0; \n"
+ "uniform mediump vec2 texSize;\n"
+ "uniform mediump float uStep;\n"
+ "uniform mediump float uRows;\n"
+ "uniform mediump float uColumns;\n"
+ "void main()\n"
+ "{\n"
+ " mediump vec2 mosaicSize = vec2(1.0 / uRows, 1.0 / uColumns); \n"
+ " mediump vec2 intXY = vec2(vTexCoord.x * texSize.x, vTexCoord.y * texSize.y); \n"
+ " mediump vec2 XYMosaic = vec2(floor(intXY.x / mosaicSize.x) * mosaicSize.x, floor(intXY.y / mosaicSize.y) * mosaicSize.y); \n"
+ " mediump vec2 UVMosaic = vec2(XYMosaic.x /texSize.x, XYMosaic.y / texSize.y); \n"
+ " mediump vec4 noiseVec = texture2D(sEffect, UVMosaic); \n"
+ " mediump float intensity = (noiseVec[0] + noiseVec[1] + noiseVec[2] + noiseVec[3]) / 4.0; \n"
" if(intensity < uStep) \n"
" gl_FragColor = vec4(0.1, 0.1, 0.1, 1.0); \n"
" else \n"
{
// append the default version
std::string fragmentShader(
- "uniform vec2 uTextureSize;\n"
- "uniform float uRadius;\n"
- "uniform float uAngle;\n"
- "uniform vec2 uCenter;\n"
+ "uniform mediump vec2 uTextureSize;\n"
+ "uniform highp float uRadius;\n"
+ "uniform highp float uAngle;\n"
+ "uniform mediump vec2 uCenter;\n"
"void main()\n"
"{\n"
- " vec2 textureCenter = (sTextureRect.xy + sTextureRect.zw) * 0.5;\n"
+ " highp vec2 textureCenter = (sTextureRect.xy + sTextureRect.zw) * 0.5;\n"
" textureCenter = vTexCoord.st - textureCenter;\n"
- " float distance = length(textureCenter);\n"
+ " highp float distance = length(textureCenter);\n"
" if (distance >= uRadius)\n"
" discard;\n"
- " float percent = (uRadius - distance) / uRadius;\n"
- " float theta = percent * percent * uAngle * 4.0;\n"
- " float sinTheta = sin(theta);\n"
- " float cosTheta = cos(theta);\n" );
+ " highp float percent = (uRadius - distance) / uRadius;\n"
+ " highp float theta = percent * percent * uAngle * 4.0;\n"
+ " highp float sinTheta = sin(theta);\n"
+ " highp float cosTheta = cos(theta);\n" );
// if warp, loose the sign from sin
if( warp )
{