Initial commit - some engine bugs stopping compiling
This commit is contained in:
36
build/assets/shaders/basic.frag
Normal file
36
build/assets/shaders/basic.frag
Normal file
@@ -0,0 +1,36 @@
|
||||
#version 410 core
|
||||
in vec3 FragPos;
|
||||
in vec3 Normal;
|
||||
in vec3 Color;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec3 uLightPos;
|
||||
uniform vec3 uViewPos;
|
||||
uniform vec3 uLightColor;
|
||||
uniform float uAmbientStrength;
|
||||
uniform float uSpecularStrength;
|
||||
uniform float uShininess;
|
||||
|
||||
void main() {
|
||||
// Normalize the normal vector
|
||||
vec3 norm = normalize(Normal);
|
||||
|
||||
// Ambient lighting
|
||||
vec3 ambient = uAmbientStrength * uLightColor;
|
||||
|
||||
// Diffuse lighting
|
||||
vec3 lightDir = normalize(uLightPos - FragPos);
|
||||
float diff = max(dot(norm, lightDir), 0.0);
|
||||
vec3 diffuse = diff * uLightColor;
|
||||
|
||||
// Specular lighting
|
||||
vec3 viewDir = normalize(uViewPos - FragPos);
|
||||
vec3 reflectDir = reflect(-lightDir, norm);
|
||||
float spec = pow(max(dot(viewDir, reflectDir), 0.0), uShininess);
|
||||
vec3 specular = uSpecularStrength * spec * uLightColor;
|
||||
|
||||
// Combine results
|
||||
vec3 result = (ambient + diffuse + specular) * Color;
|
||||
FragColor = vec4(result, 1.0);
|
||||
}
|
||||
Reference in New Issue
Block a user