Hi, guys! I want to move the texture around on fixed vertexes using shaders. The images are from cameras. Rotations work well, but nothing happens when applying translation. Could anyone figure out the reason for me please?
The vertex shader is:
const char s_v_shader_glm[] =
" #version 320 es \n "
" layout(location = 0) in vec4 vPosition; \n "
" layout(location = 1) in vec2 vTexCoord; \n "
" uniform mat3 move; \n "
" out vec2 TexCoord; \n "
" uniform mat4 mvp; \n"
" void main() \n "
" { \n "
" gl_Position = mvp * vec4(vPosition.xyz, 1); \n "
" TexCoord = vec2(move * vec3(vTexCoord, 1)); \n "
" } \n ";
The fragment shader is:
const char s_f_shader_b_ec[] =
"#version 320 es \n"
" precision mediump float;\n "
" in vec2 TexCoord; \n "
" out vec4 fragColor; \n "
" uniform sampler2D myTexture; \n "
" uniform sampler2D myMask; \n "
" uniform vec4 myGain; \n "
" void main() \n "
" {\n "
" fragColor = vec4(texture(myTexture, TexCoord).bgr, texture(myMask, TexCoord).r) * myGain; \n "
" }\n ";
And I’m applying transformation using code like:
...
GLint locMove;
glm::mat3 altered = glm::mat3(glm::rotate(glm::rotate(glm::rotate(glm::translate(glm::mat4(1), glm::vec3(100.0f, 100.0f, 0.0f)), glm::radians(0.0f), glm::vec3(1.0f, 0.0f, 0.0f)), glm::radians(0.0f), glm::vec3(0.0f, 1.0f, 0.0f)), glm::radians(0.0f), glm::vec3(0.0f, 0.0f, 1.0f)));
...
locMove = glGetUniformLocation(handle, "move");
glUniformMatrix3fv(locMove, 1, GL_FALSE, glm::value_ptr(altered));
...
The effects of rotation and scaling are obvious, but no translation is performed, which drives me crazy! Could someone help me ?! Thanks for advance!