如何将许多顶点输入到几何着色器,缓冲区和着色器相互传递数据?

发布于 2025-02-10 20:03:43 字数 894 浏览 0 评论 0原文

我想在Android上执行散景应用程序,使用OpenGL ES 3.0,我阅读本文 /a>:

  1. 做一个全部散景点提取通行证。对于每个像素,计算像素周围5x5块的平均亮度和 将其与当前像素的亮度进行比较。如果像素 亮度减去平均亮度超过一定阈值 COC大小高于一定阈值,按像素 位置 +颜色 + COC大小到附加缓冲区并输出值 0.0作为像素颜色。如果没有通过阈值,请输出 输入颜色。

  2. 进行常规的DOF通行证。我实施了两个版本:一个 在两次通过的两次传球中使用16个样品在Poisson上进行全盘光盘的模糊 半径== coc大小,而圆盘的圆盘是ye Olde 1/4-res 高斯模糊(带有边缘出血的降低)和全屏LERP 在非毛发和模糊版本之间。

  3. 将嵌入式计数从附加缓冲区复制到另一个缓冲区, 并使用第二个缓冲区作为间接参数缓冲区 drawinstancanceDirect呼叫。基本上,这使我们能吸引很多 点在缓冲区中,而无需复制任何内容 CPU。每个点的顶点着色器,然后样品 位置/颜色/COC大小从附加的缓冲区,并将其传递给 几何着色器,将点扩展到尺寸相等的四边形 到COC大小。像素着色器然后从纹理中取样 包含光圈形,并将结果融合到 一个空的渲染目标。渲染目标可以是完整的,也可以 1/4 res节省带宽。

因为我对OpenGL ES了解不多,所以我不知道如何在上述大胆方面实现,所以Java如何将片段着色器的结果推向缓冲区和缓冲区的内容到几何形状着色器?你能给我一些演示或例子吗?

I want do a bokeh app on Android, use OpenGL ES 3.0, I read this article How To Fake Bokeh:

  1. Do a full-res bokeh point extraction pass. For each pixel, compute the average brightness of the 5x5 block surrounding the pixel and
    compare it with the brightness of the current pixel. If the pixel
    brightness minus the average brightness is above a certain threshold
    and the CoC size is above a certain threshold, push the pixel
    position + color + CoC size onto an append buffer and output a value
    of 0.0 as the pixel color
    . If it doesn’t pass the threshold, output
    the input color.

  2. Do a regular DOF pass. I implemented two versions: one that does a
    full-res disc-based blur in two passes using 16 samples on a Poisson
    disc with radius == CoC size, and one that does ye olde 1/4-res
    Gaussian blur (with edge bleeding reduction) and a full-screen lerp
    between the un-blurred and blurred version.

  3. Copy the embedded count from the append buffer to another buffer,
    and use the second buffer as an indirect arguments buffer for a
    DrawInstancedIndirect call. Basically this lets us draw however many
    points are in the buffer, without having to copy anything back to
    the CPU. The vertex shader for each point then samples the
    position/color/CoC size from the append buffer and passes it to the
    geometry shader, which expands the point into a quad with size equal
    to the CoC size
    . The pixel shader then samples from a texture
    containing the aperture shape, and additively blends the result into
    an empty render target. The render target can be either full res, or
    1/4 res to save on bandwidth.

Because I don't know much about OpengL ES, I don't know how to implement above bold, How does Java push the results of the fragment shader to the buffer and the contents of the buffer to the geometry shader? Can you give me some demo or example?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文