OpenGL ES 3.0頂點著色器(一),opengles

來源:互聯網
上載者:User

OpenGL ES 3.0頂點著色器(一),opengles

          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. }

  

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.