GLSL 初级教程 – Fragment Processor
来源:互联网 发布:java可移植性 编辑:程序博客网 时间:2024/06/06 05:44
The fragment processor is where the fragment shaders run. This unit is responsible for operations like:
- Computing colors, and texture coordinates per pixel
- Texture application
- Fog computation
- Computing normals if you want lighting per pixel
The inputs for this unit are the interpolated values computed in the previous stage of the pipeline such as vertex positions, colors, normals, etc…
In the vertex shader these values are computed for each vertex. Now we’re dealing with the fragments inside the primitives, hence the need for the interpolated values.
As in the vertex processor, when you write a fragment shader it replaces all the fixed functionality. Therefore it is not possible to have a fragment shader texturing the fragment and leave the fog for the fixed functionality. The programmer must code all effects that the application requires.
The fragment processor operates on single fragments, i.e. it has no clue about the neighboring fragments. The shader has access to OpenGL state, similar to the vertex shaders, and therefore it can access for instance the fog color specified in an OpenGL application.
One important point is that a fragment shader can’t change the pixel coordinate, as computed previously in the pipeline. Recall that in the vertex processor the modelview and projection matrices can be used to transform the vertex. The viewport comes into play after that but before the fragment processor. The fragment shader has access to the pixels location on screen but it can’t change it.
A fragment shader has two output options:
- to discard the fragment, hence outputting nothing
- to compute either gl_FragColor (the final color of the fragment), orgl_FragData when rendering to multiple targets.
Depth can also be written although it is not required since the previous stage already has computed it.
Notice that the fragment shader has no access to the frame buffer. This implies that operations such as blending occur only after the fragment shader has run.
- GLSL 初级教程 – Fragment Processor
- GLSL 初级教程 – Vertex Processor
- GLSL 初级教程 – Introduction
- GLSL 初级教程 – Pipeline Overview
- GLSL 高级教程 – Fragment Shader
- Android初级教程 - Activity 与 Fragment生命周期
- Android初级教程Fragment到Fragment的通信初探
- 初级教程
- GLSL
- GLSL
- Android初级教程理论知识(第十章Fragment与动画)
- GLSL 高级教程 – Introduction
- GLSL 高级教程 – Tessellation
- MyBatis入门初级教程(2) – 框架结构搭建
- GLSL 高级教程 – Vertex Shader
- GLSL 高级教程 – Primitive Assembly
- GLSL 高级教程 – Geometry Shader
- GLSL 高级教程 – Geometry Shader Examples
- 微软安全新闻聚焦-双周刊第十七期
- oracle字符串分割另类思想
- 90=2*3*3*5。分解质因数
- SSL交互过程
- 5个小实例总结
- GLSL 初级教程 – Fragment Processor
- CultureInfo 不同 ToString 的结果不同
- 迭代法
- javascript设计模式--继承(上)
- PS Operate AD
- mysql join 语法说明与 inner join 语法用法实例 (一)
- (ORA-00972:标识符过长)ORACLE 对于表名长度的限制
- 控制台下用Win32 API打开文件对话框
- 当ListView有Header或footer时,onItemClick里的position不正确,可以用getAdapter()