aboutsummaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
Diffstat (limited to 'game')
-rw-r--r--game/art/terrain/desert_rocky.pngbin0 -> 417538 bytes
-rw-r--r--game/art/terrain/desert_rocky.png.import34
-rw-r--r--game/art/terrain/desert_smooth.pngbin0 -> 202420 bytes
-rw-r--r--game/art/terrain/desert_smooth.png.import34
-rw-r--r--game/art/terrain/mountains.pngbin0 -> 374999 bytes
-rw-r--r--game/art/terrain/mountains.png.import34
-rw-r--r--game/art/terrain/ocean.pngbin0 -> 92335 bytes
-rw-r--r--game/art/terrain/ocean.png.import34
-rw-r--r--game/common/map/terrain.json7
-rw-r--r--game/common/map/terrain.pngbin0 -> 650002 bytes
-rw-r--r--game/common/map/terrain.png.import3
-rw-r--r--game/src/Autoload/Events.gd10
-rw-r--r--game/src/Autoload/Events/ShaderManager.gd20
-rw-r--r--game/src/GameSession/GameSession.tscn1
-rw-r--r--game/src/GameSession/MapView.gd14
-rw-r--r--game/src/GameSession/MapView.tscn6
-rw-r--r--game/src/GameSession/ProvinceOverviewPanel.gd4
-rw-r--r--game/src/GameSession/TerrainMap.gdshader19
18 files changed, 190 insertions, 30 deletions
diff --git a/game/art/terrain/desert_rocky.png b/game/art/terrain/desert_rocky.png
new file mode 100644
index 0000000..f7f9155
--- /dev/null
+++ b/game/art/terrain/desert_rocky.png
Binary files differ
diff --git a/game/art/terrain/desert_rocky.png.import b/game/art/terrain/desert_rocky.png.import
new file mode 100644
index 0000000..b8104eb
--- /dev/null
+++ b/game/art/terrain/desert_rocky.png.import
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://do6rtj6cejxo7"
+path="res://.godot/imported/desert_rocky.png-2c26845e144e1e8b9c55419654df6654.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://art/terrain/desert_rocky.png"
+dest_files=["res://.godot/imported/desert_rocky.png-2c26845e144e1e8b9c55419654df6654.ctex"]
+
+[params]
+
+compress/mode=3
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=2
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=false
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=0
diff --git a/game/art/terrain/desert_smooth.png b/game/art/terrain/desert_smooth.png
new file mode 100644
index 0000000..4e977cd
--- /dev/null
+++ b/game/art/terrain/desert_smooth.png
Binary files differ
diff --git a/game/art/terrain/desert_smooth.png.import b/game/art/terrain/desert_smooth.png.import
new file mode 100644
index 0000000..bc0513d
--- /dev/null
+++ b/game/art/terrain/desert_smooth.png.import
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://beo5i11jfu3al"
+path="res://.godot/imported/desert_smooth.png-58a5349b112e9e97cf3426b380f022ef.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://art/terrain/desert_smooth.png"
+dest_files=["res://.godot/imported/desert_smooth.png-58a5349b112e9e97cf3426b380f022ef.ctex"]
+
+[params]
+
+compress/mode=3
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=2
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=false
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=0
diff --git a/game/art/terrain/mountains.png b/game/art/terrain/mountains.png
new file mode 100644
index 0000000..301ee23
--- /dev/null
+++ b/game/art/terrain/mountains.png
Binary files differ
diff --git a/game/art/terrain/mountains.png.import b/game/art/terrain/mountains.png.import
new file mode 100644
index 0000000..47a00fd
--- /dev/null
+++ b/game/art/terrain/mountains.png.import
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://c20q2sqf38eq8"
+path="res://.godot/imported/mountains.png-f1ab7d9b0a0deb485923c40b1cfb258e.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://art/terrain/mountains.png"
+dest_files=["res://.godot/imported/mountains.png-f1ab7d9b0a0deb485923c40b1cfb258e.ctex"]
+
+[params]
+
+compress/mode=3
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=2
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=false
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=0
diff --git a/game/art/terrain/ocean.png b/game/art/terrain/ocean.png
new file mode 100644
index 0000000..3e52011
--- /dev/null
+++ b/game/art/terrain/ocean.png
Binary files differ
diff --git a/game/art/terrain/ocean.png.import b/game/art/terrain/ocean.png.import
new file mode 100644
index 0000000..644f7e7
--- /dev/null
+++ b/game/art/terrain/ocean.png.import
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://dlvvim3j7dbnn"
+path="res://.godot/imported/ocean.png-3d7e213c3fca805d033e0d3bf567fc01.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://art/terrain/ocean.png"
+dest_files=["res://.godot/imported/ocean.png-3d7e213c3fca805d033e0d3bf567fc01.ctex"]
+
+[params]
+
+compress/mode=3
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=2
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=false
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=0
diff --git a/game/common/map/terrain.json b/game/common/map/terrain.json
new file mode 100644
index 0000000..60596c9
--- /dev/null
+++ b/game/common/map/terrain.json
@@ -0,0 +1,7 @@
+{
+ "ocean.png": "204080",
+ "farmlands.png": [88, 170, 37],
+ "mountains.png": "584B25",
+ "desert_rocky.png": "A06C38",
+ "desert_smooth.png": "BAA644"
+}
diff --git a/game/common/map/terrain.png b/game/common/map/terrain.png
new file mode 100644
index 0000000..6e7ca0a
--- /dev/null
+++ b/game/common/map/terrain.png
Binary files differ
diff --git a/game/common/map/terrain.png.import b/game/common/map/terrain.png.import
new file mode 100644
index 0000000..8dd0c09
--- /dev/null
+++ b/game/common/map/terrain.png.import
@@ -0,0 +1,3 @@
+[remap]
+
+importer="keep"
diff --git a/game/src/Autoload/Events.gd b/game/src/Autoload/Events.gd
index f94d338..47c3b88 100644
--- a/game/src/Autoload/Events.gd
+++ b/game/src/Autoload/Events.gd
@@ -8,7 +8,9 @@ var ShaderManager = preload("Events/ShaderManager.gd").new()
const _province_identifier_file : String = "res://common/map/provinces.json"
const _water_province_file : String = "res://common/map/water.json"
const _region_file : String = "res://common/map/regions.json"
-const _province_shape_file : String = "res://common/map/provinces.png"
+const _terrain_file : String = "res://common/map/terrain.json"
+const _province_image_file : String = "res://common/map/provinces.png"
+const _terrain_image_file : String = "res://common/map/terrain.png"
# REQUIREMENTS
# * FS-333, FS-334, FS-335, FS-341
@@ -19,5 +21,7 @@ func _ready():
push_error("Failed to load water provinces")
if GameSingleton.load_region_file(_region_file) != OK:
push_error("Failed to load regions")
- if GameSingleton.load_province_shape_file(_province_shape_file) != OK:
- push_error("Failed to load province shapes")
+ if GameSingleton.load_terrain_file(_terrain_file) != OK:
+ push_error("Failed to load terrain variants")
+ if GameSingleton.load_map_images(_province_image_file, _terrain_image_file) != OK:
+ push_error("Failed to load map images")
diff --git a/game/src/Autoload/Events/ShaderManager.gd b/game/src/Autoload/Events/ShaderManager.gd
index 96ed5b4..a503c52 100644
--- a/game/src/Autoload/Events/ShaderManager.gd
+++ b/game/src/Autoload/Events/ShaderManager.gd
@@ -1,13 +1,14 @@
extends RefCounted
-const param_province_shape : StringName = &"province_shape_tex"
+const param_province_shape_tex : StringName = &"province_shape_tex"
const param_province_shape_subdivisions : StringName = &"province_shape_subdivisions"
-const param_province_colour : StringName = &"province_colour_tex"
+const param_province_colour_tex : StringName = &"province_colour_tex"
const param_hover_index : StringName = &"hover_index"
const param_selected_index : StringName = &"selected_index"
+const param_terrain_tex : StringName = &"terrain_tex"
const param_terrain_tile_factor : StringName = &"terrain_tile_factor"
-func set_up_shader(material : Material, add_colour_texture : bool) -> Error:
+func set_up_shader(material : Material, add_cosmetic_textures : bool) -> Error:
# Shader Material
if material == null:
push_error("material is null!")
@@ -22,19 +23,26 @@ func set_up_shader(material : Material, add_colour_texture : bool) -> Error:
if province_shape_texture == null:
push_error("Failed to get province shape texture!")
return FAILED
- shader_material.set_shader_parameter(param_province_shape, province_shape_texture)
+ shader_material.set_shader_parameter(param_province_shape_tex, province_shape_texture)
var subdivisions := GameSingleton.get_province_shape_image_subdivisions()
if subdivisions.x < 1 or subdivisions.y < 1:
push_error("Invalid province shape image subdivision: ", subdivisions.x, "x", subdivisions.y)
return FAILED
shader_material.set_shader_parameter(param_province_shape_subdivisions, Vector2(subdivisions))
- if add_colour_texture:
+ if add_cosmetic_textures:
# Province colour texture
var map_province_colour_texture := GameSingleton.get_province_colour_texture()
if map_province_colour_texture == null:
push_error("Failed to get province colour image!")
return FAILED
- shader_material.set_shader_parameter(param_province_colour, map_province_colour_texture)
+ shader_material.set_shader_parameter(param_province_colour_tex, map_province_colour_texture)
+
+ # Terrain texture
+ var terrain_texture := GameSingleton.get_terrain_texture()
+ if terrain_texture == null:
+ push_error("Failed to get terrain texture!")
+ return FAILED
+ shader_material.set_shader_parameter(param_terrain_tex, terrain_texture)
return OK
diff --git a/game/src/GameSession/GameSession.tscn b/game/src/GameSession/GameSession.tscn
index 98b43dd..c146b3e 100644
--- a/game/src/GameSession/GameSession.tscn
+++ b/game/src/GameSession/GameSession.tscn
@@ -74,5 +74,6 @@ grow_horizontal = 0
[connection signal="mouse_exited" from="MapControlPanel" to="MapView" method="_on_mouse_entered_viewport"]
[connection signal="zoom_in_button_pressed" from="MapControlPanel" to="MapView" method="zoom_in"]
[connection signal="zoom_out_button_pressed" from="MapControlPanel" to="MapView" method="zoom_out"]
+[connection signal="province_deselected" from="ProvinceOverviewPanel" to="MapView" method="_deselect_province"]
[connection signal="back_button_pressed" from="OptionsMenu" to="MapView" method="enable_processing"]
[connection signal="back_button_pressed" from="OptionsMenu" to="OptionsMenu" method="hide"]
diff --git a/game/src/GameSession/MapView.gd b/game/src/GameSession/MapView.gd
index 340083f..2e2c5e6 100644
--- a/game/src/GameSession/MapView.gd
+++ b/game/src/GameSession/MapView.gd
@@ -71,7 +71,8 @@ func _ready():
# Set map mesh size and get bounds
_map_mesh.aspect_ratio = GameSingleton.get_aspect_ratio()
- _map_shader_material.set_shader_parameter(Events.ShaderManager.param_terrain_tile_factor, float(GameSingleton.get_height()) / 64.0)
+ _map_shader_material.set_shader_parameter(Events.ShaderManager.param_terrain_tile_factor,
+ float(GameSingleton.get_height()) / 128.0)
var map_mesh_aabb := _map_mesh.get_core_aabb() * _map_mesh_instance.transform
_map_mesh_corner = Vector2(
min(map_mesh_aabb.position.x, map_mesh_aabb.end.x),
@@ -111,15 +112,20 @@ func zoom_in() -> void:
func zoom_out() -> void:
_zoom_target += _zoom_target_step
+func _select_province(index : int) -> void:
+ _map_shader_material.set_shader_parameter(Events.ShaderManager.param_selected_index, index)
+ province_selected.emit(index)
+
+func _deselect_province() -> void:
+ _select_province(0)
+
# REQUIREMENTS
# * SS-31
func _unhandled_input(event : InputEvent):
if _mouse_over_viewport and event.is_action_pressed(_action_click):
# Check if the mouse is outside of bounds
if _map_mesh.is_valid_uv_coord(_mouse_pos_map):
- var selected_index := GameSingleton.get_province_index_from_uv_coords(_mouse_pos_map)
- _map_shader_material.set_shader_parameter(Events.ShaderManager.param_selected_index, selected_index)
- province_selected.emit(selected_index)
+ _select_province(GameSingleton.get_province_index_from_uv_coords(_mouse_pos_map))
else:
print("Clicked outside the map!")
elif event.is_action_pressed(_action_drag):
diff --git a/game/src/GameSession/MapView.tscn b/game/src/GameSession/MapView.tscn
index efbad4e..fa6ffcd 100644
--- a/game/src/GameSession/MapView.tscn
+++ b/game/src/GameSession/MapView.tscn
@@ -1,17 +1,15 @@
-[gd_scene load_steps=6 format=3 uid="uid://dkehmdnuxih2r"]
+[gd_scene load_steps=5 format=3 uid="uid://dkehmdnuxih2r"]
[ext_resource type="Script" path="res://src/GameSession/MapView.gd" id="1_exccw"]
[ext_resource type="Shader" path="res://src/GameSession/TerrainMap.gdshader" id="1_upocn"]
-[ext_resource type="Texture2D" uid="uid://ckf222w5usrsu" path="res://art/terrain/farmlands.png" id="3_47mq1"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_tayeg"]
render_priority = 0
shader = ExtResource("1_upocn")
-shader_parameter/province_index_subdivisions = null
+shader_parameter/province_shape_subdivisions = null
shader_parameter/hover_index = null
shader_parameter/selected_index = null
shader_parameter/terrain_tile_factor = null
-shader_parameter/farmlands_tex = ExtResource("3_47mq1")
[sub_resource type="MapMesh" id="MapMesh_3gtsd"]
diff --git a/game/src/GameSession/ProvinceOverviewPanel.gd b/game/src/GameSession/ProvinceOverviewPanel.gd
index 17da9d0..5a914f7 100644
--- a/game/src/GameSession/ProvinceOverviewPanel.gd
+++ b/game/src/GameSession/ProvinceOverviewPanel.gd
@@ -1,5 +1,7 @@
extends PanelContainer
+signal province_deselected
+
@export var _province_name_label : Label
@export var _region_name_label : Label
@export var _life_rating_bar : ProgressBar
@@ -92,4 +94,4 @@ func _on_province_selected(index : int) -> void:
_selected_index = index
func _on_close_button_pressed() -> void:
- _selected_index = 0
+ province_deselected.emit()
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;