且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

OpenGL-特定深度的像素颜色

更新时间:2023-11-08 11:39:28

您并不是第一个因这种误解而堕落的人,因此我说的是最直截了当的方式:OpenGL不能那样工作. OpenGL never(!)处理对象或任何复杂的场景. OpenGL唯一了解的是帧缓冲区,着色器和单个三角形.每当您绘制通常由三角形组成的对象时,OpenGL一次只会看到每个三角形.并且一旦将某些内容吸引到帧缓冲区,以前丢失的内容都会丢失.

You're not the first to fall for this misconception, so I say it the most blunt way possible: OpenGL doesn't work that way. OpenGL never(!) deals with objects or any complex scenes. The only thing OpenGL knows about are framebuffers, shaders and single triangles. Whenever you draw an object, usually composed of triangles, OpenGL will only see each triangle at a time. And once something has been drawn to the framebuffer, whatever has been there before is lost.

有一些基于光栅化器概念的算法(例如OpenGL是),可以将渲染的场景分解为各个部分,深度剥离就是其中之一.

There are algorithms based on the concepts of rasterizers (like OpenGL is) that decompose a rendered scene into it's parts, depth peeling would be one of them.