summaryrefslogtreecommitdiff
path: root/client/src/ui.wgsl
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-01-10 02:20:21 +0100
committermetamuffin <metamuffin@disroot.org>2025-01-10 02:20:21 +0100
commit3ecd4588d4aa85a93a06aa5a1a3a60b918a72557 (patch)
treebfb6b2624e23fc09d640e36a5d5de1b89777062e /client/src/ui.wgsl
parent87f67ff9ae1aa74008042750d354a7dad030020d (diff)
downloadweareserver-3ecd4588d4aa85a93a06aa5a1a3a60b918a72557.tar
weareserver-3ecd4588d4aa85a93a06aa5a1a3a60b918a72557.tar.bz2
weareserver-3ecd4588d4aa85a93a06aa5a1a3a60b918a72557.tar.zst
some progress on egui
Diffstat (limited to 'client/src/ui.wgsl')
-rw-r--r--client/src/ui.wgsl43
1 files changed, 43 insertions, 0 deletions
diff --git a/client/src/ui.wgsl b/client/src/ui.wgsl
new file mode 100644
index 0000000..174f20c
--- /dev/null
+++ b/client/src/ui.wgsl
@@ -0,0 +1,43 @@
+// wearechat - generic multiplayer game with voip
+// Copyright (C) 2025 metamuffin
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, version 3 of the License only.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+struct VertexIn {
+ @location(0) pos: vec2<f32>,
+ @location(1) uv: vec2<f32>,
+ @location(2) color: vec3<f32>,
+}
+struct VertexOut {
+ @builtin(position) clip: vec4<f32>,
+ @location(0) uv: vec2<f32>,
+ @location(1) color: vec3<f32>,
+}
+
+@group(0) @binding(0) var texture: texture_2d<f32>;
+@group(0) @binding(1) var texture_sampler: sampler;
+var<push_constant> project: mat4x4<f32>;
+
+@vertex
+fn vs_main(vi: VertexIn) -> VertexOut {
+ var clip = project * vec4(vi.pos, 0., -1.);
+ clip /= clip.w;
+ clip.x *= -1.;
+ clip.y *= -1.;
+ let vo = VertexOut(clip, vi.uv, vi.color);
+ return vo;
+}
+@fragment
+fn fs_main(vo: VertexOut) -> @location(0) vec4<f32> {
+ return textureSample(texture, texture_sampler, vo.uv) * vec4(vo.color, 1.);
+}