aboutsummaryrefslogtreecommitdiff
path: root/game/src/GameSession/TerrainMap.gdshader
diff options
context:
space:
mode:
author Spartan322 <Megacake1234@gmail.com>2023-06-03 20:37:10 +0200
committer Spartan322 <Megacake1234@gmail.com>2023-06-03 20:37:10 +0200
commitcef940108fe15752c3ef66f43f5169403fa2f71d (patch)
treefe4de5a05830e3bddeae78f74f729503b7cee1e9 /game/src/GameSession/TerrainMap.gdshader
parent73e29d02e48739aba5ca5db1b9575c67e795400f (diff)
Reorganize the file structure of the files in `game/src`
Diffstat (limited to 'game/src/GameSession/TerrainMap.gdshader')
-rw-r--r--game/src/GameSession/TerrainMap.gdshader50
1 files changed, 0 insertions, 50 deletions
diff --git a/game/src/GameSession/TerrainMap.gdshader b/game/src/GameSession/TerrainMap.gdshader
deleted file mode 100644
index 88e7019..0000000
--- a/game/src/GameSession/TerrainMap.gdshader
+++ /dev/null
@@ -1,50 +0,0 @@
-shader_type spatial;
-
-render_mode unshaded;
-
-#include "res://src/GameSession/ProvinceIndexSampler.gdshaderinc"
-
-// Province colour texture
-uniform sampler2D province_colour_tex: source_color, repeat_enable, filter_nearest;
-// Index of the mouse over the map mesh
-uniform uint hover_index;
-// Index of the currently selected province
-uniform uint selected_index;
-// Cosmetic terrain textures
-uniform sampler2DArray terrain_tex: source_color, repeat_enable, filter_linear;
-// The number of times the terrain textures should tile vertically
-uniform float terrain_tile_factor;
-
-const vec3 highlight_colour = vec3(1.0);
-
-vec3 get_terrain_colour(vec2 uv, vec2 corner, vec2 half_pixel_size, vec2 terrain_uv) {
- uvec3 province_data = read_uvec3(fma(corner, half_pixel_size, uv));
- vec4 province_colour = texelFetch(province_colour_tex, ivec2(province_data.rg), 0);
- vec3 terrain_colour = texture(terrain_tex, vec3(terrain_uv, float(province_data.b))).rgb;
- vec3 mixed_colour = mix(terrain_colour, province_colour.rgb, province_colour.a);
- uint index = uvec2_to_uint(province_data.rg);
- float mix_val = 0.1 * (float(index == hover_index) + float(index == selected_index));
- return mix(mixed_colour, highlight_colour, mix_val);
-}
-
-vec3 mix_terrain_colour(vec2 uv) {
- vec2 map_size = vec2(textureSize(province_shape_tex, 0).xy) * province_shape_subdivisions;
- vec2 pixel_offset = fract(fma(uv, map_size, vec2(0.5)));
- vec2 half_pixel_size = 0.49 / map_size;
-
- vec2 terrain_uv = uv;
- terrain_uv.x *= map_size.x / map_size.y;
- terrain_uv *= terrain_tile_factor;
-
- return mix(
- mix(get_terrain_colour(uv, vec2(-1, -1), half_pixel_size, terrain_uv),
- get_terrain_colour(uv, vec2(+1, -1), half_pixel_size, terrain_uv), pixel_offset.x),
- mix(get_terrain_colour(uv, vec2(-1, +1), half_pixel_size, terrain_uv),
- get_terrain_colour(uv, vec2(+1, +1), half_pixel_size, terrain_uv), pixel_offset.x),
- pixel_offset.y);
-}
-
-void fragment() {
- vec3 terrain_colour = mix_terrain_colour(UV);
- ALBEDO = terrain_colour;
-}