A1: Style guide, palette and the woodcut print pass

docs/STYLE.md sets Tidewall's look: a drowned coast printed by hand. It has the
palette, shape language, character proportions, shading, UI motifs, audio
palette and a do-not-do list.

- Palette (src/client/style/palette.gd) is the one table of client colours.
  Every colour that was scattered over the views now names its entry, with
  values unchanged. test_palette fails on a colour literal anywhere else in
  src/client or src/app, and on a palette colour the guide doesn't list.
- Look sets up the sky, the salt-faded grading (saturation 0.86, contrast
  1.05), the sun and the print pass, for the match view and the capture scenes.
- folk_print.gdshader is one full-screen quad multiplied over the frame. It
  draws ink lines at depth jumps and creases (fading with distance, scaled with
  screen height), diagonal hatching cut into real shadow, and faint paper
  grain. Ground under the sea gets none.
- make style-captures renders a hamlet and a dock with and without the pass.

Closes #41

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-13 08:57:11 -05:00
co-authored by Claude Opus 5.5
parent ce89ca4929
commit d7c8ed7e6e
24 changed files with 651 additions and 76 deletions
+8
View File
@@ -0,0 +1,8 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://test/capture/terrain_scene.gd" id="1"]
[node name="CaptureStyle" type="Node3D"]
script = ExtResource("1")
poi_kind = "dock"
show_props = true
+9
View File
@@ -0,0 +1,9 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://test/capture/terrain_scene.gd" id="1"]
[node name="CaptureStyle" type="Node3D"]
script = ExtResource("1")
poi_kind = "dock"
show_props = true
print_pass = false
+8
View File
@@ -0,0 +1,8 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://test/capture/terrain_scene.gd" id="1"]
[node name="CaptureStyle" type="Node3D"]
script = ExtResource("1")
poi_kind = "hamlet"
show_props = true
+9
View File
@@ -0,0 +1,9 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://test/capture/terrain_scene.gd" id="1"]
[node name="CaptureStyle" type="Node3D"]
script = ExtResource("1")
poi_kind = "hamlet"
show_props = true
print_pass = false
+7 -20
View File
@@ -32,6 +32,9 @@ const CRACK_COLOUR: Color = Color(1.0, 0.0, 1.0)
@export var prop_view: Vector3 = Vector3(10.0, 4.0, 14.0)
## Destroy every `knock_out`th prop near the framed one, to show felled props vanish.
@export var knock_out: int = 0
## Draw with the woodcut print pass and graded colour (docs/STYLE.md). Off shows the
## plain render, for before-and-after captures.
@export var print_pass: bool = true
func _ready() -> void:
@@ -44,31 +47,13 @@ func _ready() -> void:
environment.ambient_light_color = Color(0.5, 0.5, 0.5)
environment.tonemap_mode = Environment.TONE_MAPPER_LINEAR
else:
var sky_material: ProceduralSkyMaterial = ProceduralSkyMaterial.new()
sky_material.sky_top_color = Color(0.32, 0.5, 0.68)
sky_material.sky_horizon_color = Color(0.82, 0.78, 0.68)
sky_material.ground_bottom_color = Color(0.18, 0.2, 0.2)
sky_material.ground_horizon_color = Color(0.82, 0.78, 0.68)
var sky: Sky = Sky.new()
sky.sky_material = sky_material
environment.background_mode = Environment.BG_SKY
environment.sky = sky
environment.ambient_light_source = Environment.AMBIENT_SOURCE_SKY
environment.ambient_light_energy = 0.45
environment.tonemap_mode = Environment.TONE_MAPPER_FILMIC
environment.fog_enabled = true
environment.fog_light_color = Color(0.78, 0.78, 0.74)
environment.fog_density = 0.0005
environment.fog_aerial_perspective = 0.4
environment = Look.environment(print_pass)
var world: WorldEnvironment = WorldEnvironment.new()
world.environment = environment
add_child(world)
var sun: DirectionalLight3D = DirectionalLight3D.new()
sun.rotation_degrees = Vector3(-35.0, -130.0, 0.0)
sun.light_energy = 0.95
var sun: DirectionalLight3D = Look.sun(600.0)
sun.shadow_enabled = not crack_check
sun.directional_shadow_max_distance = 600.0
add_child(sun)
var camera: Camera3D = Camera3D.new()
@@ -123,6 +108,8 @@ func _ready() -> void:
add_child(camera)
camera.look_at(look_at_point)
camera.make_current()
if print_pass and not crack_check:
Look.set_sea_level(Look.add_print_pass(camera), sea_level if show_water else -1000.0)
var terrain: TerrainView = TerrainView.new()
terrain.setup(island)
+42
View File
@@ -0,0 +1,42 @@
extends TestCase
## Issue A1: the shared look. The match view gets the graded environment and the
## woodcut print pass, and the pass follows the sea.
func test_environment_is_graded_and_uses_the_palette() -> void:
var environment: Environment = Look.environment()
assert_true(environment.adjustment_enabled)
assert_near(environment.adjustment_saturation, Look.SATURATION, 0.0001)
assert_true(Look.SATURATION < 1.0, "salt-faded: greyer than rendered")
var sky: ProceduralSkyMaterial = environment.sky.sky_material as ProceduralSkyMaterial
assert_eq(sky.sky_horizon_color, Palette.SKY_HAZE)
assert_eq(environment.fog_light_color, Palette.SEA_FOG)
assert_false(Look.environment(false).adjustment_enabled, "ungraded for comparisons")
func test_match_view_draws_through_the_print_pass() -> void:
var sim: Simulation = Simulation.new(3, SimGround.flat())
var view: MatchView = MatchView.new()
view.setup(sim)
assert_not_null(view.print_pass)
assert_eq(view.print_pass.get_parent(), view.camera, "it rides on the camera")
var material: ShaderMaterial = (view.print_pass.mesh as QuadMesh).material as ShaderMaterial
assert_eq(material.shader, Look.PRINT_SHADER)
assert_eq(material.render_priority, Material.RENDER_PRIORITY_MAX, "drawn after everything it darkens")
assert_eq(material.get_shader_parameter("ink_colour"), Palette.INK)
sim.set_sea_level(6.5)
sim.step()
view.sync()
assert_near(float(material.get_shader_parameter("sea_level")), view.water.level, 0.0001, "no ink under the sea")
view.free()
func test_print_shader_compiles() -> void:
# A shader that fails to compile still loads; its code must at least parse into
# uniforms, which an invalid one doesn't list.
var names: Array[String] = []
for uniform: Dictionary in Look.PRINT_SHADER.get_shader_uniform_list():
names.append(String(uniform["name"]))
for wanted: String in ["ink_colour", "strength", "sea_level", "hatch_spacing", "camera_far"]:
assert_true(names.has(wanted), "uniform %s in %s" % [wanted, names])
+1
View File
@@ -0,0 +1 @@
uid://cfnbvdys6s8xm
+61
View File
@@ -0,0 +1,61 @@
extends TestCase
## A1: every colour the client draws with comes from Palette (docs/STYLE.md).
## Scripts allowed literal Color() values, and why.
const ALLOWED: Dictionary = {
"res://src/client/style/palette.gd": "the palette itself",
"res://src/client/terrain/terrain_chunk_builder.gd": "splat weights carried in vertex colours, not colours",
}
## A Color() made only of number literals, or a named engine colour other than the
## neutral ones used as multipliers.
const LITERAL: String = "Color\\(\\s*-?[0-9.]+\\s*,\\s*-?[0-9.]+\\s*,\\s*-?[0-9.]+\\s*(,\\s*-?[0-9.]+\\s*)?\\)"
const NAMED: String = "Color\\.(?!WHITE\\b|BLACK\\b|TRANSPARENT\\b)[A-Z_]+\\b|Color8\\(|Color\\.html\\("
func test_client_colours_come_from_the_palette() -> void:
var literal: RegEx = RegEx.create_from_string(LITERAL)
var named: RegEx = RegEx.create_from_string(NAMED)
var paths: Array[String] = _scripts_under("res://src/client")
paths.append_array(_scripts_under("res://src/app"))
assert_true(paths.size() > 10, "expected client scripts")
for path: String in paths:
if ALLOWED.has(path):
continue
for line: String in FileAccess.get_file_as_string(path).split("\n"):
var code: String = line.get_slice("#", 0)
if literal.search(code) != null or named.search(code) != null:
fail("%s has a colour outside Palette: %s" % [path, code.strip_edges()])
func test_scanner_catches_literals_and_named_colours() -> void:
var literal: RegEx = RegEx.create_from_string(LITERAL)
var named: RegEx = RegEx.create_from_string(NAMED)
assert_not_null(literal.search("var c: Color = Color(0.5, 0.2, 0.1)"))
assert_not_null(literal.search("Color(1, 0, 0, 0.5)"))
assert_null(literal.search("Color(base.r + shift, 0.0, 1.0)"))
assert_not_null(named.search("x = Color.RED"))
assert_not_null(named.search("Color.html(\"#fff\")"))
assert_null(named.search("tint = Color.WHITE"))
func test_palette_matches_the_style_guide() -> void:
# Each named colour is listed in docs/STYLE.md, so the guide can't fall behind.
var guide: String = FileAccess.get_file_as_string("res://docs/STYLE.md")
assert_true(not guide.is_empty(), "docs/STYLE.md should exist")
var names: PackedStringArray = PackedStringArray()
for constant: String in (Palette as Script).get_script_constant_map():
names.append(constant)
assert_true(names.size() > 20, "expected the palette's colours")
for constant: String in names:
assert_true(guide.contains("`%s`" % constant), "docs/STYLE.md should list `%s`" % constant)
func _scripts_under(dir_path: String) -> Array[String]:
var found: Array[String] = []
for name: String in DirAccess.get_files_at(dir_path):
if name.ends_with(".gd"):
found.append(dir_path.path_join(name))
for name: String in DirAccess.get_directories_at(dir_path):
found.append_array(_scripts_under(dir_path.path_join(name)))
return found
+1
View File
@@ -0,0 +1 @@
uid://dwcwolwyr3b4s