- Home /
Question by
artie · Jan 21, 2014 at 12:22 AM ·
shadertypeconversionnumbers
Can I convert numeric types in a Shader?
I have two textures I need to process in a shader (depth maps). One is float, the other is short (integer).
Can I do some kind of type conversion? Or are shaders able to compare floats and ints?
Comment
Best Answer
Answer by Benproductions1 · Jan 21, 2014 at 02:21 AM
In GLSL you can cast using the type, for instance:
int value = int(float_value);
or for vectors:
vec4 vector = vec4(3d_vector, float(integer));
It's quite smart in that manour.