Texture Mapping Shader需要用到貼圖,OpenGL application可以做到,這次使用GLSL來實做,效果幾乎一模一樣。
vertex shader程式碼:
varying vec2 texture_coordinate;
void main()
{
// Transforming The Vertex
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
// Passing The Texture Coordinate Of Texture Unit 0 To The Fragment Shader
texture_coordinate = vec2(gl_MultiTexCoord0);
}
fragment shader程式碼:
varying vec2 texture_coordinate;
uniform sampler2D my_color_texture;
void main()
{
// Sampling The Texture And Passing It To The Frame Buffer
gl_FragColor = texture2D(my_color_texture, texture_coordinate);
}
開始覺得NeHe故布疑陣,這次的bug是全域變數不在程式碼欄中,他是想讓複製貼上的懶人有多一點可以努力的空間,思考過後會更瞭解實做過程。


隨意留個言吧:)~