eo/shaders/vs_basic.sc

35 lines
976 B
Python
Raw Normal View History

2025-01-27 18:16:31 +00:00
$input a_position
$output f_position
2024-11-15 00:12:51 +00:00
uniform vec4 u_position;
uniform vec4 u_rotation;
uniform vec4 u_scale;
#include <bgfx_shader.sh>
2025-01-27 18:16:31 +00:00
#include <shaderlib.sh>
2024-11-15 00:12:51 +00:00
void main() {
2025-01-27 18:16:31 +00:00
// rotation
mat3 x_rot = mat3(1, 0, 0,
0, cos(u_rotation.x), -sin(u_rotation.x),
0, sin(u_rotation.x), cos(u_rotation.x));
mat3 y_rot = mat3(cos(u_rotation.y), 0, sin(u_rotation.y),
0, 1, 0,
-sin(u_rotation.y), 0, cos(u_rotation.y));
mat3 z_rot = mat3(cos(u_rotation.z), -sin(u_rotation.z), 0,
sin(u_rotation.z), cos(u_rotation.z), 0,
0, 0, 1);
vec3 r_position = a_position;
r_position = mul(r_position, x_rot);
r_position = mul(r_position, y_rot);
r_position = mul(r_position, z_rot);
vec4 scale = mul(u_scale, vec4(r_position, 1.0f));
2024-11-15 00:12:51 +00:00
vec4 view = mul(u_view, scale);
vec4 pos = view + u_position;
gl_Position = mul(u_proj, pos);
2025-01-27 19:33:39 +00:00
f_position = a_position;
}