Thanks. After learning some stuff about matrix multiplication I'm now trying this:
Code: Select all
extern vec2 texSize;
extern float angle;
#ifdef VERTEX
vec4 position(mat4 transform_projection, vec4 vertex_position) {
transform_projection *= mat4(
1, 0, 0, 0,
0, cos(angle), -sin(angle), 0,
0, sin(angle), cos(angle), 0,
1, 1, 1, 1
);
float z = 1 / (texSize.y - vertex_position.y);
transform_projection *= mat4(
z, 0, 0, 0,
0, z, 0, 0,
0, 0, 1, 0,
1, 1, 1, 1
);
return transform_projection * vertex_position;
}
#endif
Angle is in radians. Nothing appears on the screen though, even with angle set to 0. Not sure what I'm doing wrong in my math.
Update: Here's another attempt:
Code: Select all
float z = 1 / (vertex_position.y / texSize.y);
transform_projection *= mat4(
z, 0, 0, 0,
0, z, 0, 0,
0, 0, 1, 0,
1, 1, 1, 1
);
return transform_projection * vertex_position;
Is vertex_position normalized?