位置: 编程技术 - 正文

The graphics pipeline ,Open GL 渲染管线

编辑:rootadmin

推荐整理分享The graphics pipeline ,Open GL 渲染管线,希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:,内容如对您有帮助,希望把文章链接给更多的朋友!

来源: Ever since the early days of real-time 3d, the triangle has been the paintbrush with which scenes have been drawn. Although modern GPUs can perform all sorts of flashy effects to cover up this dirty secret, underneath all the shading, triangles are still the medium in which they work. The graphics pipeline that OpenGL implements reflects this: the host program fills OpenGL-managed memory buffers with arrays of vertices; these vertices are projected into screen space, assembled into triangles, and rasterized into pixel-sized fragments; finally, the fragments are assigned color values and drawn to the framebuffer. Modern GPUs get their flexibility by delegating the “project into screen space” and “assign color values” stages to uploadable programs called shaders. Let’s look at each stage in more detail:

The vertex and element arrays A rendering job starts its journey through the pipeline in a set of one or more vertex buffers, which are filled with arrays of vertex attributes. These attributes are used as inputs to the vertex shader. Common vertex attributes include the location of the vertex in 3d space, and one or more sets of texture coordinates that map the vertex to a sample point on one or more textures. The set of vertex buffers supplying data to a rendering job are collectively called the vertex array. When a render job is submitted, we supply an additional element array, an array of indexes into the vertex array that select which vertices get fed into the pipeline. The order of the indexes also controls how the vertices get assembled into triangles later on.

Uniform state and textures A rendering job also has uniform state, which provides a set of shared, read-only values to the shaders at each programmable stage of the pipeline. This allows the shader program to take parameters that don’t change between vertices or fragments. The uniform state includes textures, which are one-, two-, or three-dimensional arrays that can be sampled by shaders. As their name implies, textures are commonly used to map texture images onto surfaces. They can also be used as lookup tables for precalculated functions or as datasets for various kinds of effects.

The vertex shader The GPU begins by reading each selected vertex out of the vertex array and running it through the vertex shader, a program that takes a set of vertex attributes as inputs and outputs a new set of attributes, referred to as varying values, that get fed to the rasterizer. At a minimum, the vertex shader calculates the projected position of the vertex in screen space. The vertex shader can also generate other varying outputs, such as a color or texture coordinates, for the rasterizer to blend across the surface of the triangles connecting the vertex.

Triangle assembly

The graphics pipeline ,Open GL 渲染管线

The GPU then connects the projected vertices to form triangles. It does this by taking the vertices in the order specified by the element array and grouping them into sets of three. The vertices can be grouped in a few different ways:

Take every three elements as an independent triangle Make a triangle strip, reusing the last two vertices of each triangle as the first two vertices of the next Make a triangle fan, connecting the first element to every subsequent pair of elements The diagram shows how the three different modes behave. Strips and fans both require only one new index per triangle in the element array after the initial three, trading the flexibility of independent triangles for extra memory efficiency in the element array.

Rasterization

The rasterizer takes each triangle, clips it and discards parts that are outside of the screen, and breaks the remaining visible parts into pixel-sized fragments. As mentioned above, the vertex shader’s varying outputs are also interpolated across the rasterized surface of each triangle, assigning a smooth gradient of values to each fragment. For example, if the vertex shader assigns a color value to each vertex, the rasterizer will blend those colors across the pixelated surface as shown in the diagram.

The fragment shader The generated fragments then pass through another program called the fragment shader. The fragment shader receives the varying values output by the vertex shader and interpolated by the rasterizer as inputs. It outputs color and depth values that then get drawn into the framebuffer. Common fragment shader operations include texture mapping and lighting. Since the fragment shader runs independently for every pixel drawn, it can perform the most sophisticated special effects; however, it is also the most performance-sensitive part of the graphics pipeline.

Framebuffers, testing, and blending A framebuffer is the final destination for the rendering job’s output. In addition to the default framebuffer OpenGL gives you to draw to the screen, most modern OpenGL implementations let you make framebuffer objects that draw into offscreen renderbuffers or into textures. Those textures can then be used as inputs to other rendering jobs. A framebuffer is more than a single 2d image; in addition to one or more color buffers, a framebuffer can have a depth buffer and/or stencil buffer, both of which optionally filter fragments before they are drawn to the framebuffer: Depth testing discards fragments from objects that are behind the ones already drawn, and stencil testing uses shapes drawn into the stencil buffer to constrain the drawable part of the framebuffer, “stencilling” the rendering job. Fragments that survive these two gauntlets have their color value alpha blended with the color value they’re overwriting, and the final color, depth, and stencil values are drawn into the corresponding buffers.

