I trying to compile program (I have previously ported it from Cg
language). Fragment shader is
precision mediump float;
precision mediump int;
uniform float time;
uniform float aspect;
uniform sampler2D sampler_main;
varying vec4 v_texCoord;
void main()
{
vec3 ret;
vec2 uv = v_texCoord.xy;
float rad=sqrt((uv.x-0.5)*(uv.x-0.5)*4.0+(uv.y-0.5)*(uv.y-0.5)*4.0)*.7071067;
float ang=atan(((uv.y-0.5)*2.0),((uv.x-0.5)*2.0));
vec2 uv1 = (uv-0.5)*aspect.xy;
float rad1 = .1/(length(uv1) + .1)) ;
vec2 uv2 = vec2 (ang/3.14, rad1);
uv2.y = uv2.y +0.1*time;
uv2.x = uv2.x +.0*time;
vec2 uv3 = vec2 (ang/3.14, rad1*1.5);
uv3.y = uv3.y + 0.08*time ;
uv3.x = uv3.x + time/32;
vec3 crisp = 2*texture2D(sampler_main, uv2).xyz;
vec3 lay1 = vec3 (0,0,1)*uv.y*pow(1-rad,8);
crisp = 3*crisp * pow(rad,1);
float mask = saturate(1-4*rad);
ret = crisp + lay1*mask + mask * texture2D(sampler_main, uv).xyz;
gl_FragColor.xyz = ret;
gl_FragColor.w = 1.0;
}
I got error on line
uv3.x = uv3.x + time/32;
When I change it to
uv3.x = uv3.x + time/32.0;
Problem is solved, but I don't understand the root of the problem.
The same problem for the line
float mask = saturate(1-4*rad); => float mask = saturate(1.0-4.0*rad);
vec3 crisp = 2*texture2D(sampler_main, uv2).xyz; => vec3 crisp = 2.0*texture2D(sampler_main, uv2).xyz;
vec3 lay1 = vec3 (0,0,1)*uv.y*pow(1-rad,8); => vec3 lay1 = vec3 (0,0,1)*uv.y*pow(1.0-rad,8.0);
crisp = 3*crisp * pow(rad,1); => crisp = 3.0*crisp * pow(rad,1.0);
Could someone explain:
Implicit casts are not allowed in early GLSL. So try an explicit cast:
uv3.x = uv3.x + time/float(32);
The GLSL 1.1 Spec says in Chapter 4 (page 16):
The OpenGL Shading Language is type safe. There are no implicit conversions between types
Recent GLSL allows implicit type casts. The GLSL 4.4 Spec says in Chapter 4 (page 25):
The OpenGL Shading Language is type safe. There are some implicit conversions between types. Exactly how and when this can occur is described in section 4.1.10 “Implicit Conversions” and as referenced by other sections in this specification.
And later on starting at page 39 there is a list of possible implicit conversions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With