Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# User specific editor and IDE configurations
.vs
launchSettings.json
!SeeSharp.Templates/content/SeeSharp.Blazor.Template/Properties/launchSettings.json
.idea
SeeSharp.sln.DotSettings.user

Expand Down
3 changes: 1 addition & 2 deletions MaterialTest/Pages/IntegratorTest.razor.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Components;
using SeeSharp.Blazor;

namespace MaterialTest.Pages;

Expand All @@ -22,7 +21,7 @@ void RunExperiment()
scene.Prepare();
VertexConnectionAndMerging vcm = new()
{
NumIterations = NumSamples,
NumIterations = (uint)NumSamples,
MaxDepth = MaxDepth,
RenderTechniquePyramid = true
};
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ using SeeSharp.Integrators.Bidir;
// Configure an experiment that compares VCM and path tracing.
class PathVsVcm : Experiment {
public override List<Method> MakeMethods() => new() {
new("PathTracer", new PathTracer() { MaxDepth = 5, TotalSpp = 4 }),
new("PathTracer", new PathTracer() { MaxDepth = 5, NumIterations = 4 }),
new("Vcm", new VertexConnectionAndMerging() { MaxDepth = 5, NumIterations = 2 })
};
}
Expand Down
2 changes: 1 addition & 1 deletion SeeSharp.Benchmark/GenericMaterial_Sampling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static float TestRender(GenericMaterial.Parameters parameters, string name) {
scene.Prepare();

PathTracer integrator = new() {
TotalSpp = 1,
NumIterations = 1,
NumShadowRays = 0,
MaxDepth = 2,
};
Expand Down
4 changes: 2 additions & 2 deletions SeeSharp.Benchmark/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
SceneRegistry.AddSourceRelativeToScript("../data/scenes");

BenchRender("PathTracer - 16spp", new PathTracer() {
TotalSpp = 16,
NumIterations = 16,
});

BenchRender("BDPT - 8spp", new VertexCacheBidir() {
Expand Down Expand Up @@ -51,4 +51,4 @@ void BenchRender(string name, Integrator integrator) {

GenericMaterial_Sampling.Benchmark();

VectorBench.BenchComputeBasisVectors(10000000);
VectorBench.BenchComputeBasisVectors(10000000);
25 changes: 25 additions & 0 deletions SeeSharp.Blazor/LongSetting.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@using Microsoft.AspNetCore.Mvc

@namespace SeeSharp.Blazor

@inherits SettingBase<long>

@{
base.BuildRenderTree(__builder);
}

@code {
protected override string Type => "number";

protected override long ParseValue(ChangeEventArgs e)
{
if (long.TryParse((string)e.Value, out long result))
return result;
return Value;
}

protected override Dictionary<string, object> CustomAttributes => new() {
{ "step", 1 }
};
}

2 changes: 1 addition & 1 deletion SeeSharp.Blazor/SceneSelector.razor
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
}
else if (!string.IsNullOrEmpty(scene?.Name))
{
<p>Loaded "@(scene.Name)"</p>
<p>Loaded "@(scene.Name)" from "@scene.SourceDirectory"</p>
}

</div>
Expand Down
4 changes: 2 additions & 2 deletions SeeSharp.Examples/MisCompensation.dib
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ scene.FrameBuffer = new(512, 512, "");
scene.Prepare();

new PathTracer() {
TotalSpp = 10
NumIterations = 10
}.Render(scene);
var plain = scene.FrameBuffer.Image;

Expand All @@ -36,7 +36,7 @@ scene.FrameBuffer = new(512, 512, "");
scene.Prepare();

new PathTracer() {
TotalSpp = 10
NumIterations = 10
}.Render(scene);

HTML(FlipBook.Make(("plain", plain), ("comp", scene.FrameBuffer.Image)))
7 changes: 1 addition & 6 deletions SeeSharp.Examples/PathVsVcm.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
using SeeSharp.Experiments;
using SeeSharp.Integrators;
using SeeSharp.Integrators.Bidir;
using System.Collections.Generic;

namespace SeeSharp.Examples;

/// <summary>
/// Renders a scene with a path tracer and with VCM.
/// </summary>
class PathVsVcm : Experiment {
public override List<Method> MakeMethods() => [
new("PathTracer", new PathTracer() { TotalSpp = 4 }),
new("PathTracer", new PathTracer() { NumIterations = 4 }),
new("Vcm", new VertexConnectionAndMerging() { NumIterations = 2 })
];
}
6 changes: 2 additions & 4 deletions SeeSharp.Examples/SphericalSampling.dib
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,16 @@ scene.Prepare();
#!csharp

abstract class DirectIllum : Integrator {
public int TotalSpp = 20;

protected Scene scene;

public DirectIllum(int spp) {
TotalSpp = spp;
SampleCount = spp;
}

public override void Render(Scene scene) {
this.scene = scene;

for (uint sampleIndex = 0; sampleIndex < TotalSpp; ++sampleIndex) {
for (uint sampleIndex = 0; sampleIndex < SampleCount; ++sampleIndex) {
scene.FrameBuffer.StartIteration();
Parallel.For(0, scene.FrameBuffer.Height, row => {
for (uint col = 0; col < scene.FrameBuffer.Width; ++col) {
Expand Down
2 changes: 1 addition & 1 deletion SeeSharp.IntegrationTests/LightProbeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ public static void CornellProbe() {
scene.FrameBuffer.WriteToFile();
}
}
}
}
2 changes: 1 addition & 1 deletion SeeSharp.IntegrationTests/OutlierCacheTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static void RenderPT() {
scene.Prepare();

var integrator = new PathTracer() {
TotalSpp = 4,
NumIterations = 4,
MaxDepth = 10,
BaseSeed = 1234,
};
Expand Down
4 changes: 2 additions & 2 deletions SeeSharp.IntegrationTests/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static void PathTracerTimeBudget() {
scene.Prepare();

var integrator = new PathTracer() {
TotalSpp = 498989,
NumIterations = 498989,
MaximumRenderTimeMs = 4500,
MaxDepth = 5
};
Expand Down Expand Up @@ -43,4 +43,4 @@ static void Main(string[] args) {
// OutlierCacheTest.RenderPT();
OutlierCacheTest.RenderVCM();
}
}
}
6 changes: 3 additions & 3 deletions SeeSharp.PreviewRender/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ static int Main(
if (algo == "PT") {
new PathTracer() {
MaxDepth = maxdepth,
TotalSpp = samples,
NumIterations = (uint)samples,
}.Render(sc);
} else if (algo == "VCM") {
new VertexConnectionAndMerging() {
MaxDepth = maxdepth,
NumIterations = samples,
NumIterations = (uint)samples,
}.Render(sc);
} else {
Logger.Error($"Unknown rendering algorithm: {algo}. Use PT or VCM");
Expand All @@ -67,4 +67,4 @@ static int Main(

return 0;
}
}
}
12 changes: 12 additions & 0 deletions SeeSharp.ReferenceManager/App.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
32 changes: 32 additions & 0 deletions SeeSharp.ReferenceManager/Imports.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
global using System;
global using System.Collections.Concurrent;
global using System.Collections.Generic;
global using System.Diagnostics;
global using System.IO;
global using System.Linq;
global using System.Numerics;
global using System.Text.Json;
global using System.Text.Json.Serialization;
global using System.Threading;
global using System.Threading.Tasks;

global using TinyEmbree;
global using SimpleImageIO;

global using SeeSharp;
global using SeeSharp.Cameras;
global using SeeSharp.Common;
global using SeeSharp.Experiments;
global using SeeSharp.Geometry;
global using SeeSharp.Images;
global using SeeSharp.Integrators;
global using SeeSharp.Integrators.Bidir;
global using SeeSharp.Integrators.Common;
global using SeeSharp.Integrators.Util;
global using SeeSharp.Sampling;
global using SeeSharp.Shading;
global using SeeSharp.Shading.Background;
global using SeeSharp.Shading.Emitters;
global using SeeSharp.Shading.Materials;

global using SeeSharp.Blazor;
3 changes: 3 additions & 0 deletions SeeSharp.ReferenceManager/MainLayout.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@inherits LayoutComponentBase

<main> @Body </main>
52 changes: 52 additions & 0 deletions SeeSharp.ReferenceManager/Pages/IntegratorSelector.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
@using SeeSharp.Experiments
@using SeeSharp
@using SeeSharp.Blazor
@using SeeSharp.Integrators
@using System.Reflection
@using System.Collections.Generic
@using System.ComponentModel

<div class="integrator-selector">
<div style="display: flex; align-items: center; gap: 10px;">
<label style="margin: 0; white-space: nowrap;">Integrator:</label>
<select value="@selectedIntegrator" @onchange="OnSelectionChanged" style="flex-grow: 1;">
@foreach (var type in integratorTypes)
{
<option value="@type.FullName" selected="@(type.FullName == selectedIntegrator)">@FormatClassName(type)</option>
}
</select>
</div>
</div>

<div class="integrator-container">
@if (CurrentIntegrator != null)
{
var groups = GetParameterGroups(CurrentIntegrator);

@foreach (var group in groups)
{
<details open>
<summary>
@group.Title
</summary>

<div>
@foreach (var prop in group.Properties)
{
<RenderSetting
Member="@prop"
Getter="() => prop.GetValue(CurrentIntegrator)"
Setter="v => { prop.SetValue(CurrentIntegrator, v); StateHasChanged(); }" />
}
@foreach (var field in group.Fields)
{
<RenderSetting
Member="@field"
Getter="() => field.GetValue(CurrentIntegrator)"
Setter="v => { field.SetValue(CurrentIntegrator, v); StateHasChanged(); }" />
}
</div>
</details>
}
}
</div>
88 changes: 88 additions & 0 deletions SeeSharp.ReferenceManager/Pages/IntegratorSelector.razor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using Microsoft.AspNetCore.Components;

namespace SeeSharp.ReferenceManager.Pages;

public partial class IntegratorSelector : ComponentBase
{
[Parameter] public Scene scene { get; set; } = default!;

public List<Integrator> addedIntegrators { get; private set; } = new();

public Integrator CurrentIntegrator => addedIntegrators.FirstOrDefault();

Type[] integratorTypes = Array.Empty<Type>();
string selectedIntegrator;
private string lastIntegrator;

protected override void OnInitialized()
{
var types = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(assembly => assembly.GetTypes())
.Where(type => type.IsClass && !type.IsAbstract && typeof(Integrator).IsAssignableFrom(type) &&
!type.ContainsGenericParameters && !typeof(DebugVisualizer).IsAssignableFrom(type));
integratorTypes = types.Where(t => !types.Any(other => other.IsSubclassOf(t))).ToArray();

if (integratorTypes.Length > 0) {
selectedIntegrator = integratorTypes[0].FullName;
lastIntegrator = selectedIntegrator;
ReplaceIntegrator();
}
DocumentationReader.LoadXmlDocumentation(typeof(Integrator).Assembly);
}

void OnSelectionChanged(ChangeEventArgs e)
{
selectedIntegrator = e.Value?.ToString();
if (!string.IsNullOrEmpty(selectedIntegrator))
{
lastIntegrator = selectedIntegrator;
ReplaceIntegrator();
}
}

void ReplaceIntegrator()
{
if (string.IsNullOrEmpty(selectedIntegrator)) return;
var type = integratorTypes.FirstOrDefault(t => t.FullName == selectedIntegrator);
if (type == null) return;

addedIntegrators.Clear();

var integrator = (Integrator)Activator.CreateInstance(type)!;
addedIntegrators.Add(integrator);

StateHasChanged();
}

protected List<ParameterGroup> GetParameterGroups(Integrator integrator)
=> IntegratorUtils.GetParameterGroups(integrator);

protected string FormatClassName(Type t) => IntegratorUtils.FormatClassName(t);

public void TriggerReset()
{
selectedIntegrator = lastIntegrator;
ReplaceIntegrator();
}

public bool TrySelectIntegrator(string simpleName)
{
var targetType = integratorTypes.FirstOrDefault(t => t.Name == simpleName || t.Name == simpleName + "`1");

if (targetType != null && targetType.FullName != selectedIntegrator)
{
selectedIntegrator = targetType.FullName;
ReplaceIntegrator();
return true;
}
return targetType != null;
}

public Type GetIntegratorType(string simpleName)
{
if (string.IsNullOrEmpty(simpleName)) return null;
return integratorTypes.FirstOrDefault(t =>
t.Name.Equals(simpleName, StringComparison.OrdinalIgnoreCase) ||
t.Name.Equals(simpleName + "`1", StringComparison.OrdinalIgnoreCase));
}
}
Loading