diff options
author | Hop311 <hop3114@gmail.com> | 2023-04-05 19:38:40 +0200 |
---|---|---|
committer | Hop311 <hop3114@gmail.com> | 2023-04-05 19:38:40 +0200 |
commit | 2d47ff8c02a4ee88270634289381140f8ac1617e (patch) | |
tree | 920dc801e7bf5f83b9cca110a437a2e64524f1d7 /game/src/GameSession/TerrainMap.gdshader | |
parent | 29b334995b084e5d6944c45b7950c88f370941cc (diff) |
Custom map mesh that fixes UV issue
Diffstat (limited to 'game/src/GameSession/TerrainMap.gdshader')
-rw-r--r-- | game/src/GameSession/TerrainMap.gdshader | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/game/src/GameSession/TerrainMap.gdshader b/game/src/GameSession/TerrainMap.gdshader index f78779d..61b7032 100644 --- a/game/src/GameSession/TerrainMap.gdshader +++ b/game/src/GameSession/TerrainMap.gdshader @@ -11,21 +11,13 @@ uniform vec2 hover_pos; // Position in UV coords of a pixel belonging to the currently selected province uniform vec2 selected_pos; -// Transform map mesh UV coordinates to account for the extra -// half map on either side. This takes the x-coord from [0 -> 1] -// to [-0.5 -> 1.5], while leaving the y-coord unchanged. -vec2 fix_uv(vec2 uv) { - return vec2(uv.x * 2.0 - 0.5, uv.y); -} - const vec3 NULL_COLOUR = vec3(0.0); void fragment() { - vec2 fixed_uv = fix_uv(UV); - vec3 terrain_colour = texture(terrain_tex, fixed_uv).rgb; - vec3 prov_colour = texture(province_tex, fixed_uv).rgb; - vec3 hover_colour = texture(province_tex, fix_uv(hover_pos)).rgb; - vec3 selected_colour = texture(province_tex, fix_uv(selected_pos)).rgb; + vec3 terrain_colour = texture(terrain_tex, UV).rgb; + vec3 prov_colour = texture(province_tex, UV).rgb; + vec3 hover_colour = texture(province_tex, hover_pos).rgb; + vec3 selected_colour = texture(province_tex, selected_pos).rgb; // Boost prov_colour's contribution if it matches hover_colour or selected_colour float mix_val = float(prov_colour == hover_colour) * 0.3 + float(prov_colour == selected_colour) * 0.5; // Set to 0 if the province has NULL colour |