Conclusion That’s the process, from vertex buffers to framebuffer, that your data goes through when you make a single “draw” call in OpenGL. Rendering a scene usually involves multiple draw jobs, switching out textures, other uniform state, or shaders between passes and using the framebuffer’s depth and stencil buffers to combine the results of each pass. Now that we’ve covered the general dataflow of 3d rendering, we can write a simple program to see how OpenGL makes it all happen. Throughout the course of this tutorial, I’d love to get your feedback—let me know if it’s helping you or if anything doesn’t make sense.

Following the pipeline 1.PassingDatatotheVertexShaderThevertexshaderisthefirstprogrammablestageintheOpenGLpipelineandhasthedistinctionofbeingtheonlymandatorystageinthepipeline.VertexAttributesInGLSL,themechanismforgettingda

Tutorial 4: Shaders 本文源自:

FreeGLUT Tips: 详解 glutInit 的入口参数 问题前文我们遇到的问题是,如何正确地给glutInit()这个函数传递一个正确的入口参数,使它能够正确地初始化OpenGL环境。假设大家都在使用VisualC++。当

标签: The graphics pipeline ,Open GL 渲染管线

本文链接地址:https://www.jiuchutong.com/biancheng/369418.html 转载请保留说明!

上一篇:openGL4.X 深度测试(depth testing) framebuffer中(opengl 4.2)

下一篇:Following the pipeline

  • 税务局纳税申报网站官网
  • 分公司所得税汇算清缴
  • 幼儿园财务科目设置
  • 汽车申请报废了交强险能退吗
  • 企业变更法人的流程网上申请变更
  • 个税申报信息怎么恢复
  • 8.会计核算方法具体包括哪些内容?
  • 发票红冲原票怎么处理
  • 员工全额承担社保账务怎么做?
  • 期间费用包括资本公积吗
  • 虚开增值税发票的涉税风险如何防范
  • 财务费用中的汇兑损益记在现金流表哪里
  • 企业免征土地使用税吗
  • 外购的自用小轿车
  • 增值税普通发票怎么开
  • 建筑业交税会计分录
  • 白酒五行属火还是水
  • 小规模跨年发票可以入账吗
  • 扣缴上月税费会计分录
  • 企业外币账户清单哪里能查到
  • 年终奖个人所得税缴纳标准
  • 管理人员预借差旅费会计分录怎么写
  • 利息如何做会计分录
  • 失业保险稳岗补贴是给个人的还是给企业的
  • 发生债务重组收益的分录
  • 如何进行抵债资金管理
  • 如何安装iis网站服务器
  • php生成php文件
  • php中分页功能的实现
  • 如何办理车辆购置证变更手续
  • 企业取得的搬迁补贴
  • 无形资产租金计入什么会计科目里
  • eslint不起作用
  • 计算机领域划分
  • Ubuntu18.04配置允许远程访问
  • node.js快速入门
  • php initialize
  • 企业收到发票冲销怎么办
  • 个税申报可以作废重新申报吗
  • 残保金的计费依据
  • 开了银行对公账户要多久
  • 进销存表格模板明细账
  • cms是前端还是后端
  • RedHat6.5/CentOS6.5安装Mysql5.7.20的教程详解
  • 辞退员工补偿金计入什么科目
  • 给天猫开的服务怎么关闭
  • 收到生育津贴会计分离
  • 对公账户转到个人账户怎么做账
  • 购买的服务如何申请退款
  • 红字发票抵扣联和发票联要给对方吗
  • 不动产计提折旧时间
  • 文化传媒公司的主营业务
  • 利润所得税费用
  • 工程投标保证金什么时候交
  • 利润表期初余额怎么填
  • 金蝶旗舰版的数据怎么在标准版打开
  • 核定征收也需要报税务报表吗?
  • 保险赔偿收入如何减税额
  • 非关联企业之间可以借款吗
  • 收到进项发票不认证抵扣的会计分录
  • 实收资本是什么公司
  • centos启动不了图形界面
  • deepin-win
  • winxp共享打印机win11
  • 如何判断电脑是不是linux
  • 电脑系统win8怎么样
  • win7桌面怎么设置到d盘
  • unity怎么bake
  • 批处理删除空文件夹
  • perl读取文件内容
  • jquery插件库怎么导入
  • github 最火的项目
  • Android -- service两种启动方式startService与bindService
  • jquery插件使用教程
  • jquery左右选择框
  • git 删除分支和回滚的实例详解
  • python文本文件操作步骤
  • XRegExp 0.2: Now With Named Capture
  • 重庆市劳动监察大队官网
  • 一季度土地市场
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设