Skip to content

Commit

Permalink
Fields padding for UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
iwatkot committed Dec 18, 2024
1 parent 00c92dc commit 27a0591
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 57 deletions.
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -427,20 +427,26 @@ The tool supports the custom size of the map. To use this feature select `Custom

⛔️ Do not use this feature, if you don't know what you're doing. In most cases, the Giants Editor will just crash on opening the file, because you need to enter specific values for the map size.<br><br>

![Advanced settings](https://github.com/user-attachments/assets/e7406adf-6b82-41a0-838a-13dd8877bebf)
![Advanced settings](https://github.com/user-attachments/assets/9e8e178a-58d9-4aa6-aefd-4ed53408701d)

You can also apply some advanced settings to the map generation process. Note that they're ADVANCED, so you don't need to use them if you're not sure what they do.<br>

Here's the list of the advanced settings:
### DEM Advanced settings

- DEM multiplier: the height of the map is multiplied by this value. So the DEM map is just a 16-bit grayscale image, which means that the maximum available value there is 65535, while the actual difference between the deepest and the highest point on Earth is about 20 km. Just note that this setting mostly does not matter, because you can always adjust it in the Giants Editor, learn more about the DEM file and the heightScale parameter in [docs](docs/dem.md). By default, it's set to 1.
- Multiplier: the height of the map is multiplied by this value. So the DEM map is just a 16-bit grayscale image, which means that the maximum available value there is 65535, while the actual difference between the deepest and the highest point on Earth is about 20 km. Just note that this setting mostly does not matter, because you can always adjust it in the Giants Editor, learn more about the DEM file and the heightScale parameter in [docs](docs/dem.md). By default, it's set to 1.

- DEM Blur radius: the radius of the Gaussian blur filter applied to the DEM map. By default, it's set to 21. This filter just makes the DEM map smoother, so the height transitions will be more natural. You can set it to 1 to disable the filter, but it will result in a Minecraft-like map.
- Blur radius: the radius of the Gaussian blur filter applied to the DEM map. By default, it's set to 21. This filter just makes the DEM map smoother, so the height transitions will be more natural. You can set it to 1 to disable the filter, but it will result in a Minecraft-like map.

- DEM Plateau height: this value will be added to each pixel of the DEM image, making it "higher". It's useful when you want to add some negative heights on the map, that appear to be in a "low" place. By default, it's set to 0.
- Plateau height: this value will be added to each pixel of the DEM image, making it "higher". It's useful when you want to add some negative heights on the map, that appear to be in a "low" place. By default, it's set to 0.

### Background Terrain Advanced settings

- Background Terrain Generate only full tiles: if checked (by default) the small tiles (N, NE, E, and so on) will not be generated, only the full tile will be created. It's useful when you don't want to work with separate tiles, but with one big file. Since the new method of cutting the map from the background terrain added to the documentation, and now it's possible to perfectly align the map with the background terrain, this option will remain just as a legacy one.

### Texture Advanced settings

- Fields padding - this value (in meters) will be applied to each field, making it smaller. It's useful when the fields are too close to each other and you want to make them smaller. By default, it's set to 0.

## Resources
In this section, you'll find a list of the resources that you need to create a map for the Farming Simulator.<br>
To create a basic map, you only need the Giants Editor. But if you want to create a background terrain - the world around the map, so it won't look like it's floating in the void - you also need Blender and the Blender Exporter Plugins. To create realistic textures for the background terrain, the QGIS is required to obtain high-resolution satellite images.<br>
Expand Down
124 changes: 72 additions & 52 deletions webui/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def add_left_widgets(self) -> None:
self.blur_radius_input = DEFAULT_BLUR_RADIUS
self.plateau_height_input = DEFAULT_PLATEAU
self.only_full_tiles = True
self.fields_padding = 0

if not self.auto_process:
self.logger.info("Auto preset is disabled.")
Expand All @@ -213,62 +214,80 @@ def add_left_widgets(self) -> None:
self.logger.debug("Advanced settings are enabled.")

st.warning("⚠️ Changing these settings can lead to unexpected results.")
st.info(
"ℹ️ [DEM] is for settings related to the Digital Elevation Model (elevation map). "
"This file is used to generate the terrain of the map (hills, valleys, etc.)."
)
# Show multiplier and blur radius inputs.
st.write("[DEM] Enter multiplier for the elevation map:")
st.write(Messages.DEM_MULTIPLIER_INFO)

self.multiplier_input = st.number_input(
"Multiplier",
value=DEFAULT_MULTIPLIER,
min_value=0,
max_value=10000,
step=1,
key="multiplier",
label_visibility="collapsed",
)

st.write("[DEM] Enter blur radius for the elevation map:")
st.write(Messages.DEM_BLUR_RADIUS_INFO)

self.blur_radius_input = st.number_input(
"Blur Radius",
value=DEFAULT_BLUR_RADIUS,
min_value=0,
max_value=300,
key="blur_radius",
label_visibility="collapsed",
step=2,
)
with st.expander("DEM Advanced Settings", icon="⛰️"):
st.info(
"ℹ️ Settings related to the Digital Elevation Model (elevation map). "
"This file is used to generate the terrain of the map (hills, valleys, etc.)."
)
# Show multiplier and blur radius inputs.
st.write("Enter the multiplier for the elevation map:")
st.write(Messages.DEM_MULTIPLIER_INFO)

self.multiplier_input = st.number_input(
"Multiplier",
value=DEFAULT_MULTIPLIER,
min_value=0,
max_value=10000,
step=1,
key="multiplier",
label_visibility="collapsed",
)

st.write("[DEM] Enter the plateau height (which will be added to the whole map):")
st.write(Messages.DEM_PLATEAU_INFO)
self.plateau_height_input = st.number_input(
"Plateau Height",
value=0,
min_value=0,
max_value=10000,
key="plateau_height",
label_visibility="collapsed",
)
st.write("Enter the blur radius for the elevation map:")
st.write(Messages.DEM_BLUR_RADIUS_INFO)

self.blur_radius_input = st.number_input(
"Blur Radius",
value=DEFAULT_BLUR_RADIUS,
min_value=0,
max_value=300,
key="blur_radius",
label_visibility="collapsed",
step=2,
)

st.info(
"ℹ️ [Background Terrain] is for settings related to the background terrain "
"which is a simple mesh around the playable area. "
)
st.write("Enter the plateau height (which will be added to the whole map):")
st.write(Messages.DEM_PLATEAU_INFO)
self.plateau_height_input = st.number_input(
"Plateau Height",
value=0,
min_value=0,
max_value=10000,
key="plateau_height",
label_visibility="collapsed",
)

st.write(
"[Background Terrain] Generate only full tiles (recommended) or all tiles:"
)
st.write(Messages.ONLY_FULL_TILES_INFO)
self.only_full_tiles = st.checkbox(
"Only Full Background Tiles",
key="only_full_tiles",
value=True,
)
with st.expander("Background Terrain Advanced Settings", icon="🏞️"):
st.info(
"ℹ️ Settings related to the background terrain "
"which is a simple mesh around the playable area. "
)

st.write("Generate only full tiles (recommended) or all tiles:")
st.write(Messages.ONLY_FULL_TILES_INFO)
self.only_full_tiles = st.checkbox(
"Only Full Background Tiles",
key="only_full_tiles",
value=True,
)

with st.expander("Textures Advanced Settings", icon="🎨"):
st.info(
"ℹ️ Settings related to the textures of the map, which represent different "
"types of terrain, such as grass, dirt, etc."
)

st.write("Enter the field padding (in meters):")
st.write(Messages.FIELD_PADDING_INFO)
self.fields_padding = st.number_input(
"Field Padding",
value=0,
min_value=0,
max_value=100,
key="field_padding",
label_visibility="collapsed",
)

# Add an empty container for status messages.
self.status_container = st.empty()
Expand Down Expand Up @@ -374,6 +393,7 @@ def generate_map(self) -> None:
plateau=self.plateau_height_input,
light_version=self.community,
only_full_tiles=self.only_full_tiles,
fields_padding=self.fields_padding,
)

if self.community:
Expand Down
4 changes: 4 additions & 0 deletions webui/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,7 @@ class Messages:
"In most cases you don't need splitted tiles, so it's recommended to keep this option "
"checked."
)
FIELD_PADDING_INFO = (
"This value is used to add some padding around the fields. "
"It will make the fields smaller, can be useful if they are too close to each other."
)

0 comments on commit 27a0591

Please sign in to comment.