Skip to content
Snippets Groups Projects
Commit 3565df54 authored by Erik Wijmans's avatar Erik Wijmans Committed by Oleksandr
Browse files

Make fog-of-war darker and make that value changeable (#166)

* Make fog-of-war darker and make that value changeable
parent d3d6a5eb
No related branches found
No related tags found
No related merge requests found
......@@ -327,11 +327,10 @@ def get_topdown_map(
return top_down_map
FOG_OF_WAR_COLOR_DESAT = np.array([[0.7], [1.0]])
def colorize_topdown_map(
top_down_map: np.ndarray, fog_of_war_mask: Optional[np.ndarray] = None
top_down_map: np.ndarray,
fog_of_war_mask: Optional[np.ndarray] = None,
fog_of_war_desat_amount: float = 0.5,
) -> np.ndarray:
r"""Convert the top down map to RGB based on the indicator values.
Args:
......@@ -339,17 +338,21 @@ def colorize_topdown_map(
fog_of_war_mask: A mask used to determine which parts of the
top_down_map are visible
Non-visible parts will be desaturated
fog_of_war_desat_amount: Amount to desaturate the color of unexplored areas
Decreasing this value will make unexplored areas darker
Default: 0.5
Returns:
A colored version of the top-down map.
"""
_map = TOP_DOWN_MAP_COLORS[top_down_map]
if fog_of_war_mask is not None:
fog_of_war_desat_values = np.array([[fog_of_war_desat_amount], [1.0]])
# Only desaturate things that are valid points as only valid points get revealed
desat_mask = top_down_map != MAP_INVALID_POINT
_map[desat_mask] = (
_map * FOG_OF_WAR_COLOR_DESAT[fog_of_war_mask]
_map * fog_of_war_desat_values[fog_of_war_mask]
).astype(np.uint8)[desat_mask]
return _map
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment