Four fixes from T4 spec review: 1. Extracted InstanceData.cs (14-line struct) verbatim to src/AcDream.App/Rendering/Wb/InstanceData.cs (per O-D1). 2. ObjectMeshManager.cs: replaced `using Chorizite.OpenGLSDLBackend.Lib;` with `using AcDream.Core.Rendering.Wb;` (TextureHelpers comes from our T2 Core extraction; InstanceData comes from new T4 cleanup). 3. EmbeddedResourceReader.GetEmbeddedResource promoted from `internal` to `public` per O-D9 intent (the type promotion only changed the class signature in T3; this finishes the spec). 4. OpenGLGraphicsDevice.cs: removed stale T3 interim comment at lines 142-145 — T4 resolved the ParticleBatcher construction via post-ctor assignment in WbMeshAdapter.cs:78. Build green; tests green (1147 passing, 8 pre-existing failures baseline maintained). Spec: docs/superpowers/specs/2026-05-21-phase-o-dat-path-unification-design.md Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
45 lines
2 KiB
C#
45 lines
2 KiB
C#
using System;
|
|
using System.IO;
|
|
|
|
namespace AcDream.App.Rendering.Wb {
|
|
|
|
/// <summary>
|
|
/// Resolves WB-style shader resource names (e.g. "Shaders.Particle.vert") to
|
|
/// the corresponding file under the acdream binary's Rendering/Shaders directory.
|
|
///
|
|
/// WB embeds shaders as assembly resources under the Chorizite.OpenGLSDLBackend
|
|
/// namespace. acdream ships shaders as plain files copied to the output directory.
|
|
/// This class adapts between the two conventions so ParticleBatcher and
|
|
/// ParticleEmitterRenderer can call GetEmbeddedResource without modification.
|
|
///
|
|
/// Mapping rule: "Shaders.Foo.vert" → Rendering/Shaders/wb_foo.vert
|
|
/// (lower-case, wb_ prefix to distinguish WB-origin shaders from acdream's own)
|
|
/// </summary>
|
|
public static class EmbeddedResourceReader {
|
|
public static string GetEmbeddedResource(string filename) {
|
|
// Convert "Shaders.Particle.vert" → "wb_particle.vert"
|
|
// Strip leading "Shaders." then lowercase and prefix with wb_
|
|
string leafName;
|
|
const string shadersPrefix = "Shaders.";
|
|
if (filename.StartsWith(shadersPrefix, StringComparison.Ordinal))
|
|
{
|
|
var rest = filename.Substring(shadersPrefix.Length); // e.g. "Particle.vert"
|
|
leafName = "wb_" + rest.ToLowerInvariant(); // e.g. "wb_particle.vert"
|
|
}
|
|
else
|
|
{
|
|
leafName = "wb_" + filename.ToLowerInvariant();
|
|
}
|
|
|
|
var shadersDir = Path.Combine(AppContext.BaseDirectory, "Rendering", "Shaders");
|
|
var fullPath = Path.Combine(shadersDir, leafName);
|
|
|
|
if (!File.Exists(fullPath))
|
|
throw new InvalidOperationException(
|
|
$"WB shader not found: '{fullPath}' (mapped from resource '{filename}'). " +
|
|
$"Ensure {leafName} is in src/AcDream.App/Rendering/Shaders/ with CopyToOutputDirectory.");
|
|
|
|
return File.ReadAllText(fullPath);
|
|
}
|
|
}
|
|
}
|