aboutsummaryrefslogtreecommitdiff
path: root/src/main/resources/assets
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/resources/assets')
-rw-r--r--src/main/resources/assets/libgui/shaders/core/tiled_rectangle.fsh32
-rw-r--r--src/main/resources/assets/libgui/shaders/core/tiled_rectangle.json20
-rw-r--r--src/main/resources/assets/libgui/shaders/core/tiled_rectangle.vsh15
3 files changed, 67 insertions, 0 deletions
diff --git a/src/main/resources/assets/libgui/shaders/core/tiled_rectangle.fsh b/src/main/resources/assets/libgui/shaders/core/tiled_rectangle.fsh
new file mode 100644
index 0000000..15e3185
--- /dev/null
+++ b/src/main/resources/assets/libgui/shaders/core/tiled_rectangle.fsh
@@ -0,0 +1,32 @@
+#version 150
+
+uniform sampler2D Sampler0;
+uniform vec4 ColorModulator;
+
+uniform vec2 LibGuiRectanglePos;
+uniform vec2 LibGuiTileDimensions;
+uniform vec4 LibGuiTileUvs;
+
+in vec2 vertexPosition;
+out vec4 fragColor;
+
+float lerp(float time, float a, float b) {
+ return (1 - time) * a + time * b;
+}
+
+vec2 getTextureCoords(vec2 pos) {
+ float deltaX = mod(pos.x - LibGuiRectanglePos.x, LibGuiTileDimensions.x) / LibGuiTileDimensions.x;
+ float deltaY = mod(pos.y - LibGuiRectanglePos.y, LibGuiTileDimensions.y) / LibGuiTileDimensions.y;
+ return vec2(
+ lerp(deltaX, LibGuiTileUvs.x, LibGuiTileUvs.z),
+ lerp(deltaY, LibGuiTileUvs.y, LibGuiTileUvs.w)
+ );
+}
+
+void main() {
+ vec4 color = texture(Sampler0, getTextureCoords(vertexPosition));
+ if (color.a < 0.1) {
+ discard;
+ }
+ fragColor = color * ColorModulator;
+}
diff --git a/src/main/resources/assets/libgui/shaders/core/tiled_rectangle.json b/src/main/resources/assets/libgui/shaders/core/tiled_rectangle.json
new file mode 100644
index 0000000..2ca0af3
--- /dev/null
+++ b/src/main/resources/assets/libgui/shaders/core/tiled_rectangle.json
@@ -0,0 +1,20 @@
+{
+ "blend": {
+ "func": "add",
+ "srcrgb": "srcalpha",
+ "dstrgb": "1-srcalpha"
+ },
+ "vertex": "libgui:tiled_rectangle",
+ "fragment": "libgui:tiled_rectangle",
+ "attributes": ["Position"],
+ "samplers": [{ "name": "Sampler0" }],
+ "uniforms": [
+ { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
+ { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
+ { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] },
+ { "name": "LibGuiRectanglePos", "type": "float", "count": 2, "values": [ 0.0, 0.0 ] },
+ { "name": "LibGuiTileDimensions", "type": "float", "count": 2, "values": [ 0.0, 0.0 ] },
+ { "name": "LibGuiTileUvs", "type": "float", "count": 4, "values": [ 0.0, 0.0, 1.0, 1.0 ] },
+ { "name": "LibGuiPositionMatrix", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }
+ ]
+}
diff --git a/src/main/resources/assets/libgui/shaders/core/tiled_rectangle.vsh b/src/main/resources/assets/libgui/shaders/core/tiled_rectangle.vsh
new file mode 100644
index 0000000..6a1209d
--- /dev/null
+++ b/src/main/resources/assets/libgui/shaders/core/tiled_rectangle.vsh
@@ -0,0 +1,15 @@
+#version 150
+
+in vec3 Position;
+
+uniform mat4 ModelViewMat;
+uniform mat4 ProjMat;
+uniform mat4 LibGuiPositionMatrix;
+
+out vec2 vertexPosition;
+
+void main() {
+ gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
+ vec4 rawPos = inverse(LibGuiPositionMatrix) * vec4(Position, 1.0);
+ vertexPosition = rawPos.xy;
+}