Thanks for checking. Meanwhile i did my homework. Here are the result:

http://www.youtube.com/watch?v=gYWcfz42B-w

You can see in this video i have made one shader with the 2 options. I am very unfamiliar with shaders, so i have not been able to switch from onse shader to the other from a running program. Actually, i have, but the result is crazy, so i quit. So, to go from one shader to the other you must comment one of the 2 lines as shown in the video. I really dont understand what is going on. Can anyone help please?

I have the feeling the root cause is around how the shaders are implemented in ios5.1 or ipad1 or codea support of these, or a tricky combination of the three…

Here is the code:

```
--# SphereShader
sphereShader = {
vertexShader = [[
uniform mat4 modelViewProjection;
attribute vec4 position;
attribute vec4 color;
attribute vec2 texCoord;
varying lowp vec4 vColor;
varying highp vec2 vTexCoord;
void main()
{
vColor=color;
vTexCoord = texCoord;
gl_Position = modelViewProjection * position;
}
]],
fragmentShader = [[
precision highp float;
uniform float model;
uniform lowp sampler2D texture;
uniform float time;
uniform float fraction;
uniform float height;
uniform vec3 light;
highp float h = height*height;
highp float rh = h/(h-1.);
highp float sqrh = sqrt(rh);
varying lowp vec4 vColor;
varying highp vec2 vTexCoord;
varying vec4 vPosition;
void main()
{
vec2 p = (-1.0 + 2.0 * vTexCoord)/sqrh;
float r = dot(p,p);
if (r > 1.0) discard;
vec2 uv;
vec2 uv1;
vec2 uv2;
// texture coordinates according to Ignatz
float f = 0.5*(1.0-sqrt(1.0-r))/r;
uv1.x = mod( fraction+p.x*f + time , 1.0 );
uv1.y = mod( fraction+p.y*f + time , 1.0 );
// texture coordinates according to Andrew
float t = (h + sqrt(r - r*h + h))/(r+h);
float phi = 1.-acos(t*p.y)/3.1415;
float theta = atan((1.-t)*height,t*p.x) / (2.*3.1415) + time ;
uv2.x = mod( theta , 1.0 );
uv2.y = mod( phi , 1.0 );
// choose uv according to model
// attempt to do it from parameter, but the result is crazy and i dont understand why.
// if (model<0.5) uv = uv1;
// if (model>0.5) uv = uv2;
// choose manually your model by commenting one of the lines:
//uv = uv1;
uv = uv2;
// set the texture coordinates
vec4 c = texture2D( texture, uv );
// shadow application
float l = max(0.,t*dot(p.xy,light.xy) + (1.-t)*height*light.z);
gl_FragColor = vec4(l*c.xyz, 1.0);
}
]]}
--# Main
-- sphere shader 2
-- by andrew stacey
function setup()
m=mesh()
img0=readImage("Cargo Bot:Codea Icon") --select your image here <<<<<
mm=math.min(img0.width,img0.height)
img=img0:copy(1,1,mm,mm) --make it square
m:addRect(WIDTH/2,HEIGHT/2,400,400) --add a rectangle to our mesh, the size you want (square)
m.texture=img
m.shader=shader(
sphereShader.vertexShader,sphereShader.fragmentShader)
m.shader.height=15
m.shader.light = vec3(1,1,0):normalize()
m:setColors(color(255))
light_azimuth = 0
light_zenith = 0
local reset_light = function()
m.shader.light = vec3(
math.cos(math.rad(light_azimuth))
* math.sin(math.rad(light_zenith)),
math.cos(math.rad(light_zenith)),
math.sin(math.rad(light_azimuth))
* math.sin(math.rad(light_zenith))
)
end
model = 0.0
m.shader.model = model
local setModel = function() m.shader.model = model*1.0 end
parameter.integer("model",0,1,0,setModel)
parameter.integer("light_azimuth",-180,180,-34,reset_light)
parameter.integer("light_zenith",0,180,90,reset_light)
end
function draw()
background(40, 40, 50)
m.shader.time=ElapsedTime/10 --vary the time speed to change the rotation speed of the sphere
m:draw()
end
```