GLSL: How Do I cast a float into an int?

Posted by dugla on Game Development See other posts from Game Development or by dugla
Published on 2011-02-17T18:43:07Z Indexed on 2011/02/17 23:34 UTC
Read the original article Hit count: 402

Filed under:
|

In a GLSL fragment shader I am trying to cast a float into an int. The compiler has other ideas. It complains thusly:

ERROR: 0:60: '=' :  cannot convert from 'mediump float' to 'highp int'

I am trying to do this:

mediump float indexf = floor(2.0 * mixer);
highp int index = indexf;

I (vainly) tried to raise the precision of the int above the float to appease the GL Gods but no joy.

Could someone please school me here?

Thanks,
Doug

© Game Development or respective owner

Related posts about opengl-es

Related posts about glsl