BlockGame/blocks/fragment.shader
2022-02-06 18:28:12 +01:00

25 lines
499 B
GLSL

R"(#version 330 core
out vec4 color;
uniform vec3 u_color;
uniform sampler2D u_texture;
in vec3 normal;
in vec4 pos;
in vec2 texcoords;
void main()
{
vec3 norm = normalize(normal);
vec3 lightDir = normalize(vec3(4.0,3.0,3.0) - pos.xyz);
float diff = max(dot(norm, lightDir), 0.0);
// set light color
vec3 diffuse = diff * vec3(1.0,1.0,1.0);
vec4 c = texture(u_texture, texcoords);
vec3 result = (diffuse) * c.xyz;
color = vec4(result,0.0);
// color = c;
})";