Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Opengl es Opengl es glsl位操作等价物_Opengl Es_Bit Manipulation_Glsl_Glsles - Fatal编程技术网

Opengl es Opengl es glsl位操作等价物

Opengl es Opengl es glsl位操作等价物,opengl-es,bit-manipulation,glsl,glsles,Opengl Es,Bit Manipulation,Glsl,Glsles,我正在尝试将一些opengl glsl转换为opengl es(2.0)glsl。我将一个字节值传递到片段着色器中,方法是在代码中将其强制转换为浮点,然后在着色器中将其强制转换回。然后我需要将结果拆分为0-15之间的两个值。对于opengl glsl,我正在使用 int x = int(a_otherdata); int a = (x >> 4) & 0xF; int b = x & 0xF; 但是,由于opengl es不支持按位操作,我尝试了以下操作,但不起作用

我正在尝试将一些opengl glsl转换为opengl es(2.0)glsl。我将一个字节值传递到片段着色器中,方法是在代码中将其强制转换为浮点,然后在着色器中将其强制转换回。然后我需要将结果拆分为0-15之间的两个值。对于opengl glsl,我正在使用

int x = int(a_otherdata);
int a = (x >> 4) & 0xF;
int b = x & 0xF;
但是,由于opengl es不支持按位操作,我尝试了以下操作,但不起作用

int x = int(a_otherdata);
int a = x / 16;
int b = x - (a * 16);

问题是在OpenGLES2.0GLSL中,
int
s实际上可能不是整数;它们可能被实现为浮点数——唯一的保证是基于精度可以保持的整数值范围。所以这个除法可能是一个浮动除法,这意味着如果你想取整它,你需要在那里插入一个
floor
调用:

int a = int(floor(a_otherdata / 16));
int b = int(mod(a_otherdata, 16));