I work with webgl and modify the shaders (vs.glsls and fs.glsl) to understand the GLSL and graphic programming. I have a model that I want to scale, rotate and translate. Scaling and rotating works fine but when I multiply the translation matrix, the result is weird. I know this is a very basic question, but I am missing something and I need to find it out. my model is infinitely stretchered through the y axis.
The white area is supposed to be the eye of the model:
this is my vertex shader code:
mat4 rX = mat4 (
1.0, 0.0, 0.0, 0.0,
0.0, 0.0, -1.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 0.0, 1.0
);
mat4 rZ = mat4 (
0.0, 1.0, 0.0, 0.0,
-1.0, 0.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
);
mat4 eyeScale = mat4 (
.50,0.0,0.0,0.0,
0.0,.50,0.0,0.0,
0.0,0.0,.50,0.0,
0.0,0.0,0.0,1.0
);
mat4 eyeTrans = mat4(
1.0,0.0,0.0,0.0,
0.0,1.0,0.0,4.0,
0.0,0.0,1.0,0.0,
0.0,0.0,0.0,1.0
);
mat4 iR = eyeTrans*rZ*rX*eyeScale;
gl_Position = projectionMatrix * modelViewMatrix *iR* vec4(position, 1.0);
}