prosperon/source/shaders/unlit.sglsl

37 lines
589 B
Plaintext

@vs vs
in vec3 a_pos;
in vec2 a_tex_coords;
in vec4 a_norm;
out vec2 tex_coords;
out vec3 normal;
uniform vs_p {
uniform mat4 vp;
uniform mat4 model;
};
void main() {
gl_Position = vp * model * vec4(a_pos,1.0);
tex_coords = a_tex_coords;
normal = a_norm.xyz;
}
@end
@fs fs
in vec2 tex_coords;
in vec3 normal;
out vec4 color;
uniform texture2D diffuse;
uniform sampler smp;
void main() {
vec3 lightDir = normalize(vec3(0.5f, 0.5f, 1.0f));
float diff = max(dot(normal, lightDir), 0.0f);
color = texture(sampler2D(diffuse,smp),tex_coords)*diff;
}
@end
@program unlit vs fs