Reading current framebuffer

后端 未结 2 363
萌比男神i
萌比男神i 2021-01-21 01:53

Is there a way to read fragment from the framebuffer currently rendered?

So, I\'m looking for a way to read color information from the fragment that\'s on the place that

2条回答
  •  暖寄归人
    2021-01-21 02:39

    Your question seems rather confused.

    Part of your question (the first sentence) asks if you can read from the framebuffer in the fragment shader. The answer is, generally no. There is an OpenGL ES 2.0 extension that lets you do so, but it's only supported on some hardware. In desktop GL 4.2+, you can use arbitrary image load/store to get the same effect. But you can't render to that image anymore; you have to write your data using image storing functions.

    gl_LastFragData is pretty simple: it's the color from the sample in the framebuffer that will be overwritten by this fragment shader. You can do with it what you wish, if it is available.

    The second part of your question (the second paragraph) is a completely different question. There, you're asking about fragments that were potentially never written to the framebuffer. You can't read from a fragment shader; you can only read images. And if a fragment fails the depth test, then it's data was never rendered to an image. So you can't read it.

提交回复
热议问题