-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathExperiment.razor.cs
More file actions
54 lines (45 loc) · 1.73 KB
/
Experiment.razor.cs
File metadata and controls
54 lines (45 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using Microsoft.AspNetCore.Components;
namespace ExperimentConfigTest.Pages;
public partial class Experiment : ComponentBase
{
const int Width = 1280;
const int Height = 720;
SurfacePoint? selected;
void OnFlipClick(FlipViewer.OnEventArgs args)
{
if (args.Control)
{
RNG rng = new(1241512);
var ray = scene.Camera.GenerateRay(new Vector2(args.MouseX + 0.5f, args.MouseY + 0.5f), ref rng).Ray;
selected = (SurfacePoint)scene.Raytracer.Trace(ray);
SurfaceShader shader = new(selected.Value, -ray.Direction, false);
var s = shader.Sample(rng.NextFloat(), rng.NextFloat2D());
Console.WriteLine(s);
}
}
async Task OnDownloadClick()
{
HtmlReport report = new();
report.AddMarkdown("""
# Example experiment
$$ L_\mathrm{o} = \int_\Omega L_\mathrm{i} f_\mathrm{r} |\cos\theta_\mathrm{i}| \, d\omega_\mathrm{i} $$
""");
report.AddFlipBook(flip);
await SeeSharp.Blazor.Scripts.DownloadAsFile(JS, "report.html", report.ToString());
}
void RunSingleIntegrator(Integrator integrator, string? name = null)
{
if (flip == null) {
flip = new FlipBook(660, 580)
.SetZoom(FlipBook.InitialZoom.FillWidth)
.SetToneMapper(FlipBook.InitialTMO.Exposure(scene.RecommendedExposure))
.SetToolVisibility(false);
}
scene.FrameBuffer = new(Width, Height, "");
scene.Prepare();
integrator.Render(scene);
string displayName = name ?? IntegratorUtils.FormatClassName(integrator.GetType());
flip.Remove(displayName);
flip.Add(displayName, scene.FrameBuffer.Image);
}
}