Skip to content

Instantly share code, notes, and snippets.

@TomMinor
Last active October 14, 2021 22:05
Show Gist options
  • Save TomMinor/088766855a5fb161e236 to your computer and use it in GitHub Desktop.
Save TomMinor/088766855a5fb161e236 to your computer and use it in GitHub Desktop.
#version 420 // Keeping you on the bleeding edge!
#extension GL_EXT_gpu_shader4 : enable
smooth in vec3 fragmentNormal;
// Force location to 0 to ensure its the first output
layout (location = 0) out vec4 o_FragColor;
struct Lights
{
vec3 position;
vec3 diffuse; // Colour
};
float lambert(vec3 N, vec3 L)
{
vec3 nrmN = normalize(N);
vec3 nrmL = normalize(L);
float result = dot(nrmN, nrmL);
return max(result, 0.0);
}
void main()
{
// Temporary light, exam one will be a uniform input
Lights light;
light.position = vec3(2,1,4);
light.diffuse = vec3(1.0, 1.0, 1.0);
//
vec3 result = light.diffuse * lambert(fragmentNormal, light.position);;
o_FragColor = vec4(result.rgb, 1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment