feat: mosswart client icon and Asheron's Call-inspired launcher icon

acdream had no application icon on either executable. Two marks now ship,
built from the game's own material rather than drawn freehand:

* Client - the retail mosswart head. Not an illustration of one: the actual
  creature mesh (Setup 0x02000B4F part 14, skin atlas 0x05001E11,
  ClothingBase 0x10000344) read out of client_portal.dat through acdream's
  own GfxObjMesh/SetupMesh port, then smoothed, lit and graded. Palette
  values are sampled from that texture, including the mustard belly the
  Mosswart lore calls a "foul yellow".

* Launcher - a forged ring enclosing a barbed crescent, rebuilt from
  measurements of the retail wordmark and the acclient.exe icon resource.
  An original construction in the same visual language, not a copy of the
  trademarked logo. Its warm field matches the retail client icon.

Three techniques carry the render quality, all in tools/IconForge:

* PN-triangle tessellation (smooth.py). The retail head is 104 triangles
  and renders faceted. Each triangle becomes a cubic Bezier patch built
  from its own corner positions and normals, so the silhouette genuinely
  rounds rather than merely shading smoothly - and it needs no mesh
  connectivity, which matters because UV seams would otherwise pull apart.
  Normals are welded across coincident positions first, but only within a
  crease angle, so ear fins and tusk edges stay sharp.

* Matcaps (ring.py). A Lambert rasterizer cannot produce chrome, because
  chrome is almost entirely reflection and there is nothing here to
  reflect. Sampling a lit-sphere image by the camera-space normal is the
  standard stand-in for an environment map.

* Distance-transform bevelling (chisel.py). Flat shapes become chiselled
  metal by treating distance-to-edge as height. The height field is
  blurred before differentiating; without that the medial axis of each
  stroke shows through as a hatched ridge.

Two facts worth recording, both discovered the hard way. Creature Setups
define no upright pose in PlacementFrames, so the exporter must be handed
the weenie's MotionTable id or all 17 parts stack on the origin. And a
mosswart's eyes sit on the sides of the skull like a frog's, so a dead-on
frontal turns them edge-on and the face stops reading as a mosswart at all;
the hero angle is az 266 / el 32.

Wiring: <ApplicationIcon> gives each executable its PE icon. The client's
runtime window icon is embedded rather than copied beside the binary - a
window icon has no sensible fallback if the file goes missing, and
embedding survives single-file publish. WindowIconLoaderTests guards the
resource names, which are coupled to LogicalName in the csproj by string
alone and would otherwise fail only as a silently icon-less window.

Both halves of the pipeline are deterministic and reproduce the committed
PNGs byte-for-byte, so an accidental edit shows up as a diff.

Solution builds clean; 14,378 tests pass on the standard hermetic lane
filter, 0 failures.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-08-20 14:42:10 +02:00
parent 4d84456c21
commit a1ffe77af4
43 changed files with 2210 additions and 0 deletions

View file

@ -8,6 +8,10 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<RootNamespace>AcDream.App</RootNamespace>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<!-- Windows shell/Explorer icon for the client executable. The runtime
window icon is a separate mechanism (WindowIconLoader) because the exe
icon is baked into the PE and never reaches GLFW. -->
<ApplicationIcon>..\..\assets\icons\acdream-client.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<InternalsVisibleTo Include="AcDream.Core.Tests" />
@ -81,6 +85,21 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<!-- Runtime window icon (WindowIconLoader). Embedded rather than copied:
a window icon has no sensible fallback if the file goes missing, and
embedding survives single-file publish. Included from assets/icons
with an explicit LogicalName so the art has ONE source of truth and is
not duplicated into this project's tree. -->
<EmbeddedResource Include="..\..\assets\icons\acdream-client-16.png"
LogicalName="AcDream.App.Rendering.Icons.acdream-client-16.png" />
<EmbeddedResource Include="..\..\assets\icons\acdream-client-32.png"
LogicalName="AcDream.App.Rendering.Icons.acdream-client-32.png" />
<EmbeddedResource Include="..\..\assets\icons\acdream-client-48.png"
LogicalName="AcDream.App.Rendering.Icons.acdream-client-48.png" />
<EmbeddedResource Include="..\..\assets\icons\acdream-client-256.png"
LogicalName="AcDream.App.Rendering.Icons.acdream-client-256.png" />
</ItemGroup>
<ItemGroup>
<!-- Build the smoke plugin first and copy it into plugins/AcDream.Plugins.Smoke/ -->
<ProjectReference Include="..\AcDream.Plugins.Smoke\AcDream.Plugins.Smoke.csproj">

View file

