Friday, April 8, 2016

opengl es - glsl Expected token ')', found 'identifier' with function mix


I have a Fragment shader that contains:


[...]

float c = texture2D(tex, tc).a;
float alpha = mix(0.0f, 1.0f, c);
gl_FragColor = vec4(1, 1, 1, alpha) * color;

This works fine on my desktop and Nexus 5. However I get an exception while running on a Wiko mobile:


0:22: L0001: Expected token ')', found 'identifier'

Line 22 is the line containing the mix function.


What I'm doing wrong?



Answer




Depending on your driver and GLSL version, the "f" suffix on floats may be illegal. Change to:


float alpha = mix(0.0, 1.0, c);

As always, OS is irrelevant; you really need to say what hardware (in particular what GPU) you have.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...