GPU Tips(收集和整理)

來源:互聯網
上載者:User
1. glMultiMatrix是右乘,比如:
    glLoadMatrix(&m1);
    glMultiMatrix(&m2);
    相當於:m1 * m2.
2. GLSL的vec4有3種分量形式xyzw/rgba/stpq, 注意到的r分量是指顏色r分量, 習慣上的紋理座標分量strq的r由於和顏色r衝突,改作p.
3. GLSL可以只有PixelShader, 沒有Vertex Shader, HLSL不支援. 
    vs_3_0 shader executed in hardware vertex processing mode can only be paired with at least a ps_3_0 shader.
4. GLSL的1.2版本開始支援mat4x3這種non-square矩陣,要注意4x3是4列3行,而不是4行3列.
(註:2,3,4條來源於http://www.cnitblog.com/linghuye/archive/2008/01/29/39451.aspx)
5. 在GLSL 1.10版本,當程式連結成功時,所有的uniform的預設值為0;在1.20版本所有uniform(除了sampler),都可以有一構造器,像這樣:
       uniform vec3 color = vec3(0.7, 0.7, 0.2);
    無構造器的所有uniform其預設值均為0.
6.

Try passing data as attributes rather than uniforms

Changing uniforms sometimes have a setup cost

盡量以attribute而非uniform來傳遞資料,因為改變uniform有時會有setup的開銷。
7. 使用FBO時,如果在attach一個color buffer時沒同時attach一個depth buffer,那麼將情境渲染到該color buffer時,是不會進行depth test的(可以認為每個fragment都會通過depth test);要想能進行depth test,必須為FBO attach一個depth buffer.
8. 要使用GLSL 1.20版本,則在開頭加上:#version 120
9. 要使用Geometry Shader,則在開頭加上:#extension GL_EXT_geometry_shader4 : enable

聯繫我們

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