aboutsummaryrefslogtreecommitdiff
path: root/game/src/GameSession/TerrainMap.gdshader
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2023-05-01 01:34:59 +0200
committer GitHub <noreply@github.com>2023-05-01 01:34:59 +0200
commitb1e985e0774598b3add22069be50f891e981fd79 (patch)
treee18e9cb252030e9b40ff91463ed117dd00a65789 /game/src/GameSession/TerrainMap.gdshader
parent1f8545facd248bbf4ea0cd551fea5f7d9b0efdce (diff)
parent2fec521cc6bbe7b2cda0eef3b830acbfc8b68333 (diff)
Merge pull request #103 from OpenVic2Project/terrain
Cosmetic terrain + Hashmaps
Diffstat (limited to 'game/src/GameSession/TerrainMap.gdshader')
-rw-r--r--game/src/GameSession/TerrainMap.gdshader19
1 files changed, 7 insertions, 12 deletions
diff --git a/game/src/GameSession/TerrainMap.gdshader b/game/src/GameSession/TerrainMap.gdshader
index 05928f3..cab757b 100644
--- a/game/src/GameSession/TerrainMap.gdshader
+++ b/game/src/GameSession/TerrainMap.gdshader
@@ -10,27 +10,22 @@ uniform sampler2D province_colour_tex: source_color, repeat_enable, filter_neare
uniform uint hover_index;
// Index of the currently selected province
uniform uint selected_index;
-// Cosmetic farmlands terrain texture
-uniform sampler2D farmlands_tex: source_color, repeat_enable, filter_linear;
+// 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 water_colour = vec3(0, 0, 1);
-
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;
uint index = uvec2_to_uint(province_data.rg);
- float is_land = float(province_data.b != 0u);
- vec3 province_colour = texelFetch(province_colour_tex, ivec2(province_data.rg), 0).rgb;
- vec3 farmlands_colour = texture(farmlands_tex, terrain_uv).rgb;
- vec3 terrain_colour = mix(water_colour, farmlands_colour, is_land);
- float mix_val = 0.4 + float(index == hover_index) * 0.2 + float(index == selected_index) * 0.2;
- vec3 mixed_colour = mix(terrain_colour, province_colour, mix_val);
- return mixed_colour;
+ float mix_val = province_colour.a + float(index == hover_index) * 0.2 + float(index == selected_index) * 0.2;
+ return mix(terrain_colour, province_colour.rgb, mix_val);
}
vec3 mix_terrain_colour(vec2 uv) {
- vec2 map_size = vec2(textureSize(province_shape_tex, 0).xy);
+ 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;