Interactive 2D wave optics simulator. Turn any image into a refractive scene, add sources, watch waves refract, diffract and interfere. Probes, intensity maps, video export.
C#
A picture export takes an 8-bit run as it is
Alexander Graef668c94b31b76
diff --git a/CLAUDE.md b/CLAUDE.mdindex 13cb3dd..766c4dc 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -99,7 +99,8 @@ FrameStore: native memory up to the budget, the rest in a temp file (%LOCALAPPDA- **Reduced preview** (View menu): resolution 1/2/4, frames 1/2/4 (the timeline never changes), samples 16-bit or**8-bit palette index, the default**: the same pixels at the captured brightness, half the store, half thecolouring; 16-bit keeps the brightness turnable after a run. In 8-bit a brightness edit is a simulation edit.- Exports always use a full run.+ A picture export takes an 8-bit run as it is (the same pixels; 2026-10-18); an EXR data export, a reduced resolution or+ skipped frames make the export run the simulation again at full quality first.## The app's rulesdiff --git a/WaveDudeNext.WPF/MainWindow.Export.cs b/WaveDudeNext.WPF/MainWindow.Export.csindex bab1624..774faa5 100644--- a/WaveDudeNext.WPF/MainWindow.Export.cs+++ b/WaveDudeNext.WPF/MainWindow.Export.cs@@ -19,6 +19,7 @@ using System.IO;using System.Windows;using System.Windows.Input;using Microsoft.Win32;+using WaveDudeNext.Engine;using WaveDudeNext.Export;using WaveDudeNext.Model;using WaveDudeNext.Rendering;@@ -190,7 +191,7 @@ public partial class MainWindow}}}- SimulationRun? run = await EnsureRunForExport(intensity);+ SimulationRun? run = await EnsureRunForExport(intensity, format);if (run == null){return;@@ -285,7 +286,7 @@ public partial class MainWindow/// holds the intensity plane if asked for; otherwise a run is started and awaited. Null when no run could/// be had (logged, and an error shown when the run could not start)./// </summary>- private async Task<SimulationRun?> EnsureRunForExport(bool intensity)+ private async Task<SimulationRun?> EnsureRunForExport(bool intensity, ExportFormat format){IsExportWaiting = true;try@@ -293,8 +294,12 @@ public partial class MainWindowfor (int attempt = 0; attempt < 3; attempt++){SimulationRun? run = Run;+ // a reduced preview serves a picture export when only its samples are reduced: the 8-bit index gives the+ // same pixels (2026-10-18); a smaller picture or skipped frames never do, and a data export needs the halves+ PreviewQuality? quality = run?.Spec.Quality;+ bool reduced = quality != null && (quality.ResolutionDivisor != 1 || quality.FrameDivisor != 1 || (quality.Format != FrameFormat.Half && ExportFormats.IsData(format)));string? reason = run == null ? "no run" : IsRunStale ? "the run is stale" : IsProbesStale ? "the probes were edited since the run"- : !run.Spec.Quality.IsFull ? "the run is a reduced preview (View menu)"+ : reduced ? (quality!.Format != FrameFormat.Half && ExportFormats.IsData(format) && quality.ResolutionDivisor == 1 && quality.FrameDivisor == 1 ? "a data export needs the 16-bit samples" : "the run is a reduced preview (View menu)"): intensity && !run.Store.Has(FrameLayer.Intensity) ? "the run has no intensity plane" : !run.IsActive && run.State != RunState.Completed ? "the run did not complete" : null;if (reason != null){diff --git a/_tools/library_check/Program.cs b/_tools/library_check/Program.csindex a995485..9ba7a26 100644--- a/_tools/library_check/Program.cs+++ b/_tools/library_check/Program.cs@@ -970,16 +970,22 @@ internal static class Programrefused = true;}Check(refused, "index store: the Half read is refused");- refused = false;- try- {- _ = new ExportJob(store, 0, 0, [], null);- }- catch (ArgumentException)- {- refused = true;- }- Check(refused, "an export refuses a store of palette indices");+ // a picture export takes the index store as it is (2026-10-18): the job colours the indices through the LUT, the+ // same pixels the renderer makes of them; a data export (OpenEXR) needs the halves and fails on it+ int[] indexLut = ColorLut.Build(ColorSchemeStore.LoadBuiltIn(null).First(s => s.Name == Display.DefaultFieldColorScheme)).Argb;+ var collected = new CollectingSink(32, 24);+ var indexJob = new ExportJob(store, 0, 2, [new ExportTarget(new ExportLayer(FrameLayer.Field, indexLut, 1f, null, 0, null), "memory", () => collected)], null);+ indexJob.Start();+ var fromIndices = new int[32 * 24];+ FrameRenderer.RenderIndexed(expectedField, 32, 24, indexLut, fromIndices);+ Check(indexJob.Completion.Wait(30000) && indexJob.State == ExportState.Completed && collected.Frames.Count == 3 && collected.Frames.All(f => f.SequenceEqual(fromIndices)),+ "an export of pictures takes a store of palette indices and colours them as the renderer does");+ string exrOnIndex = Path.Combine(Path.GetTempPath(), "library_check-exr-" + Guid.NewGuid().ToString("N") + ".exr");+ var dataJob = new ExportJob(store, 0, 0, [new ExportTarget(new ExportLayer(FrameLayer.Field, null, 1f, null, 0, null), exrOnIndex, () => ExportFormats.OpenStill(ExportFormat.Exr, exrOnIndex, 32, 24, 70))], null);+ dataJob.Start();+ Check(dataJob.Completion.Wait(30000) && dataJob.State == ExportState.Failed && dataJob.Error?.Message.Contains("16-bit") == true,+ "a data export (OpenEXR) of a store of palette indices fails: it needs the 16-bit samples");+ File.Delete(exrOnIndex);refused = false;try{@@ -1060,6 +1066,19 @@ internal static class Program}}+ /// <summary>A sink that keeps every frame's pixels in memory, for checks on what a job renders.</summary>+ private sealed class CollectingSink(int width, int height) : IFrameSink+ {+ public List<int[]> Frames { get; } = [];+ public int Width => width;+ public int Height => height;+ public int FrameCount => Frames.Count;+ public string Output => "memory";+ public void Add(ReadOnlySpan<int> pixels) => Frames.Add(pixels[..(width * height)].ToArray());+ public void Close() { }+ public void Dispose() { }+ }+private static void CheckRenderer(){Console.WriteLine("--- renderer");