OpenGL ES 3.0流程圖
1.Vertex Shader(頂點著色器)
頂點著色實現了一種通用的可編程方法操作頂點。
頂點著色器的輸入包括以下幾個:
• Shader PRogram.程序的頂點著色程序源代碼或可執行程序,描述將在頂點上執行的操作。
• Vertex shader inputs (or attributes)-頂點著色去支持的頂點數組。
• Uniforms。頂點(片段)著色器使用的常量數據。
• Samplers。Uniforms使用的特殊類型,在紋理中使用(Texture)
在OpenGL ES2.0中頂點著色器的輸出被稱為變量,而在3.0中重新命名了。在最初的光柵化階段,它計算每個生成的輸出值,作為輸入傳遞給片段著色器。用于生成每個的值的機制從頂點著色輸出到每個頂點的片段原始的被稱為插值。此外,OpenGL ES 3加
種新的特征稱為變換反饋,它允許頂點著色輸出選擇寫入到輸出緩沖區。
頂點著色器
它使用在傳統的基于頂點的操作。如矩陣變換,計算光線,生成每頂點顏色,紋理生成和坐標變換。
2. uniform mat4 u_mvpMatrix; // matrix to convert a_position3. // from model space to normalized4. // device space5.6. // attributes input to the vertex shader7. in vec4 a_position; // position value8. in vec4 a_color; // input vertex color9.10. // output of the vertex shader - input to fragment11. // shader12. out vec4 v_color; // output vertex color13. void main()14. {15. v_color = a_color;16. gl_Position = u_mvpMatrix * a_position;17. }
新聞熱點
疑難解答