From 43394c8a8908442982e3a7e25975c31b3c952923 Mon Sep 17 00:00:00 2001 From: Nikolas Date: Sun, 27 Oct 2024 12:52:55 +0200 Subject: root --- graphics/commonshaders.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 graphics/commonshaders.h (limited to 'graphics/commonshaders.h') 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; +} +)"; -- cgit v1.2.3