aboutsummaryrefslogtreecommitdiff
path: root/game/src/GameSession/ProvinceIndexSampler.gdshaderinc
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2023-04-29 00:48:13 +0200
committer GitHub <noreply@github.com>2023-04-29 00:48:13 +0200
commit5195a460330af234391dfdc892847d74d0d29393 (patch)
tree588f505bd94991b3a6c7a95b18b02e712df36cc7 /game/src/GameSession/ProvinceIndexSampler.gdshaderinc
parent1b35c3a4434873b98f8e3aa7770f0edd37ec053c (diff)
parent05937359e8c53ee76dc3ce537dd70083a016f766 (diff)
Merge branch 'main' into goods
Diffstat (limited to 'game/src/GameSession/ProvinceIndexSampler.gdshaderinc')
-rw-r--r--game/src/GameSession/ProvinceIndexSampler.gdshaderinc18
1 files changed, 18 insertions, 0 deletions
diff --git a/game/src/GameSession/ProvinceIndexSampler.gdshaderinc b/game/src/GameSession/ProvinceIndexSampler.gdshaderinc
new file mode 100644
index 0000000..65f73d8
--- /dev/null
+++ b/game/src/GameSession/ProvinceIndexSampler.gdshaderinc
@@ -0,0 +1,18 @@
+
+// Province shape texture
+uniform sampler2DArray province_shape_tex : repeat_enable, filter_nearest;
+// Province shape subdivisions
+uniform vec2 province_shape_subdivisions;
+
+uvec3 vec3_to_uvec3(vec3 v) {
+ return uvec3(v * 255.0);
+}
+uvec3 read_uvec3(vec2 uv) {
+ uv *= province_shape_subdivisions;
+ vec2 subdivision_coords = mod(floor(uv), province_shape_subdivisions);
+ float idx = subdivision_coords.x + subdivision_coords.y * province_shape_subdivisions.x;
+ return vec3_to_uvec3(texture(province_shape_tex, vec3(uv, idx)).rgb);
+}
+uint uvec2_to_uint(uvec2 v) {
+ return (v.y << 8u) | v.x;
+}