二进制或帧缓冲区混合

Binary OR framebuffer blending

我目前正在研究 this 研究论文中描述的算法,但是我遇到了一部分我不清楚它是如何实现的。

A grid is defined by placing a camera above the scene and adjusting its view frustum to enclose the area to be voxelized. This camera has an associated viewport with (w, h ) dimensions. The scene is then rendered, constructing the voxelization in the frame buffer. A pixel (i,j) represents a column in the grid and each voxel within this column is binary encoded using the k th bit of the RGBA value of the pixel. Therefore, the corresponding image represents a w×h×32 grid with one bit of information per voxel. This bit indicates whether a primitive passes through a cell or not. The union of voxels corresponding to the kth bit for all pixels defines a slice. Consequently, the image/texture encoding the grid is called a slicemap . When a primitive is rasterized, a set of fragments are obtained. A fragment shader is used in order to determine the position of the fragment in the column based on its depth. The result is then OR−ed with the current value of the frame buffer.

大概可以通过将 blend equation 设置为使用二进制或来实现这一点,但是这不是一个可用的选项,我看不到通过操纵 glBlendFunc() 来实现它的方法+glBlendEquation()

此外,根据我的理解,不可能在片段着色器中读取帧缓冲区。您可以将纹理绑定到着色器和帧缓冲区,但是由于缺乏同步,在着色器中访问它是 undefined behaviour

本文没有说明使用的是 OpenGL 还是 Direct-X,但是 best of my understanding 它具有相同的 glBlendEquation() 限制。

我是不是漏掉了什么?

我意识到我可以在 32 遍中简单地获得相同的结果。

OpenGL 有一个单独的 glLogicOp() 用于在帧缓冲区上执行逻辑操作。

这可以使用

配置和启用
glLogicOp(GL_OR);
glEnable(GL_COLOR_LOGIC_OP);

尽管标志是 GL_COLOR_LOGIC_OP,文档暗示这也将涵盖 alpha 值。

引用中描述的稍微好一点26