1
GLSLで色のビット位置を取得する関数を作成しようとしています。GLSL ES 3.00以降でサポートされているビット単位演算子
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はこのエラーを返す
ERROR: 0:35: '>>' : bit-wise operator supported in GLSL ES 3.00 and above only
ERROR: 0:35: '&' : bit-wise operator supported in GLSL ES 3.00 and above only
私はこのように、私のシェーダの1行目にバージョンを強制しようとしている:
#version 130
ですが、コンソールはバージョンがサポートされていないことを返します。
getBit関数のサブルーチンを作成する方法はありますか? またはsharderフラグメントでbitwize演算子を実装するために有効にする設定は?
お返事ありがとうございます。
ギヨーム