Hello,

i have very strange experience on those 3 phones. All of those should have Power SGX 540 chip but i’ve got different results compiling shaders.

Samsung S9100 - android 2.3.6 - compile ok

Samsung Galaxy S - android 4.2.1 - compile failed without reason

Samsung S9000 - android ? - compile crash

I also tested this shader in 4 shader compilers - SGX 535, 540, 543, 6xx and all went fine.

I also tested it in windows emulator - all goes fine

So, it seems to me like shader version problem, so can you, please, help me, what to do with it ?

If it compiles, everything goes fine - no artefacts seen

Best regards and thanks

Petr Sovis

Vertex shader:

#define vxIn attribute

#define vxOut varying

#line 47 2

#define VX_UNIFORMN(typeprec,type,var,tag) uniform typeprec type var

#define VX_UNIFORMDV(typeprec, type, var, tag, defaultValue) uniform typeprec type var

#define vxTex2D texture2D

#define nop

#line 4 3

VX_UNIFORMN(highp , mat4, matProjModelView, MATRIX);

VX_UNIFORMN(highp , mat4, matModelView, MATRIX);

VX_UNIFORMN(highp , mat4, matProjection, MATRIX);

VX_UNIFORMN(highp , vec3, vecCameraPos, VEC3);

VX_UNIFORMN(lowp , sampler2D, DiffuseTex, SAMPLER2D);

VX_UNIFORMN(lowp , sampler2D, SpecTex, SAMPLER2D);

VX_UNIFORMN(lowp , sampler2D, NormalTex, SAMPLER2D);

VX_UNIFORMN(lowp , vec4, AmbientCol, COLOR);

#line 2 4

const lowp vec3 globalAmbient = vec3(104.0,103.0,159.0) * (1.0 / 255.0);

const lowp vec3 globalAmbientCatcher = vec3(204.0,203.0,209.0) * (1.0 / 255.0);

const lowp vec3 lightDiff = vec3(240.0,217.0,175.0) * (1.0 / 255.0);

const lowp vec3 lightSpecColor = lightDiff;

const mediump vec3 lightPos = vec3(0.0,-3.0,1.0);

const lowp vec3 light2Diff = vec3(195.0,209.0,253.0) * (0.7 / 255.0);

const lowp vec3 light2SpecColor = light2Diff;

const lowp vec3 light2Dir = normalize(vec3(2.0,5.0,0.0));

#line 22 5

vxIn vec3 inPos;

vxIn vec3 inNormal;

vxIn vec2 inTex0;

vxIn vec3 inTangent;

vxIn vec3 inBinormal;

vxOut mediump vec2 interTex0;

vxOut mediump vec3 interLightVec;

vxOut mediump vec3 interLightVec2;

vxOut mediump vec3 interEyeVec;

vxOut mediump vec3 interHalfVec;

vxOut mediump vec3 interHalfVec2;

void saEnemyVertexFn()

{

highp vec3 outPos;

lowp mat3 mmVN = mat3(matModelView);

outPos = (matModelView * vec4(inPos,1.0)).xyz;

lowp vec3 trNormal = normalize(mmVN * inNormal);

lowp vec3 trTangent = normalize(mmVN * inTangent);

lowp vec3 trBinormal = normalize(mmVN * inBinormal);

lowp vec3 lightDir = normalize(lightPos - outPos);

interLightVec.x = dot(trTangent, lightDir);

interLightVec.y = dot(trBinormal, lightDir);

interLightVec.z = dot(trNormal, lightDir);

interLightVec2.x = dot(trTangent, light2Dir);

interLightVec2.y = dot(trBinormal, light2Dir);

interLightVec2.z = dot(trNormal, light2Dir);

mediump vec3 v, no;

no = normalize(vecCameraPos - outPos);

v.x = dot(trTangent, no);

v.y = dot(trBinormal, no);

v.z = dot(trNormal, no);

interEyeVec = normalize(v);

v = normalize(no + lightDir);

interHalfVec.x = dot(trTangent, v);

interHalfVec.y = dot(trBinormal, v);

interHalfVec.z = dot(trNormal, v);

v = normalize(no + light2Dir);

interHalfVec2.x = dot(trTangent, v);

interHalfVec2.y = dot(trBinormal, v);

interHalfVec2.z = dot(trNormal, v);

gl_Position = matProjection * vec4(outPos, 1.0);

interTex0 = inTex0;

}

