#version 450 layout(location = 0) in vec4 frag_color; layout(location = 1) in vec4 frag_mcolor; layout(location = 2) in vec2 frag_texcoord; layout(location = 3) in flat int frag_texindex; layout(location = 4) in vec3 frag_pos; layout(location = 5) in vec3 frag_normal; layout(location = 0) out vec4 outColor; layout(binding = 0) uniform GlobalVars { mat4 proj_view; vec3 light; vec3 eye; } global; layout(binding = 2) uniform sampler2D teximage[2]; void main() { // vec3 light_pos = vec3(5.0, 5.0, -5.0); // vec3 view_pos = vec3(3.0, 3.0, 3.0); float ambiant = 0.2; vec3 light_dir = normalize(global.light - frag_pos); float diff = max(dot(frag_normal, light_dir), 0.0); float specular_strength = 0.7; vec3 view_dir = normalize(global.eye - frag_pos); vec3 reflect_dir = reflect(-light_dir, frag_normal); float spec = pow(max(dot(view_dir, reflect_dir), 0.0), 64); float specular = specular_strength * spec; float factor = ambiant + diff + specular; vec4 pre_color = frag_color * texture(teximage[frag_texindex], frag_texcoord); pre_color = vec4(mix((factor * pre_color).rgb, frag_mcolor.rgb, frag_mcolor.a), pre_color.a); outColor = pre_color; }