diff options
author | talha <sarcxd@gmail.com> | 2024-10-08 21:15:38 +0500 |
---|---|---|
committer | talha <sarcxd@gmail.com> | 2024-10-08 21:15:38 +0500 |
commit | 7c0ca92da0d2d0fd7e7f4da957ef7d1ea9f15e41 (patch) | |
tree | c5db10f770781a2a7bff76ef9330de4779416eb6 /source/shaders |
Saving draft, added collision detection so far
Diffstat (limited to 'source/shaders')
-rwxr-xr-x | source/shaders/colored_quad.fs.glsl | 8 | ||||
-rwxr-xr-x | source/shaders/colored_quad.vs.glsl | 10 | ||||
-rwxr-xr-x | source/shaders/ui_text.fs.glsl | 15 | ||||
-rwxr-xr-x | source/shaders/ui_text.vs.glsl | 16 |
4 files changed, 49 insertions, 0 deletions
diff --git a/source/shaders/colored_quad.fs.glsl b/source/shaders/colored_quad.fs.glsl new file mode 100755 index 0000000..095a90e --- /dev/null +++ b/source/shaders/colored_quad.fs.glsl @@ -0,0 +1,8 @@ +#version 330 core + +uniform vec3 Color; +out vec4 FragColor; + +void main() { + FragColor = vec4(Color, 1.0); +}; diff --git a/source/shaders/colored_quad.vs.glsl b/source/shaders/colored_quad.vs.glsl new file mode 100755 index 0000000..ac64c49 --- /dev/null +++ b/source/shaders/colored_quad.vs.glsl @@ -0,0 +1,10 @@ +#version 330 core +layout(location=0) in vec3 aPos; + +uniform mat4 Model; +uniform mat4 View; +uniform mat4 Projection; + +void main() { + gl_Position = Projection * View * Model * vec4(aPos, 1.0); +} diff --git a/source/shaders/ui_text.fs.glsl b/source/shaders/ui_text.fs.glsl new file mode 100755 index 0000000..ca2c249 --- /dev/null +++ b/source/shaders/ui_text.fs.glsl @@ -0,0 +1,15 @@ +#version 330 core + +in vec2 TexCoords; +flat in int Index; +uniform sampler2DArray TextureAtlas; +uniform int TextureMap[32]; +uniform vec3 TextColor; +out vec4 FragColor; + +void main() { + int TextureId = TextureMap[Index]; + vec3 TextureIndexCoords = vec3(TexCoords.xy, TextureId); + vec4 sampled = vec4(1.0, 1.0, 1.0, texture(TextureAtlas, TextureIndexCoords).r); + FragColor = sampled * vec4(TextColor, 1); +}; diff --git a/source/shaders/ui_text.vs.glsl b/source/shaders/ui_text.vs.glsl new file mode 100755 index 0000000..9bba904 --- /dev/null +++ b/source/shaders/ui_text.vs.glsl @@ -0,0 +1,16 @@ +#version 330 core +layout(location=0) in vec2 aPos; + +uniform mat4 Projection; +uniform mat4 View; +uniform mat4 LetterTransforms[32]; +out vec2 TexCoords; +flat out int Index; + +void main() { + gl_Position = Projection * View * LetterTransforms[gl_InstanceID] * vec4(aPos, 0.0, 1.0); + vec2 tex = aPos; + TexCoords = tex; + TexCoords.y = 1.0 - TexCoords.y; + Index = gl_InstanceID; +} |