aboutsummaryrefslogtreecommitdiff
path: root/game/src/GameSession/TerrainMap.gdshader
diff options
context:
space:
mode:
author Hop311 <hop3114@gmail.com>2023-04-26 13:06:19 +0200
committer Hop311 <hop3114@gmail.com>2023-04-26 13:06:19 +0200
commit2455806f52f0133e5bd5e4997589c5ce4fe99b2c (patch)
treea1882d8d3a4e836ec305dd0893b6eda5ec3dd230 /game/src/GameSession/TerrainMap.gdshader
parent10053cf259c55ee45803268a844edf1011d8a16b (diff)
Vertical subdivision + calculation for both dims
Diffstat (limited to 'game/src/GameSession/TerrainMap.gdshader')
-rw-r--r--game/src/GameSession/TerrainMap.gdshader8
1 files changed, 5 insertions, 3 deletions
diff --git a/game/src/GameSession/TerrainMap.gdshader b/game/src/GameSession/TerrainMap.gdshader
index 305a34b..f80d6bd 100644
--- a/game/src/GameSession/TerrainMap.gdshader
+++ b/game/src/GameSession/TerrainMap.gdshader
@@ -6,6 +6,8 @@ render_mode unshaded;
uniform sampler2D farmlands_tex: source_color, repeat_enable, filter_linear;
// Province index texture
uniform sampler2DArray province_index_tex : source_color, repeat_enable, filter_nearest;
+// Province index subdivisions
+uniform vec2 province_index_subdivisions;
// Province colour texture
uniform sampler2D province_colour_tex: source_color, repeat_enable, filter_nearest;
// Index of the mouse over the map mesh
@@ -19,9 +21,9 @@ uvec2 vec2_to_uvec2(vec2 v) {
return uvec2(v * 255.0);
}
uvec2 read_uvec2(vec2 uv) {
- float width_divisions = float(textureSize(province_index_tex, 0).z);
- uv.x *= width_divisions;
- float idx = mod(floor(uv.x), width_divisions);
+ uv *= province_index_subdivisions;
+ vec2 subdivision_coords = mod(floor(uv), province_index_subdivisions);
+ float idx = subdivision_coords.x + subdivision_coords.y * province_index_subdivisions.x;
return vec2_to_uvec2(texture(province_index_tex, vec3(uv, idx)).rg);
}
uint uvec2_to_uint(uvec2 v) {