v4k-git-backup/engine/shaders/vs_332_32.glsl

33 lines
911 B
Plaintext
Raw Normal View History

2023-08-10 22:46:04 +00:00
//uniform mat4 u_model, u_view, u_proj;
2023-08-10 21:53:51 +00:00
uniform mat4 u_mvp;
in vec3 att_position;
in vec3 att_normal;
in vec2 att_texcoord;
in vec4 att_color;
out vec4 v_color;
out vec3 v_normal;
out vec3 v_normal_ws;
out vec2 v_texcoord;
2023-08-10 22:46:04 +00:00
// shadow
2023-08-10 21:53:51 +00:00
uniform mat4 model, view, proj;
2023-08-10 22:46:04 +00:00
uniform mat4 cameraToShadowProjector; // !VSMCUBE
2023-08-10 21:53:51 +00:00
out vec4 vneye;
out vec4 vpeye;
2023-08-10 22:46:04 +00:00
out vec4 sc; // !VSMCUBE
2023-08-10 21:53:51 +00:00
void do_shadow() {
vneye = view * model * vec4(att_normal, 0.0f);
vpeye = view * model * vec4(att_position, 1.0);
sc = cameraToShadowProjector * model * vec4(att_position, 1.0f);
}
void main() {
2023-08-10 22:46:04 +00:00
// gl_Position = proj * view * model * vec4(att_position, 1.0);
2023-08-10 21:53:51 +00:00
gl_Position = u_mvp * vec4(att_position, 1.0);
v_normal = normalize(att_normal);
2023-08-10 22:46:04 +00:00
v_normal_ws = normalize(vec3(model * vec4(att_normal, 0.))); // normal world/model space
2023-08-10 21:53:51 +00:00
v_texcoord = att_texcoord;
v_color = att_color;
do_shadow();
}