Skip to content

Commit

Permalink
Add support for Chunky 2.4.0, save denoised images in the snapshot di…
Browse files Browse the repository at this point in the history
…rectory.
  • Loading branch information
leMaik committed May 23, 2021
1 parent 03d96e1 commit 9df765e
Show file tree
Hide file tree
Showing 12 changed files with 330 additions and 407 deletions.
42 changes: 0 additions & 42 deletions src/chunky-1/java/de/lemaik/chunky/denoiser/AlbedoTracer.java

This file was deleted.

29 changes: 0 additions & 29 deletions src/chunky-1/java/de/lemaik/chunky/denoiser/DenoiserTabImpl.java

This file was deleted.

8 changes: 0 additions & 8 deletions src/chunky-1/resources/plugin.json

This file was deleted.

43 changes: 0 additions & 43 deletions src/chunky-2/java/de/lemaik/chunky/denoiser/AlbedoTracer.java

This file was deleted.

55 changes: 55 additions & 0 deletions src/main/java/de/lemaik/chunky/denoiser/AlbedoRenderer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package de.lemaik.chunky.denoiser;

import se.llbit.chunky.block.Air;
import se.llbit.chunky.block.Water;
import se.llbit.chunky.renderer.PathTracingRenderer;
import se.llbit.chunky.renderer.WorkerState;
import se.llbit.chunky.renderer.scene.PreviewRayTracer;
import se.llbit.chunky.renderer.scene.RayTracer;
import se.llbit.chunky.renderer.scene.Scene;
import se.llbit.math.Ray;

public class AlbedoRenderer extends PathTracingRenderer {

public static final String ID = "ALBEDO";

public AlbedoRenderer() {
super(ID, "Albedo map", "Renderer for albedo maps (used for denoising)",
new AlbedoTracer());
}

private static class AlbedoTracer implements RayTracer {

@Override
public void trace(Scene scene, WorkerState state) {
Ray ray = state.ray;
if (scene.isInWater(ray)) {
ray.setCurrentMaterial(Water.INSTANCE, 0);
} else {
ray.setCurrentMaterial(Air.INSTANCE, 0);
}

while (true) {
if (!PreviewRayTracer.nextIntersection(scene, ray)) {
if (ray.getPrevMaterial().isWater()) {
// set water color to white
ray.color.set(1, 1, 1, 1);
} else if (ray.depth == 0) {
// direct sky hit
if (!scene.transparentSky()) {
scene.sky().getSkyColorInterpolated(ray);
}
}
// ignore indirect sky hits
break;
}

if (ray.getCurrentMaterial() != Air.INSTANCE && ray.color.w > 0.0D) {
break;
}

ray.o.scaleAdd(1.0E-4D, ray.d);
}
}
}
}
Loading

0 comments on commit 9df765e

Please sign in to comment.