3D-Arena (Duell, Hub, Freiheit, Erstellung, Bestenliste), Retiarius beidhändig, Waffen je Klasse, Einführung, Willkommen, weniger Reiter, Wirtschaft ohne Taberna, Kantenglättung, Leuchten, weiche Schatten, Gamepad, Absturz-Protokoll
Stand von main 20cd8ba2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -101,6 +101,43 @@ namespace GladiatorIdle.Gfx
|
||||
return result;
|
||||
}
|
||||
|
||||
// ── Mipmaps: verkleinerte Stufen für Texturen, die schräg oder weit weg zu sehen sind
|
||||
// (Sand, Mauer, Publikum, Figuren) – sonst flimmern sie in der Tiefe ──
|
||||
static readonly Dictionary<Texture2D, Texture2D> _mipped = new();
|
||||
|
||||
/// Dieselbe Textur mit allen Mipmap-Stufen (einmal je Quelle).
|
||||
public static Texture2D Mipmapped(Texture2D src)
|
||||
{
|
||||
if (src.LevelCount > 1) return src;
|
||||
if (_mipped.TryGetValue(src, out var t)) return t;
|
||||
var data = new Color[src.Width * src.Height];
|
||||
src.GetData(data);
|
||||
return _mipped[src] = MipTexture(data, src.Width, src.Height);
|
||||
}
|
||||
|
||||
/// Textur aus Pixeln mit Mipmap-Stufen (2×2-Mittel je Stufe).
|
||||
public static Texture2D MipTexture(Color[] data, int w, int h)
|
||||
{
|
||||
var t = new Texture2D(_gd, w, h, true, SurfaceFormat.Color);
|
||||
t.SetData(0, null, data, 0, data.Length);
|
||||
var cur = data; int cw = w, ch = h;
|
||||
for (int level = 1; level < t.LevelCount; level++)
|
||||
{
|
||||
int nw = Math.Max(1, cw / 2), nh = Math.Max(1, ch / 2);
|
||||
var next = new Color[nw * nh];
|
||||
for (int y = 0; y < nh; y++)
|
||||
for (int x = 0; x < nw; x++)
|
||||
{
|
||||
int x0 = Math.Min(cw - 1, x * 2), x1 = Math.Min(cw - 1, x * 2 + 1), y0 = Math.Min(ch - 1, y * 2), y1 = Math.Min(ch - 1, y * 2 + 1);
|
||||
var a = cur[y0 * cw + x0]; var b = cur[y0 * cw + x1]; var c = cur[y1 * cw + x0]; var d = cur[y1 * cw + x1];
|
||||
next[y * nw + x] = new Color((a.R + b.R + c.R + d.R + 2) / 4, (a.G + b.G + c.G + d.G + 2) / 4, (a.B + b.B + c.B + d.B + 2) / 4, (a.A + b.A + c.A + d.A + 2) / 4);
|
||||
}
|
||||
t.SetData(level, null, next, 0, next.Length);
|
||||
cur = next; cw = nw; ch = nh;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
/// Bild eines Video-Sprites: Farbe vor Schwarz (JPEG, also schon vormultipliziert)
|
||||
/// plus Deckkraft (Graustufen-PNG) — zusammengesetzt zu einer Textur.
|
||||
public static Texture2D? LoadFrame(string relBase)
|
||||
@@ -160,8 +197,8 @@ namespace GladiatorIdle.Gfx
|
||||
var data = new Color[src.Width * src.Height];
|
||||
src.GetData(data);
|
||||
PaintPixels(data, colorIndex);
|
||||
t = new Texture2D(_gd, src.Width, src.Height);
|
||||
t.SetData(data);
|
||||
if (src.LevelCount > 1) t = MipTexture(data, src.Width, src.Height); // Figuren: Stufen behalten
|
||||
else { t = new Texture2D(_gd, src.Width, src.Height); t.SetData(data); }
|
||||
_painted[(src, colorIndex)] = t;
|
||||
return t;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user