位置: 编程技术 - 正文
推荐整理分享Following the pipeline,希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:,内容如对您有帮助,希望把文章链接给更多的朋友!
1.Passing Data to the Vertex Shader The vertex shader is the first programmable stage in the OpenGL pipeline and has the distinction of being the only mandatory stage in the pipeline.
Vertex Attributes In GLSL,the mechanism for getting data in and out of shaders is to declare global variables with the in and out storage qualifiers. Between stages,in and out can be used to form conduits from shader to shader and pass data between them. Vertex attributes are how vertex data is introduced into the OpenGL pipeline. To declare a vertex attribute,declare a variable in the vertex shader using the in storage qualifier. vertex shader
The vertex attributes is automatically filled in by the fixed-function vertex fetch stage. void glVertexAttrib*(GLuint index, const GLfloat* v);this function can tell the vertex stage what to fill the variable with. The parameter index is used to reference the attribute and v is a pointer to the new data to put into the attribute. the layout qualifier sets the location of the vertex attribute,this location is the value we’ll pass in index to refer to the attribute. Each time we call glVertexAttrib*(),it will update the value of the vertex atrribute that is passed to the vertex shader.
2.Passing Data from Stage to Stage Anything you write to output variables in one shader get sent to similarly named variables declared with the in keyword in the subsequent stage. vertex shader
frame shader
This allow us to pass a color all the way from a vertex attribute that we can set with glVertexAttrib*() through the vertex shader, into the fragment shader and out to the framebuffer.
Interface Blocks In most non-trival applications,you may wish to communicate a number of different pieces of data between stages,and these may include arrays,structures and other complex arrangement of variables.To achieve this,we can group together a number of variables into an interface block.
Interface blocks are matched between stages using the block name(VS_OUT in this case),but are referenced in shaders using the instance name.
3.Tesselation 曲面细分着色器 Tesselation is the process of breaking a high-order primitive(which is known as a patch in Opengl)into many smaller,simpler primitives such as triangles for rendering. Logically,the tesselation phase sits directly after the vertex shading stage in the OpenGL pipeline and is made up of three parts:the tessellation control shader,the fixed-function tessellation engine and the tessellation evaluation shader. Tesselation Control Shader
Tutorial 4: Shaders 本文源自:
FreeGLUT Tips: 详解 glutInit 的入口参数 问题前文我们遇到的问题是,如何正确地给glutInit()这个函数传递一个正确的入口参数,使它能够正确地初始化OpenGL环境。假设大家都在使用VisualC++。当
ios平台中glsl中shadow2DProjEXT函数的简单说明以及变换矩阵的小注意点 一.shadow2DProjEXT函数需要传入一张深度纹理和一个点的坐标(4维)1.这里首先注意的是这张纹理必须使用采样器类型为sampler2DShadow才可以,直接使用sampler
友情链接: 武汉网站建设