RE: hi, please help <Android MID run Esenthel error>
Hello,
Thank you for the information, your Device has problem with loading following shader:
vertex shader
Code:
#ifndef GL_ES
#define GL_ES
#endif
//GLSL
#ifdef GL_ES
precision highp float;
precision highp int;
#endif
#define COLOR 0
#define alpha_test 0
#ifdef GL_ES
#define HP highp
#define MP mediump
#define LP lowp
#else
#define HP
#define MP
#define LP
#endif
#define PAR uniform
#define VAR varying
#define EPS 0.0001
#define EPSL 0.01
#define PI 3.14159265
#define PI2 6.28318531
#define SBUMP_ZERO 0
#define SBUMP_FLAT 1
#define SBUMP_NORMAL 2
#define FX_NONE 0
#define FX_GRASS 1
#define FX_LEAF 2
#define FX_LEAFS 3
#define FX_BONE 4
#define Sat(x) clamp(x,0.0,1.0)
MP float Sum(MP vec2 v){return v.x+v.y;}
MP float Sum(MP vec3 v){return v.x+v.y+v.z;}
MP float Sum(MP vec4 v){return v.x+v.y+v.z+v.w;}
MP float Sqr(MP float x){return x*x;}
MP vec2 Sqr(MP vec2 x){return x*x;}
MP float Cube(MP float x){return x*x*x;}
MP float Length2(MP vec2 v){return dot(v,v);}
MP float Length2(MP vec3 v){return dot(v,v);}
MP float Length2(MP vec4 v){return dot(v,v);}
MP vec2 Rotate(MP vec2 vec,MP vec2 cos_sin)
{
return vec2(vec.x*cos_sin.x-vec.y*cos_sin.y,
vec.x*cos_sin.y+vec.y*cos_sin.x);
}
MP float LerpR(MP float from,MP float to,MP float v){return(v-from)/(to-from);}
MP float LerpRS(MP float from,MP float to,MP float v){return Sat((v-from)/(to-from));}
VAR HP vec2 IO_tex;
#if COLOR!=0
VAR LP vec4 IO_col;
#endif
PAR HP float VtxHeightmap;
PAR MP float VtxSkinning;
#define ATTR attribute
ATTR HP vec4 ATTR0;
ATTR MP vec3 ATTR1;
ATTR MP vec3 ATTR2;
ATTR MP vec4 ATTR3;
ATTR HP vec2 ATTR4;
ATTR HP vec2 ATTR5;
ATTR HP vec2 ATTR6;
ATTR MP float ATTR7;
ATTR MP vec2 ATTR8;
ATTR HP float ATTR9;
ATTR LP vec4 ATTR10;
ATTR LP vec4 ATTR11;
MP vec3 vtx_nrm(){return ATTR2;}
MP vec3 vtx_tan(){return ATTR3.xyz;}
HP vec4 vtx_pos4(){return ATTR0;}
HP vec3 vtx_pos(){return ATTR0.xyz;}
MP vec3 vtx_hlp(){return ATTR1;}
HP vec2 vtx_tex(const bool can_be_heightmap){return(can_be_heightmap&&bool(VtxHeightmap))?ATTR0.xz*vec2(VtxHeightmap,-VtxHeightmap):ATTR4;}
HP vec2 vtx_tex1(){return ATTR5;}
HP vec2 vtx_tex2(){return ATTR6;}
MP ivec2 vtx_bone(){return bool(VtxSkinning)?ivec2(ATTR8):ivec2(0,0);}
HP float vtx_weight(){return ATTR9;}
LP vec4 vtx_color(){return ATTR11;}
LP vec4 vtx_material(){return ATTR10;}
MP float vtx_size(){return ATTR7;}
struct Matrix3
{
HP vec3 v[3];
};
struct Matrix
{
HP vec4 v[3];
};
struct Matrix4
{
HP vec4 v[4];
};
MP vec3 MatrixX(Matrix m){return vec3(m.v[0].x,m.v[1].x,m.v[2].x);}
MP vec3 MatrixY(Matrix m){return vec3(m.v[0].y,m.v[1].y,m.v[2].y);}
MP vec3 MatrixZ(Matrix m){return vec3(m.v[0].z,m.v[1].z,m.v[2].z);}
HP vec3 MatrixPos(Matrix m){return vec3(m.v[0].w,m.v[1].w,m.v[2].w);}
MP vec3 Transform(MP vec3 v,Matrix3 m)
{
MP vec3 m0=m.v[0],m1=m.v[1],m2=m.v[2];
return vec3(dot(v,m0),
dot(v,m1),
dot(v,m2));
}
MP vec3 Transform3(MP vec3 v,Matrix m)
{
MP vec3 m0=m.v[0].xyz,m1=m.v[1].xyz,m2=m.v[2].xyz;
return vec3(dot(v,m0),
dot(v,m1),
dot(v,m2));
}
HP vec3 Transform(HP vec3 v,Matrix m)
{
return vec3(dot(v,m.v[0].xyz)+m.v[0].w,
dot(v,m.v[1].xyz)+m.v[1].w,
dot(v,m.v[2].xyz)+m.v[2].w);
}
HP vec4 Transform(HP vec3 v,Matrix4 m)
{
return vec4(dot(v,m.v[0].xyz)+m.v[0].w,
dot(v,m.v[1].xyz)+m.v[1].w,
dot(v,m.v[2].xyz)+m.v[2].w,
dot(v,m.v[3].xyz)+m.v[3].w);
}
#define MAX_MATRIX 60
PAR MP float GrassRangeSqr;
PAR MP float BehindBias;
PAR MP vec2 SkyFracMulAdd;
PAR MP vec2 VertexFogMulAdd;
PAR LP vec3 VertexFogColor;
PAR LP vec4 FogColor_Density;
PAR Matrix MatrixCam;
PAR HP vec4 MatrixOC[MAX_MATRIX*3];
PAR HP vec4 MatrixProj[2];
MP vec3 MatrixOC0Y(){return vec3(MatrixOC[0].y,MatrixOC[1].y,MatrixOC[2].y);}
HP vec3 MatrixOC0Pos(){return vec3(MatrixOC[0].w,MatrixOC[1].w,MatrixOC[2].w);}
LP vec3 FogColor(){return FogColor_Density.rgb;}
MP float FogDensity(){return FogColor_Density.a;}
#if 0
HP vec3 TransformPos(HP vec3 v){return Transform(v,MatrixOC0);}
MP vec3 TransformDir(MP vec3 v){return Transform3(v,MatrixOC0);}
HP vec3 TransformPos(HP vec3 v,MP ivec2 bone,HP float weight){return mix(Transform(v,MatrixOC[bone.y]),Transform(v,MatrixOC[bone.x]),weight);}
MP vec3 TransformDir(MP vec3 v,MP ivec2 bone,MP float weight){return mix(Transform3(v,MatrixOC[bone.y]),Transform3(v,MatrixOC[bone.x]),weight);}
#else
HP vec3 TransformPos(HP vec3 v,MP int i)
{
return vec3(dot(v,MatrixOC[i].xyz)+MatrixOC[i].w,
dot(v,MatrixOC[i+1].xyz)+MatrixOC[i+1].w,
dot(v,MatrixOC[i+2].xyz)+MatrixOC[i+2].w);
}
MP vec3 TransformDir(MP vec3 v,MP int i)
{
MP vec3 m0=MatrixOC[i].xyz,m1=MatrixOC[i+1].xyz,m2=MatrixOC[i+2].xyz;
return vec3(dot(v,m0),
dot(v,m1),
dot(v,m2));
}
HP vec3 TransformPos(HP vec3 v){return TransformPos(v,0);}
MP vec3 TransformDir(MP vec3 v){return TransformDir(v,0);}
HP vec3 TransformPos(HP vec3 v,MP ivec2 bone,HP float weight){return mix(TransformPos(v,bone.y*3),TransformPos(v,bone.x*3),weight);}
MP vec3 TransformDir(MP vec3 v,MP ivec2 bone,MP float weight){return mix(TransformDir(v,bone.y*3),TransformDir(v,bone.x*3),weight);}
#endif
HP vec4 Project(HP vec3 v){return v.xyzz*MatrixProj[0]+MatrixProj[1];}
HP vec3 MatrixObjWorldPos(){return Transform(MatrixOC0Pos(),MatrixCam);}
LP float VisibleOpacity(MP float density,MP float range){return pow(1.0-density,range);}
PAR MP vec4 BendTime;
#define GrassBendFreq 1.0
#define GrassBendScale 0.18
#define LeafBendFreq 2.0
#define LeafBendScale 0.13
#define LeafsBendScale (LeafBendScale/2.0)
MP vec2 GetGrassBend(MP vec3 center)
{
MP float offset=Sum(center.xz*(vec2(0.7,0.9)*GrassBendFreq));
return vec2((0.28*GrassBendScale)*sin(offset+BendTime.x)+(0.32*GrassBendScale)*sin(offset+BendTime.y),
(0.18*GrassBendScale)*sin(offset+BendTime.z)+(0.24*GrassBendScale)*sin(offset+BendTime.w));
}
MP vec2 GetLeafBend(MP vec3 center)
{
MP float offset=Sum(center.xy*(vec2(0.7,0.8)*LeafBendFreq));
return vec2((0.28*LeafBendScale)*sin(offset+BendTime.x)+(0.32*LeafBendScale)*sin(offset+BendTime.y),
(0.18*LeafBendScale)*sin(offset+BendTime.z)+(0.24*LeafBendScale)*sin(offset+BendTime.w));
}
MP vec2 GetLeafsBend(MP vec3 center)
{
MP float offset=Sum(center.xy*(vec2(0.7,0.8)*LeafBendFreq));
return vec2((0.28*LeafsBendScale)*sin(offset+BendTime.x)+(0.32*LeafsBendScale)*sin(offset+BendTime.y),
(0.18*LeafsBendScale)*sin(offset+BendTime.z)+(0.24*LeafsBendScale)*sin(offset+BendTime.w));
}
MP float GrassFadeOut()
{
return LerpRS(Sqr(0.8),1.0,Length2(MatrixOC0Pos())/GrassRangeSqr);
}
MP vec3 BendGrass(MP vec3 local_pos)
{
HP vec3 world_pos=MatrixObjWorldPos();
MP float b=Cube(Sat(local_pos.y));
MP vec2 bend=GetGrassBend(world_pos)*(b*length(MatrixOC0Y()));
MP vec3 mc0=MatrixCam.v[0].xyz,mc1=MatrixCam.v[1].xyz;
return mc0*bend.x
+mc1*bend.y;
}
HP vec3 BendLeaf(MP vec3 center,HP vec3 pos)
{
pos-=center;
MP vec2 bend=GetLeafBend(center);
pos.xy=Rotate(pos.xy,vec2(cos(bend.x),sin(bend.x)));
pos.zy=Rotate(pos.zy,vec2(cos(bend.y),sin(bend.y)));
pos+=center;
return pos;
}
HP vec3 BendLeafs(MP vec3 center,MP float offset,HP vec3 pos)
{
pos-=center;
MP vec2 bend=GetLeafsBend(center+offset);
pos.xy=Rotate(pos.xy,vec2(cos(bend.x),sin(bend.x)));
pos.zy=Rotate(pos.zy,vec2(cos(bend.y),sin(bend.y)));
pos+=center;
return pos;
}
void main()
{
gl_Position=Project(TransformPos(vtx_pos()));
IO_tex=vtx_tex(false);
#if COLOR!=0
IO_col=vtx_color();
#endif
}
pixel shader
Code:
#ifndef GL_ES
#define GL_ES
#endif
//GLSL
#extension GL_ARB_shader_texture_lod:enable
#extension GL_EXT_shader_texture_lod:enable
#ifdef GL_ES
precision lowp float;
precision lowp int;
#define texture2DLod texture2DLodEXT
#endif
#define COLOR 0
#define alpha_test 0
#ifdef GL_ES
#define HP highp
#define MP mediump
#define LP lowp
#else
#define HP
#define MP
#define LP
#endif
#define PAR uniform
#define VAR varying
#define EPS 0.0001
#define EPSL 0.01
#define PI 3.14159265
#define PI2 6.28318531
#define SBUMP_ZERO 0
#define SBUMP_FLAT 1
#define SBUMP_NORMAL 2
#define FX_NONE 0
#define FX_GRASS 1
#define FX_LEAF 2
#define FX_LEAFS 3
#define FX_BONE 4
#define Sat(x) clamp(x,0.0,1.0)
MP float Sum(MP vec2 v){return v.x+v.y;}
MP float Sum(MP vec3 v){return v.x+v.y+v.z;}
MP float Sum(MP vec4 v){return v.x+v.y+v.z+v.w;}
MP float Sqr(MP float x){return x*x;}
MP vec2 Sqr(MP vec2 x){return x*x;}
MP float Cube(MP float x){return x*x*x;}
MP float Length2(MP vec2 v){return dot(v,v);}
MP float Length2(MP vec3 v){return dot(v,v);}
MP float Length2(MP vec4 v){return dot(v,v);}
MP vec2 Rotate(MP vec2 vec,MP vec2 cos_sin)
{
return vec2(vec.x*cos_sin.x-vec.y*cos_sin.y,
vec.x*cos_sin.y+vec.y*cos_sin.x);
}
MP float LerpR(MP float from,MP float to,MP float v){return(v-from)/(to-from);}
MP float LerpRS(MP float from,MP float to,MP float v){return Sat((v-from)/(to-from));}
VAR HP vec2 IO_tex;
#if COLOR!=0
VAR LP vec4 IO_col;
#endif
#define AlphaTest(alpha) if(alpha+MaterialColor().a<1.0)discard
PAR sampler2D Col,Col1,Col2,Col3,
Nrm,Nrm1,Nrm2,Nrm3;
PAR samplerCube Rfl;
PAR MP float AllowBackFlip;
#define BackFlip(dir) {if(!gl_FrontFacing)dir*=AllowBackFlip;}
void main()
{
LP vec4 col=texture2D(Col,IO_tex);
#if alpha_test!=0
if(col.a<0.5)discard;
#endif
#if COLOR!=0
col*=IO_col;
#endif
gl_FragColor=col;
}
The shader works on, Adreno GPU, PowerVR Gpu, Mali GPU, Tegra 2/3 and so on.
But your device fails to compile it.
I don't have your device and I can't perform any tests to solve this problem.
Your device is using http://en.wikipedia.org/wiki/Rockchip CPU with http://en.wikipedia.org/wiki/Vivante_Corporation GPU, which seems to be unpopular chips, and it means that their OpenGL implementation may be not as good, on top of that it doesn't produce any message why the linking failed.
However if you see any problem in the shaders that could cause compilation error on your device, then please let me know and I'll check it. Sorry I can't be of more help.
|