diff options
author | George L. Albany <Megacake1234@gmail.com> | 2023-06-04 02:17:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-04 02:17:28 +0200 |
commit | 3236f51d700674aee6ee6572109ffb3d5fa5fed2 (patch) | |
tree | b898150a8a45e7c0d814459e7f12f39429acefeb /game/src/Game/GameSession/ProvinceIndexSampler.gdshaderinc | |
parent | 73e29d02e48739aba5ca5db1b9575c67e795400f (diff) | |
parent | b98166b28c47cccff731d30959b8250fb27ff408 (diff) |
Merge pull request #130 from Spartan322/organize/godot-project
Diffstat (limited to 'game/src/Game/GameSession/ProvinceIndexSampler.gdshaderinc')
-rw-r--r-- | game/src/Game/GameSession/ProvinceIndexSampler.gdshaderinc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/game/src/Game/GameSession/ProvinceIndexSampler.gdshaderinc b/game/src/Game/GameSession/ProvinceIndexSampler.gdshaderinc new file mode 100644 index 0000000..65f73d8 --- /dev/null +++ b/game/src/Game/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; +} |