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

來源:互聯網
上載者:User

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

#version 300 esuniform mat4 u_mvpMatrix; in vec4 a_position;in vec4 a_color;
out vec4 v_color;
void main(){ v_color = a_color; gl_Position = u_mvpMatrix * a_position;}

上面是一段頂點著色器代碼。

#version 300 es

出現在頂點著色檔案的第一行,說明著色語言版本是3.0(shading language 3.0)

uniform mat4 u_mvpMatrix;

建立一個用於儲存群組合模型視圖投影矩陣的uniform變數u_mvpMatrix。

in vec4 a_position;in vec4 a_color;

輸入給頂點著色器,作為頂點著色器的屬性。

 a_position是輸入頂點的位置屬性,a_color是輸入頂點的顏色屬性。

out vec4 v_color;

輸出頂點顏色


gl_position是內建的自動聲明變數,著色器必須寫入變換位置傳遞給它。

void main是一個頂點或片段著色器的進入點。

v_color = a_color;

我們讀取頂點屬性輸入a_color寫它的頂點顏色輸出v_color。

 gl_Position = u_mvpMatrix * a_position;

通過gl_Position改變頂點的位置。

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.