当前位置:网站首页>OpenGL job - texture

OpenGL job - texture

2022-07-07 22:08:00 qq_ fifty-seven million two hundred and fifty-one thousand thre

One 、 Modify Clip shader , only Let the smiling face pattern look in the other direction

#version 330 core
out vec4 FragColor;

in vec3 ourColor;
in vec2 TexCoord;

uniform sampler2D texture1;
uniform sampler2D texture2;

void main()
{
   FragColor = mix(texture(texture1, TexCoord), texture(texture2, vec2(1-TexCoord.x, TexCoord.y)), 0.2);
}

 

Two 、 Try different texture wrapping methods , Set a from 0.0f To 2.0f Within the scope of ( Not the original 0.0f To 1.0f) Texture coordinates . See if you can put... In the corner of the box 4 A smiling face

float vertices[] = {
    //     ---- Location ----       ---- Color ----     - Texture coordinates -
         0.5f,  0.5f, 0.0f,   1.0f, 0.0f, 0.0f,   2.0f, 2.0f,   // The upper right
         0.5f, -0.5f, 0.0f,   0.0f, 1.0f, 0.0f,   2.0f, 0.0f,   // The lower right
        -0.5f, -0.5f, 0.0f,   0.0f, 0.0f, 1.0f,   0.0f, 0.0f,   // The lower left
        -0.5f,  0.5f, 0.0f,   1.0f, 1.0f, 0.

原网站

版权声明
本文为[qq_ fifty-seven million two hundred and fifty-one thousand thre]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130608249155.html