firefox - bit-wise operator supported in GLSL ES 3.00 and above only -
i'm trying make function bit position color in glsl.
precision highp float; uniform sampler2d utexture0; varying vec2 vtexturecoords; int getbit(float color, int bit){ highp int colorint = int(color); return (colorint >> bit) & 1; } void main(void) { highp vec4 texelcolour = texture2d(utexture0, vec2(vtexturecoords.s, vtexturecoords.t)); if(getbit(texelcolour.r * 255.0, 7) == 1 ){ gl_fragcolor = vec4(0.5, 0.8, 0.5, 0.8); }else{ gl_fragcolor = vec4(0.4, 0.1, 0.0, 0.0); }
}
chrome , firefox return error
error: 0:35: '>>' : bit-wise operator supported in glsl es 3.00 , above error: 0:35: '&' : bit-wise operator supported in glsl es 3.00 , above
i'm trying force version in first line of shader, :
#version 130
but console return version not supported.
is there way create subroutines getbit function ? or settings enable implements bitwize operator in sharder fragment ?
thanks reply.
guillaume
i'm finding solution in writing own , shift function
int getbit(float num, float b){ num = num * 255.0; int bit = 0; for(int = 7; >= 0; i--){ if(num >= pow(2.0,float(i))){ num = num - pow(2.0,float(i)); if(b == float(i)){ bit = 1; } } } return bit; } if(getbit(texelcolour.r , 3.0) != 0 && getbit(texelcolour.g * 255.0, 0.0) == 0 && getbit(texelcolour.b * 255.0, 0.0) == 0){ gl_fragcolor = vec4(0.5, 0.8, 0.5, 0.8); }else{ gl_fragcolor = vec4(0.4, 0.1, 0.0, 0.0); }
i'm newb in glsl can surely better works.
ps: need 1 byte decimal
guillaume
Comments
Post a Comment