diff options
author | 2025-02-07 11:27:18 -0500 | |
---|---|---|
committer | 2025-02-07 11:27:18 -0500 | |
commit | 4da7be39827ea5888ef9c97b1aadf61b0d76347c (patch) | |
tree | 15d0ff8f8bcb0e871efb1b2e65c2bc8d07b17565 /mons_exe/embed |
initial commit (lol)
Diffstat (limited to 'mons_exe/embed')
-rw-r--r-- | mons_exe/embed/shaders/basic.vert.glsl | 26 | ||||
-rw-r--r-- | mons_exe/embed/shaders/basic_lit.frag.glsl | 27 |
2 files changed, 53 insertions, 0 deletions
diff --git a/mons_exe/embed/shaders/basic.vert.glsl b/mons_exe/embed/shaders/basic.vert.glsl new file mode 100644 index 0000000..8164120 --- /dev/null +++ b/mons_exe/embed/shaders/basic.vert.glsl @@ -0,0 +1,26 @@ +#version 460 core +layout (location = 0) in vec3 aPos; +layout (location = 1) in vec3 aNormal; +layout (location = 2) in vec4 aTangent; +layout (location = 3) in vec2 aTexCoord; + +out vec3 Normal; +out vec2 TexCoord; +out vec3 FragPos; +out mat3 TBN; + +uniform mat4 transform; +uniform mat4 view; +uniform mat4 projection; + +void main() { + gl_Position = projection * view * transform * vec4(aPos, 1.0); + FragPos = vec3(transform * vec4(aPos, 1.0)); + Normal = mat3(transpose(inverse(transform))) * aNormal; + TexCoord = aTexCoord; + + vec3 T = normalize(vec3(transform * vec4(aTangent.xyz, 0.0))); + vec3 N = normalize(vec3(transform * vec4(aNormal, 0.0))); + vec3 B = aTangent.w * cross(N, T); + TBN = mat3(T,B,N); +} diff --git a/mons_exe/embed/shaders/basic_lit.frag.glsl b/mons_exe/embed/shaders/basic_lit.frag.glsl new file mode 100644 index 0000000..467174c --- /dev/null +++ b/mons_exe/embed/shaders/basic_lit.frag.glsl @@ -0,0 +1,27 @@ +#version 460 core +out vec4 FragColor; + +in vec3 Normal; +in vec2 TexCoord; +in vec3 FragPos; +in mat3 TBN; + +uniform float ambient_strength; +uniform sampler2D base_texture; +uniform sampler2D normal_texture; + +uniform vec4 light_color; +uniform vec3 light_position; + +void main() { + vec4 base_color = texture(base_texture, TexCoord); + vec3 normal = texture(normal_texture, TexCoord).rgb; + normal = normal * 2.0 - 1.0; + normal = normalize(TBN * normal); + vec3 light_direction = normalize(light_position - FragPos); + float diff = max(dot(normal, light_direction), 0.0); + vec4 diffuse_color = diff * light_color; + vec4 ambient_color = ambient_strength * light_color; + + FragColor = (ambient_color + diffuse_color) * base_color; +} |