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);
|
||||
}
|
||||
23
build/assets/shaders/basic.vert
Normal file
23
build/assets/shaders/basic.vert
Normal file
@@ -0,0 +1,23 @@
|
||||
#version 410 core
|
||||
layout(location = 0) in vec3 aPos;
|
||||
layout(location = 1) in vec3 aColor;
|
||||
layout(location = 2) in vec3 aNormal;
|
||||
layout(location = 6) in mat4 aInstanceModel;
|
||||
|
||||
uniform mat4 uView;
|
||||
uniform mat4 uProjection;
|
||||
|
||||
out vec3 FragPos;
|
||||
out vec3 Normal;
|
||||
out vec3 Color;
|
||||
|
||||
void main() {
|
||||
vec4 worldPos = aInstanceModel * vec4(aPos, 1.0);
|
||||
FragPos = worldPos.xyz;
|
||||
|
||||
// Transform normal to world space (assuming uniform scaling)
|
||||
Normal = mat3(transpose(inverse(aInstanceModel))) * aNormal;
|
||||
|
||||
Color = aColor;
|
||||
gl_Position = uProjection * uView * worldPos;
|
||||
}
|
||||
Reference in New Issue
Block a user