@ -800,6 +800,10 @@ public sealed class GameWindow :
_startupQuality = startup.Quality;
_window = Window.Create(options);
// Before any callback binding: the icon is pure window decoration and
// has no ordering relationship with the render loop, so it belongs at
// the earliest point the native window exists.
WindowIconLoader.Apply(_window);
IWindow window = _window;
_lifetime.PublishNativeWindow(
window,

View file

@ -0,0 +1,107 @@
using Silk.NET.Core;
using Silk.NET.Windowing;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
namespace AcDream.App.Rendering;
/// <summary>
/// Applies acdream's window icon to the native window.
/// </summary>
/// <remarks>
/// <para>
/// The icon art is the retail mosswart head (Setup <c>0x02000B4F</c> part 14,
/// skin <c>0x05001E11</c>) rendered offline by <c>tools/IconForge</c>; only the
/// baked PNGs ship. See <c>assets/icons/README.md</c>.
/// </para>
/// <para>
/// The PNGs are <b>embedded</b> rather than copied next to the binary, unlike
/// the shader/markup assets in this project. Two reasons: a window icon has no
/// sensible runtime fallback if the file is missing, and embedding keeps it
/// intact under single-file publish. The cost is a few tens of KB in the
/// assembly.
/// </para>
/// <para>
/// Several sizes are handed over at once because the window manager picks the
/// closest match per surface — the title bar wants ~16px while Alt-Tab and the
/// taskbar want 32-256px, and letting the WM choose beats shipping one size and
/// having it resampled badly.
/// </para>
/// </remarks>
internal static class WindowIconLoader
{
// Ordered small -> large purely for readability; the window manager selects
// by size, not by position.
private static readonly string[] ResourceNames =
{
"AcDream.App.Rendering.Icons.acdream-client-16.png",
"AcDream.App.Rendering.Icons.acdream-client-32.png",
"AcDream.App.Rendering.Icons.acdream-client-48.png",
"AcDream.App.Rendering.Icons.acdream-client-256.png",
};
/// <summary>
/// Decode the embedded icon set and hand it to the window.
/// </summary>
public static void Apply(IWindow window)
{
ArgumentNullException.ThrowIfNull(window);
RawImage[] images;
try
{
images = Decode();
}
catch (Exception failure)
{
// A missing or corrupt embedded resource is a build defect, not a
// runtime condition — say so loudly rather than shipping a silent
// catch, but do not take the client down over cosmetics.
Console.Error.WriteLine($"window icon: could not decode embedded icons — {failure}");
return;
}
if (images.Length == 0)
{
Console.Error.WriteLine("window icon: no embedded icon resources found");
return;
}
try
{
window.SetWindowIcon(images.AsSpan());
}
catch (Exception failure)
{
// Wayland has no window-icon protocol and GLFW reports the request
// as unsupported there. That is a platform fact, not a bug, and it
// must not be fatal — but it is still worth printing so an
// unexpectedly icon-less window on a supported platform is
// traceable rather than mysterious.
Console.Error.WriteLine($"window icon: platform rejected the icon — {failure.Message}");
}
}
private static RawImage[] Decode()
{
var assembly = typeof(WindowIconLoader).Assembly;
var decoded = new List<RawImage>(ResourceNames.Length);
foreach (string name in ResourceNames)
{
using Stream? stream = assembly.GetManifestResourceStream(name);
if (stream is null)
{
Console.Error.WriteLine($"window icon: embedded resource missing — {name}");
continue;
}
using var image = Image.Load<Rgba32>(stream);
var pixels = new byte[image.Width * image.Height * 4];
image.CopyPixelDataTo(pixels);
decoded.Add(new RawImage(image.Width, image.Height, pixels));
}
return decoded.ToArray();
}
}

View file

@ -8,6 +8,10 @@
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<!-- Windows shell/Explorer icon for acdream-launcher.exe. The window icon
is set separately via Window.Icon in MainWindow.axaml — the PE icon
never reaches Avalonia. -->
<ApplicationIcon>..\..\assets\icons\acdream-launcher.ico</ApplicationIcon>
<PublishSingleFile>true</PublishSingleFile>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<SelfContained Condition="'$(RuntimeIdentifier)' != ''">true</SelfContained>
@ -62,6 +66,14 @@
<InternalsVisibleTo Include="AcDream.Launcher.Tests" />
</ItemGroup>
<ItemGroup>
<!-- Window icon for the Avalonia shell. Linked from assets/icons so the
art has one source of truth; the Link is what fixes the avares path
MainWindow.axaml resolves. -->
<AvaloniaResource Include="..\..\assets\icons\acdream-launcher-256.png"
Link="Assets/acdream-launcher.png" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" />
<PackageReference Include="Avalonia.Desktop" />

View file

@ -4,6 +4,7 @@
x:Class="AcDream.Launcher.MainWindow"
x:DataType="vm:LauncherWindowViewModel"
Title="acdream launcher"
Icon="avares://acdream-launcher/Assets/acdream-launcher.png"
Width="1180"
Height="760"
MinWidth="900"