prosperon/source/shaders/unlit.sglsl

64 lines
1.2 KiB
Plaintext
Raw Normal View History

2024-04-28 13:33:37 -05:00
@block vptr
2023-11-07 08:27:44 -06:00
in vec3 a_pos;
2024-04-30 10:32:27 -05:00
in vec2 a_uv;
2024-04-23 18:12:45 -05:00
in vec4 a_norm;
2023-11-07 08:27:44 -06:00
out vec2 tex_coords;
2024-04-23 15:58:08 -05:00
out vec3 normal;
2024-04-26 16:04:31 -05:00
uniform vs_p { uniform mat4 vp; };
uniform vmodel { uniform mat4 model; };
2024-04-28 13:33:37 -05:00
@end
@vs vs
@include_block vptr
2024-04-30 10:32:27 -05:00
in vec4 a_bone;
2024-04-28 13:33:37 -05:00
in vec4 a_weight;
2024-04-26 16:04:31 -05:00
uniform skinv { uniform mat4 bones[50]; };
2023-11-07 08:27:44 -06:00
void main() {
2024-04-28 13:33:37 -05:00
mat4 tt = vp;
mat4 mm = model;
2024-04-30 10:32:27 -05:00
mat4 skin = bones[int(a_bone.x)] * a_weight.x;
skin += bones[int(a_bone.y)] * a_weight.y;
skin += bones[int(a_bone.z)] * a_weight.z;
skin += bones[int(a_bone.w)] * a_weight.w;
2024-04-28 13:33:37 -05:00
mat4 skinm = mm * skin;
gl_Position = tt * skinm * vec4(a_pos,1.0);
2024-04-30 10:32:27 -05:00
tex_coords = a_uv;
2024-04-26 16:04:31 -05:00
normal = (skinm * vec4(a_norm.xyz*2-1,0)).xyz;
2023-11-07 08:27:44 -06:00
}
@end
2024-04-28 13:33:37 -05:00
@vs vs_st
@include_block vptr
void main() {
gl_Position = vp * model * vec4(a_pos,1.0);
2024-04-30 10:32:27 -05:00
tex_coords = a_uv;
2024-04-28 13:33:37 -05:00
normal = (model * vec4(a_norm.xyz*2-1,0)).xyz;
}
@end
2023-11-07 08:27:44 -06:00
@fs fs
in vec2 tex_coords;
2024-04-23 15:58:08 -05:00
in vec3 normal;
2023-11-07 08:27:44 -06:00
out vec4 color;
uniform texture2D diffuse;
uniform sampler smp;
2024-04-26 16:04:31 -05:00
uniform lightf {
vec4 ambient;
};
2023-11-07 08:27:44 -06:00
void main() {
2024-04-23 15:58:08 -05:00
vec3 lightDir = normalize(vec3(0.5f, 0.5f, 1.0f));
float diff = max(dot(normal, lightDir), 0.0f);
2024-04-26 16:04:31 -05:00
color = texture(sampler2D(diffuse,smp),tex_coords) * ambient;
2023-11-07 08:27:44 -06:00
}
@end
@program unlit vs fs
2024-04-28 13:33:37 -05:00
@program unlit_st vs_st fs