So, I have a texture that I want to rotate taking into account the angle of rotation . Here are my UV coordinates
float[] landscapeVerts = {
I want to rotate only part of the UV. So I built the following matrix to execute this in the shader.
Matrix.setIdentityM(mProjMatrix, 0); //start with identity matrix Matrix.translateM(mProjMatrix,0,-0.5f,-0.5f,0.0f); // move center to center [0 1] : [-.5 .5] Matrix.rotateM(mProjMatrix, 0, rotation, 0.0f,0.0f,-1.0f); // rotate about z axis Matrix.translateM(mProjMatrix,0,0.5f,0.5f,0.0f); // move back to [0 1] range
Then I load the matrix into the shader as uSTMatrix and multiply its texture coordinates
"uniform mat4 uMVPMatrix;\n" + "uniform mat4 uSTMatrix;\n" + "attribute vec4 aPosition;\n" + "attribute vec4 aTextureCoord;\n" + "varying vec2 vTextureCoord;\n" + "varying vec2 calcTexCoord;\n" + "void main() {\n" + " gl_Position = uMVPMatrix * aPosition;\n" + " vTextureCoord = (uSTMatrix * aTextureCoord).xy;\n" + " calcTexCoord = aTextureCoord.xy;\n" + "}\n";
But that does not do what I want. This should be easy to do in the shader, what am I missing? or how it can be done easily.
source share