diff options
| author | navewindre <boneyaard@gmail.com> | 2025-09-03 20:10:09 +0200 |
|---|---|---|
| committer | navewindre <boneyaard@gmail.com> | 2025-09-03 20:10:09 +0200 |
| commit | f8b92ce3aa08b1445c9f956d8166830946562d12 (patch) | |
| tree | 94e63a5aec9f8f52b577f56799e0c9201fd976a5 /assets/shaders | |
a
Diffstat (limited to 'assets/shaders')
| -rw-r--r-- | assets/shaders/2d.fsh | 7 | ||||
| -rw-r--r-- | assets/shaders/2d.vsh | 23 | ||||
| -rw-r--r-- | assets/shaders/2d_overlay.fsh | 17 | ||||
| -rw-r--r-- | assets/shaders/2d_overlay.vsh | 20 | ||||
| -rw-r--r-- | assets/shaders/2d_texcoord.fsh | 18 | ||||
| -rw-r--r-- | assets/shaders/2d_texcoord.vsh | 28 | ||||
| -rw-r--r-- | assets/shaders/3d.fsh | 18 | ||||
| -rw-r--r-- | assets/shaders/3d.vsh | 22 |
8 files changed, 153 insertions, 0 deletions
diff --git a/assets/shaders/2d.fsh b/assets/shaders/2d.fsh new file mode 100644 index 0000000..15465af --- /dev/null +++ b/assets/shaders/2d.fsh @@ -0,0 +1,7 @@ +#version 150 + +in vec4 g_color; + +void main() { + gl_FragColor = g_color; +} diff --git a/assets/shaders/2d.vsh b/assets/shaders/2d.vsh new file mode 100644 index 0000000..7701087 --- /dev/null +++ b/assets/shaders/2d.vsh @@ -0,0 +1,23 @@ +#version 150 + +in vec2 in_pos; +in vec2 in_texcoord; +in vec4 in_col; + +out vec2 g_texcoord; +out vec4 g_color; + +uniform vec4 g_screenratio; + +void main() { + vec2 halfscreen = vec2( 1.0 / g_screenratio[0], 1.0 / g_screenratio[1] ); + + vec4 pos = vec4( in_pos.x, in_pos.y, 1, 1 ); + pos[0] -= halfscreen[0]; + pos[1] -= halfscreen[1]; + pos[1] *= -1.0; + + gl_Position = ( pos ) * g_screenratio; + g_texcoord = in_texcoord; + g_color = in_col; +} diff --git a/assets/shaders/2d_overlay.fsh b/assets/shaders/2d_overlay.fsh new file mode 100644 index 0000000..052f0bd --- /dev/null +++ b/assets/shaders/2d_overlay.fsh @@ -0,0 +1,17 @@ +precision mediump float; +varying vec2 in_texcoord; +varying vec2 in_texcoord2; +varying vec4 g_color; +uniform sampler2D in_sampler; +uniform sampler2D in_sampler2; + +void main() { + vec4 color = texture2D( in_sampler, in_texcoord ); + vec4 color2 = texture2D( in_sampler2, in_texcoord2 ); + + float brightness = (color.x + color.y + color.z) / 3.0; + vec3 blend = color2.xyz * brightness; + vec4 final = vec4( color2.xyz, color.a ); + + gl_FragColor = vec4( in_texcoord.x, fTexCoord.y, 0.0, 1.0 ); +} diff --git a/assets/shaders/2d_overlay.vsh b/assets/shaders/2d_overlay.vsh new file mode 100644 index 0000000..512ef91 --- /dev/null +++ b/assets/shaders/2d_overlay.vsh @@ -0,0 +1,20 @@ +attribute vec4 in_position; +attribute vec2 in_texcoord; +attribute vec2 in_texcoord2; + +varying vec2 g_texcoord; +varying vec2 g_texcoord2; +uniform vec4 g_screenratio; + +void main() { + vec2 halfscreen = vec2( 1.0 / g_screenratio[0], 1.0 / g_screenratio[1] ); + + vec4 pos = in_position; + pos[0] -= halfscreen[0]; + pos[1] -= halfscreen[1]; + pos[1] *= -1.0; + + gl_Position = ( pos ) * g_screenratio; + g_texcoord = in_texcoord; + g_texcoord2 = in_texcoord2; +} diff --git a/assets/shaders/2d_texcoord.fsh b/assets/shaders/2d_texcoord.fsh new file mode 100644 index 0000000..276f305 --- /dev/null +++ b/assets/shaders/2d_texcoord.fsh @@ -0,0 +1,18 @@ +#version 150 + +uniform sampler2D g_samplers[255]; + +const uint SAMPLER_ID_NONE = 255u; + +in vec2 g_texcoord; +in vec4 g_color; +flat in uint g_sampler; + +void main() { + vec4 color = g_color; + if( g_sampler != SAMPLER_ID_NONE ) { + color = texture2D( g_samplers[g_sampler], g_texcoord ); + color *= g_color; + } + gl_FragColor = color; +} diff --git a/assets/shaders/2d_texcoord.vsh b/assets/shaders/2d_texcoord.vsh new file mode 100644 index 0000000..3ccc8e7 --- /dev/null +++ b/assets/shaders/2d_texcoord.vsh @@ -0,0 +1,28 @@ +#version 150 + +uniform sampler2D g_samplers[255]; + +in vec2 in_pos; +in vec4 in_clr; +in vec2 in_texcoord; +in float in_sampler; + +out vec2 g_texcoord; +out vec4 g_color; +flat out uint g_sampler; + +uniform vec4 g_screenratio; + +void main() { + vec2 halfscreen = vec2( 1.0 / g_screenratio[0], 1.0 / g_screenratio[1] ); + + vec4 pos = vec4( in_pos.x, in_pos.y, 1, 1 ); + pos[0] -= halfscreen[0]; + pos[1] -= halfscreen[1]; + pos[1] *= -1.0; + + g_texcoord = in_texcoord; + g_color = in_clr; + g_sampler = uint(in_sampler * 255 + 0.5); + gl_Position = ( pos ) * g_screenratio; +} diff --git a/assets/shaders/3d.fsh b/assets/shaders/3d.fsh new file mode 100644 index 0000000..ee1208c --- /dev/null +++ b/assets/shaders/3d.fsh @@ -0,0 +1,18 @@ +#version 150 + +uniform sampler2D g_samplers[255]; + +const uint SAMPLER_ID_NONE = 255u; + +in vec2 g_texcoord; +in vec4 g_color; +flat in uint g_sampler; + +void main() { + vec4 color = g_color; + if( g_sampler != SAMPLER_ID_NONE ) { + color = texture2D( g_samplers[int(g_sampler)], g_texcoord ); + color *= g_color; + } + gl_FragColor = color; +} diff --git a/assets/shaders/3d.vsh b/assets/shaders/3d.vsh new file mode 100644 index 0000000..d248e41 --- /dev/null +++ b/assets/shaders/3d.vsh @@ -0,0 +1,22 @@ +#version 150 + +in vec3 in_pos; +in vec4 in_clr; +in vec2 in_texcoord; +in float in_sampler; + +uniform mat4 in_proj_matrix; +uniform vec4 g_screenratio; + +out vec4 g_color; +out vec2 g_texcoord; +flat out uint g_sampler; + +void main() { + vec4 pos = in_proj_matrix * vec4( in_pos, 1.0 ); + g_texcoord = in_texcoord; + g_sampler = uint(in_sampler * 255 + 0.5); + g_color = in_clr; + gl_Position = pos; +} + |