#line 0 7

void main() { saEnemyVertexFn(); }

Fragmen shader:

#ifdef GL_FRAGMENT_PRECISION_HIGH

#else

#define highp mediump

#endif

#define nomeaning

#define vxIn varying

#define vxOut(x) nomeaning

#define vxPixelResult gl_FragColor

#line 47 2

#define VX_UNIFORMN(typeprec,type,var,tag) uniform typeprec type var

#define VX_UNIFORMDV(typeprec, type, var, tag, defaultValue) uniform typeprec type var

#define vxTex2D texture2D

#define nop

#line 4 3

VX_UNIFORMN(highp , mat4, matProjModelView, MATRIX);

VX_UNIFORMN(highp , mat4, matModelView, MATRIX);

VX_UNIFORMN(highp , mat4, matProjection, MATRIX);

VX_UNIFORMN(highp , vec3, vecCameraPos, VEC3);

VX_UNIFORMN(lowp , sampler2D, DiffuseTex, SAMPLER2D);

VX_UNIFORMN(lowp , sampler2D, SpecTex, SAMPLER2D);

VX_UNIFORMN(lowp , sampler2D, NormalTex, SAMPLER2D);

VX_UNIFORMN(lowp , vec4, AmbientCol, COLOR);

#line 2 4

const lowp vec3 globalAmbient = vec3(104.0,103.0,159.0) * (1.0 / 255.0);

const lowp vec3 globalAmbientCatcher = vec3(204.0,203.0,209.0) * (1.0 / 255.0);

const lowp vec3 lightDiff = vec3(240.0,217.0,175.0) * (1.0 / 255.0);

const lowp vec3 lightSpecColor = lightDiff;

const mediump vec3 lightPos = vec3(0.0,-3.0,1.0);

const lowp vec3 light2Diff = vec3(195.0,209.0,253.0) * (0.7 / 255.0);

const lowp vec3 light2SpecColor = light2Diff;

const lowp vec3 light2Dir = (vec3(2.0,5.0,0.0));

#line 88 6

vxIn mediump vec2 interTex0;

vxIn mediump vec3 interLightVec;

vxIn mediump vec3 interLightVec2;

vxIn mediump vec3 interEyeVec;

vxIn mediump vec3 interHalfVec;

vxIn mediump vec3 interHalfVec2;

vxOut( vec4 vxPixelResult)

lowp vec3 specLighting(lowp vec3 bumpVec, lowp vec3 texDiffuse, lowp float texSpec, lowp vec3 lightDiffuse, lowp vec3 lightSpec, lowp vec3 pILD, lowp vec3 eyeVec, lowp vec3 halfVec)

{

lowp float diffFact = max(dot(pILD, bumpVec), 0.0);

lowp vec3 baseColor = texDiffuse * (lightDiffuse * diffFact);

if (diffFact > 0.0)

{

mediump float shininess = pow (max (dot (halfVec, bumpVec), 0.0), 1.0);

baseColor += lightSpec * (texSpec * shininess);

};

return baseColor;

}

void saEnemyPixelFn()

{

mediump vec3 bumpVec = vxTex2D(NormalTex, interTex0).xyz * 2.0 - 1.0;

lowp vec4 texDiffuse = vxTex2D(DiffuseTex, interTex0);

bumpVec.x = -bumpVec.x;

vxPixelResult.xyz = texDiffuse.xyz * globalAmbient;

vxPixelResult.xyz += specLighting(bumpVec, texDiffuse.xyz, texDiffuse.a, lightDiff, lightSpecColor, interLightVec, interEyeVec, interHalfVec);

vxPixelResult.xyz += specLighting(bumpVec, texDiffuse.xyz, texDiffuse.a, light2Diff, light2SpecColor, interLightVec2, interEyeVec, interHalfVec2);

vxPixelResult.a = 1.0;

}

#line 0 8

void main() { saEnemyPixelFn(); }