Skip to content

Instantly share code, notes, and snippets.

@thatcosmonaut
Created August 15, 2023 05:38
Show Gist options
  • Save thatcosmonaut/d041be4d9791bd2a1b9b35e7425146ac to your computer and use it in GitHub Desktop.
Save thatcosmonaut/d041be4d9791bd2a1b9b35e7425146ac to your computer and use it in GitHub Desktop.
Diffuse lighting shader
#version 450
layout(location = 0) in vec3 InNormal;
layout(location = 1) in vec3 InFragPos;
layout(location = 0) out vec4 FragColor;
layout(binding = 0, set = 3) uniform UBO
{
vec3 LightPos;
vec3 LightColor;
} ubo;
void main()
{
vec3 norm = normalize(InNormal);
vec3 lightDir = normalize(ubo.LightPos - InFragPos);
float diff = max(dot(norm, lightDir), 0.0);
vec3 diffuse = diff * ubo.LightColor;
FragColor = vec4(diffuse, 1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment