diff options
author | Nikolas <nikolas@boutalas.com> | 2024-10-27 12:52:55 +0200 |
---|---|---|
committer | Nikolas <nikolas@boutalas.com> | 2024-10-27 12:52:55 +0200 |
commit | 43394c8a8908442982e3a7e25975c31b3c952923 (patch) | |
tree | 2facd563e29f48fe3b0653ac5c113998940b4d5e /graphics/commonshaders.h |
Diffstat (limited to 'graphics/commonshaders.h')
-rw-r--r-- | graphics/commonshaders.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/graphics/commonshaders.h b/graphics/commonshaders.h new file mode 100644 index 0000000..b5b423f --- /dev/null +++ b/graphics/commonshaders.h @@ -0,0 +1,36 @@ +#pragma once + +const char* __PrimitivesVertexShader = R"( +#version 120 + +attribute vec4 coord; +varying vec2 texcoord; +uniform mat4 MV; +uniform mat4 P; + +void main(void) { + gl_Position = P*MV*vec4(coord.xy, 0, 1); + texcoord = coord.zw; +} +)"; + + +const char* __SolidFragmentShader = R"( +#version 120 + +varying vec2 texcoord; +uniform vec4 color1; +uniform vec4 color2; +uniform sampler2D tex; +uniform int has_texture; +uniform vec2 gradient; + +void main(void) { + vec4 color = mix( color1, color2, dot(texcoord,gradient)); + vec4 tex_color = texture2D(tex, texcoord); + if (has_texture>0) + gl_FragColor = color * tex_color; + else + gl_FragColor = color; +} +)"; |