简体   繁体   中英

Pass through vertex shader for texture mapping?

I added a vertex shader to this example :

void main()
{   
    gl_Position = ftransform();
}   

then I get this image:

在此处输入图片说明

What am I doing wrong here?

For texture mapping using a vertex shader you will also need to pass the texture coordinates as well as the vertex positions to the fragment shader. Examples, including the one below, can be found here

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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM