v4k-git-backup/engine/art/shaders/vs_323444143_16_3322_model....

47 lines
1.5 KiB
Plaintext
Raw Permalink Normal View History

2024-08-24 13:24:44 +00:00
#include "model_vs.glsl"
2024-08-23 15:57:19 +00:00
// lights
2024-08-24 13:04:33 +00:00
#include "light.glsl"
2024-03-26 16:15:02 +00:00
void main() {
2024-08-24 13:24:44 +00:00
vec3 objPos = get_object_pos();
2024-03-26 16:15:02 +00:00
2024-08-24 17:19:18 +00:00
// Set attributes up
2024-03-26 16:15:02 +00:00
v_normal_ws = normalize(vec3(att_instanced_matrix * vec4(v_normal, 0.))); // normal to world/model space
v_normal = normalize(v_normal);
v_position = att_position;
v_texcoord = att_texcoord;
v_texcoord2 = att_texcoord2;
v_color = att_color;
mat4 modelView = view * att_instanced_matrix;
mat4 l_model = att_instanced_matrix;
v_position_ws = (l_model * vec4( objPos, 1.0 )).xyz;
2024-08-24 16:03:23 +00:00
vec3 binormal = cross(att_normal, att_tangent.xyz) * att_tangent.w;
2024-03-26 16:15:02 +00:00
v_binormal = normalize(mat3(att_instanced_matrix) * binormal);
2024-08-24 17:19:18 +00:00
// Optional: Billboarding
{
billboard_t bb = setup_billboard(modelView, l_model);
modelView = bb.modelView;
l_model = bb.l_model;
2024-08-24 13:24:44 +00:00
2024-08-24 17:19:18 +00:00
v_position_ws = (l_model * vec4( objPos, 1.0 )).xyz;
v_tangent = normalize(mat3(att_instanced_matrix) * att_tangent.xyz);
}
// Compute lighting (vertex-lit models)
material_t dummy_mat;
v_vertcolor = lighting(dummy_mat);
// Compute final position and camera vector
2024-03-26 16:15:02 +00:00
vec4 finalPos = modelView * vec4( objPos, 1.0 );
vec3 to_camera = normalize( -finalPos.xyz );
v_to_camera = mat3( inv_view ) * to_camera;
2024-08-24 17:19:18 +00:00
// Set final position
2024-08-25 00:58:34 +00:00
v_depth = -finalPos.z;
2024-03-26 16:15:02 +00:00
gl_Position = P * finalPos;
2024-08-24 17:19:18 +00:00
// Prepare shadow data for shadow mapping
2024-08-29 15:32:34 +00:00
do_shadow(att_instanced_matrix, objPos, v_normal);
2023-11-06 08:30:19 +00:00
}