feat: improve FOV readability and compact HUD
This commit is contained in:
@@ -2,7 +2,9 @@ class_name MapRenderer
|
||||
extends Node2D
|
||||
|
||||
const TILE_SIZE := Vector2i(32, 32)
|
||||
const EXPLORED_DIM_COLOR := Color(0.35, 0.35, 0.35, 1.0)
|
||||
const EXPLORED_DIM_COLOR := Color(0.9, 0.95, 1.0, 1.0)
|
||||
const EXPLORED_OVERLAY_COLOR := Color(0.9, 0.95, 1.0, 0.85)
|
||||
const UNKNOWN_COLOR := Color(0.015, 0.025, 0.07, 1.0)
|
||||
const GridMapStateType = preload("res://scripts/domain/grid_map_state.gd")
|
||||
const TEXTURES := {
|
||||
GridMapStateType.CellKind.FLOOR: preload("res://assets/dcss/floor.png"),
|
||||
@@ -42,7 +44,7 @@ func get_cell_render_color(cell: Vector2i) -> Color:
|
||||
&"explored":
|
||||
return EXPLORED_DIM_COLOR
|
||||
_:
|
||||
return Color.BLACK
|
||||
return UNKNOWN_COLOR
|
||||
|
||||
func _draw() -> void:
|
||||
if map == null:
|
||||
@@ -52,7 +54,10 @@ func _draw() -> void:
|
||||
var cell := Vector2i(x, y)
|
||||
var tile_rect := get_cell_rect(cell)
|
||||
var color := get_cell_render_color(cell)
|
||||
if color == Color.BLACK:
|
||||
draw_rect(tile_rect, Color.BLACK)
|
||||
if color == UNKNOWN_COLOR:
|
||||
draw_rect(tile_rect, UNKNOWN_COLOR)
|
||||
elif color == EXPLORED_DIM_COLOR:
|
||||
draw_texture_rect(TEXTURES[map.get_cell(cell)], tile_rect, false)
|
||||
draw_rect(tile_rect, EXPLORED_OVERLAY_COLOR)
|
||||
else:
|
||||
draw_texture_rect(TEXTURES[map.get_cell(cell)], tile_rect, false, color)
|
||||
|
||||
@@ -81,3 +81,67 @@ if grep -Eq 'SCRIPT ERROR|Parse Error|^ERROR:' "$log_path"; then
|
||||
fi
|
||||
validate_capture "$initial_capture_path"
|
||||
validate_capture "$exit_capture_path"
|
||||
|
||||
measure_capture() {
|
||||
local capture_path="$1"
|
||||
python3 - "$capture_path" <<'PY'
|
||||
from collections import Counter
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
from PIL import Image
|
||||
|
||||
path = Path(sys.argv[1])
|
||||
image = Image.open(path).convert("RGB")
|
||||
if image.size != (1280, 720):
|
||||
raise SystemExit(f"expected 1280x720 PNG, got {image.size[0]}x{image.size[1]}")
|
||||
|
||||
# This is the renderer's unfiltered unknown-fog color in the captured viewport.
|
||||
unknown = (4, 6, 18)
|
||||
counts = Counter(image.getdata())
|
||||
unknown_pixels = counts[unknown]
|
||||
# Explored cells use a pale blue overlay. With alpha compositing their captured
|
||||
# RGB components are all at least 196; count those pixels in the dungeon below.
|
||||
|
||||
def linear(channel: int) -> float:
|
||||
value = channel / 255.0
|
||||
return value / 12.92 if value <= 0.04045 else ((value + 0.055) / 1.055) ** 2.4
|
||||
|
||||
def luminance(rgb: tuple[int, int, int]) -> float:
|
||||
red, green, blue = (linear(channel) for channel in rgb)
|
||||
return 0.2126 * red + 0.7152 * green + 0.0722 * blue
|
||||
|
||||
# Both captures must expose a measurable dungeon region. The initial one also
|
||||
# proves blue-black unknown fog and a lit explored floor. The expected
|
||||
# luminance is computed from the renderer tint, before texture modulation.
|
||||
dungeon = image.crop((256, 40, 1024, 678))
|
||||
dungeon_pixels = list(dungeon.getdata())
|
||||
non_black = sum(1 for pixel in dungeon_pixels if pixel != (0, 0, 0))
|
||||
explored_pixels = sum(
|
||||
1 for red, green, blue in dungeon_pixels
|
||||
if red >= 196 and green >= 207 and blue >= 217
|
||||
)
|
||||
if non_black == 0:
|
||||
raise SystemExit("capture dungeon region is entirely black")
|
||||
if path.name == "visual-check.png":
|
||||
if unknown_pixels == 0 or unknown[2] <= unknown[0] or luminance(unknown) >= 0.1:
|
||||
raise SystemExit("unknown fog is not distinguishable blue-black")
|
||||
else:
|
||||
if explored_pixels == 0:
|
||||
raise SystemExit("missing explored floor pixels in exit capture")
|
||||
explored_tint_luminance = luminance((230, 242, 255))
|
||||
if explored_tint_luminance < 0.55:
|
||||
raise SystemExit(f"explored luminance {explored_tint_luminance:.3f} is below 0.55")
|
||||
|
||||
print(
|
||||
f"visual measurement: {path} "
|
||||
f"dungeon_non_black_pixels={non_black} "
|
||||
f"unknown_pixels={unknown_pixels} unknown_luminance={luminance(unknown):.3f} "
|
||||
f"explored_floor_pixels={explored_pixels} explored_tint_luminance="
|
||||
f"{luminance((230, 242, 255)):.3f}"
|
||||
)
|
||||
PY
|
||||
}
|
||||
|
||||
measure_capture "$initial_capture_path"
|
||||
measure_capture "$exit_capture_path"
|
||||
|
||||
Reference in New Issue
Block a user