OpenGL在计算着色器中混合GL_TEXTURE_3D的颜色

时间:2016-09-12 16:06:46

标签: opengl-es compute-shader 3d-texture

我不确定它是否是驱动程序错误,但发生以下情况:

计算-shader.glsl

<section id="container">
  <header id="header">This is a header</header>
  <section id="content">
    <aside>
      test<br /> test
      <br /> test
      <br /> test
      <br /> test
      <br /> test
      <br /> test
      <br /> test
      <br /> test
      <br /> test
      <br /> test
      <br /> test
      <br /> test
      <br /> test
      <br /> test
      <br /> test
      <br /> test
      <br /> test
      <br /> test
      <br /> test
      <br /> test
      <br />
    </aside>
    <article id="article">
      <div>
        This is the content that
        <br /> With a lot of lines.
        <br /> With a lot of lines.
        <br /> This is the content that
        <br /> With a lot of lines.
        <br />
        <br /> This is the content that
        <br /> With a lot of lines.
        <br />
        <br /> This is the content that
        <br /> With a lot of lines.
        <br />
      </div>
      <footer id="footer">This is a page footer</footer>
    </article>
  </section>
  <footer id="footer">This is a footer</footer>
</section>

#version 320 es precision mediump float; layout(local_size_x = 16, local_size_y = 8, local_size_z = 1) in; layout(rgba8ui, binding = 0) writeonly uniform mediump uimage2D image; layout(binding = 1) uniform mediump usampler3D grid; void main() { uint i = gl_GlobalInvocationID.y; uint j = gl_GlobalInvocationID.x; uvec4 val = texture(grid, vec3(float(i)/480.0,float(j)/640.0,0.5)); imageStore(image, ivec2(j,i), val); } 的颜色通道完全被扰乱:

  • alpha = blue
  • red = red
  • 绿色 = alpha
  • 蓝色 = 绿色

的main.cpp

val

对此有合理的解释吗?注意:我不想使用hack glActiveTexture(GL_TEXTURE1); glEnable(GL_TEXTURE_3D); glBindTexture(GL_TEXTURE_3D, grid_tex_id); glTexStorage3D(GL_TEXTURE_3D, 1, GL_RGBA8, 256, 256, 256); glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, 256, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, grid.data); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); (即使存在)。

1 个答案:

答案 0 :(得分:2)

pandas.ExcelFile

import pandas as pd xlsx = pd.ExcelFile(fName) dataFrame = pd.read_excel(xlsx, sht, parse_cols=21, merge_cells=noMerge, header=header) return dataFrame 不是整数格式;它是规范化的格式。这意味着它等同于浮点格式。因此,您应该使用layout(binding = 1) uniform mediump usampler3D grid; ... glTexStorage3D(GL_TEXTURE_3D, 1, GL_RGBA8, 256, 256, 256); ,而不是GL_RGBA8。或者您应该使用sampler3D像素传输格式将数据上传为usampler3D等整数格式。

您可能会使用re-specifying the format in the shader itself的图像加载/存储来逃避它。你无法用纹理做到这一点。