prosperon/source/shaders/unlit.sglsl

48 lines
973 B
Plaintext
Raw Normal View History

2023-11-07 08:27:44 -06:00
@vs vs
in vec3 a_pos;
in vec2 a_tex_coords;
2024-04-23 18:12:45 -05:00
in vec4 a_norm;
2024-04-26 16:04:31 -05:00
in vec4 a_weight;
in vec4 a_joint;
2023-11-07 08:27:44 -06:00
out vec2 tex_coords;
2024-04-23 15:58:08 -05:00
out vec3 normal;
2023-11-07 08:27:44 -06:00
2024-04-26 16:04:31 -05:00
uniform vs_p { uniform mat4 vp; };
uniform vmodel { uniform mat4 model; };
uniform skinv { uniform mat4 bones[50]; };
2023-11-07 08:27:44 -06:00
void main() {
2024-04-26 16:04:31 -05:00
mat4 skin = bones[int(a_joint.x)] * a_weight.x;
skin += bones[int(a_joint.y)] * a_weight.y;
skin += bones[int(a_joint.z)] * a_weight.z;
skin += bones[int(a_joint.w)] * a_weight.w;
mat4 skinm = model * skin;
gl_Position = vp * skinm * vec4(a_pos,1.0);
2023-11-07 08:27:44 -06:00
tex_coords = a_tex_coords;
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
@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