Skip to content

Instantly share code, notes, and snippets.

@anirul
Created March 8, 2020 09:30
Show Gist options
  • Save anirul/aca408c8ee7cd483f3e04b5c0092f8fd to your computer and use it in GitHub Desktop.
Save anirul/aca408c8ee7cd483f3e04b5c0092f8fd to your computer and use it in GitHub Desktop.
Simple fragment shader to show a model with texture.
#version 410 core
layout(location = 0) out vec4 frag_color;
in vec3 out_normal;
in vec2 out_texcoord;
uniform sampler2D texture1;
void main()
{
vec3 light_position = vec3(0.0, 0.0, 1.0);
float shade = clamp(dot(light_position, out_normal), 0.0, 1.0);
frag_color =
vec4(shade, shade, shade, 1.0) *
texture(texture1, out_texcoord);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment