Skip to content

Commit 4d4db51

Browse files
leMaikMadDog443
andauthored
Update the plugin for Chunky 2.4.0 (#24)
* Add support for Chunky 2.4.0, save denoised images in the snapshot directory. * Enabled Headless Mode (Untested) All I did was stop the check for headless from returning, it still warns the user that it may not work. * Make the plugin compatible with Chunky 2.4.0 * Update info on Chunky 1.x vs 2.x * Revert "Enabled Headless Mode (Untested)" This reverts commit 06bf34b. * Fix incomplete sentence * Cleanup imports Co-authored-by: MadDog443 <[email protected]>
1 parent 03d96e1 commit 4d4db51

File tree

14 files changed

+337
-437
lines changed

14 files changed

+337
-437
lines changed

README.md

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Denoising Plugin
22

3-
This is a plugin for [Chunky][chunky] that creates _Portable Float Map_ files (.pfm) for use with denoisers, e.g. [Intel Open Image Denoise][openimagedenoise]. The plugin was compiled for and tested with Chunky 1.4.5 as well as Chunky 2.0-beta6.
3+
This is a plugin for [Chunky][chunky] that creates _Portable Float Map_ files (.pfm) for use with denoisers, e.g. [Intel Open Image Denoise][openimagedenoise].
44

5-
Please use `chunky-denoiser-chunky1.jar` for Chunky 1.x and `chunky-denoiser-chunky2.jar` for Chunky 2.x (i.e. all Chunky versions for Minecraft 1.13 or later).
5+
Please use [version 0.3.2](https://github.com/chunky-dev/chunky-denoiser/releases/tag/v0.3.2) for Chunky 1.x and the [latest version](https://github.com/chunky-dev/chunky-denoiser/releases/latest) for Chunky 2.4.0 or later.
66

77
## Installation
88

@@ -16,7 +16,7 @@ Just render a scene as usual. It will render three images and save them as _Port
1616

1717
### Denoise automatically
1818

19-
The Intel Open Image Denoiser can be downloaded [here][openimagedenoise-dl]. After unpacking the archive, you can configure the denoiser executable (`denoiser.exe` on Windows, `denoiser` on Linux) in the _Denoiser_ tab inside Chunky.
19+
The Intel Open Image Denoiser can be downloaded [here][openimagedenoise-dl]. After unpacking the archive, you can configure the denoiser executable (`denoiser.exe` on Windows, `denoiser` on Linux) in the _Denoiser_ tab inside Chunky. If you do this, it will output the denoised image alongside the original image in the scene's snapshots directory.
2020

2121
### Invoke the denoiser manually
2222

@@ -28,16 +28,9 @@ After the rendering is done, the plugin will save the resulting image as `scene-
2828

2929
To view the resulting image, it needs to be converted back to an actual image file. This can be done by the `pfm2png.py` Python 3 script included in this repository or using an online converter, e.g. [this one][convertio].
3030

31-
## Building the plugin
32-
33-
The plugin can be built for Chunky 1.4.5 and Chunky 2.x by specifying the `chunky` parameter when invoking gradle.
34-
35-
- Chunky 1.4.5: `./gradlew pluginJar -Pchunky=1`
36-
- Chunky 2.x: `./gradlew pluginJar -Pchunky=2`
37-
3831
## License
3932

40-
Copyright 2019-2020 Maik Marschner (leMaik)
33+
Copyright 2019-2021 Maik Marschner (leMaik)
4134

4235
Permission to modify and redistribute is granted under the terms of the GNU General Public License, Version 3. See the `LICENSE` file for the full license.
4336

src/chunky-1/java/de/lemaik/chunky/denoiser/AlbedoTracer.java

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/chunky-1/java/de/lemaik/chunky/denoiser/DenoiserTabImpl.java

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/chunky-2/java/de/lemaik/chunky/denoiser/AlbedoTracer.java

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/chunky-2/resources/plugin.json

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package de.lemaik.chunky.denoiser;
2+
3+
import se.llbit.chunky.block.Air;
4+
import se.llbit.chunky.block.Water;
5+
import se.llbit.chunky.renderer.PathTracingRenderer;
6+
import se.llbit.chunky.renderer.WorkerState;
7+
import se.llbit.chunky.renderer.scene.PreviewRayTracer;
8+
import se.llbit.chunky.renderer.scene.RayTracer;
9+
import se.llbit.chunky.renderer.scene.Scene;
10+
import se.llbit.math.Ray;
11+
12+
public class AlbedoRenderer extends PathTracingRenderer {
13+
14+
public static final String ID = "ALBEDO";
15+
16+
public AlbedoRenderer() {
17+
super(ID, "Albedo map", "Renderer for albedo maps (used for denoising)",
18+
new AlbedoTracer());
19+
}
20+
21+
private static class AlbedoTracer implements RayTracer {
22+
23+
@Override
24+
public void trace(Scene scene, WorkerState state) {
25+
Ray ray = state.ray;
26+
if (scene.isInWater(ray)) {
27+
ray.setCurrentMaterial(Water.INSTANCE, 0);
28+
} else {
29+
ray.setCurrentMaterial(Air.INSTANCE, 0);
30+
}
31+
32+
while (true) {
33+
if (!PreviewRayTracer.nextIntersection(scene, ray)) {
34+
if (ray.getPrevMaterial().isWater()) {
35+
// set water color to white
36+
ray.color.set(1, 1, 1, 1);
37+
} else if (ray.depth == 0) {
38+
// direct sky hit
39+
if (!scene.transparentSky()) {
40+
scene.sky().getSkyColorInterpolated(ray);
41+
}
42+
}
43+
// ignore indirect sky hits
44+
break;
45+
}
46+
47+
if (ray.getCurrentMaterial() != Air.INSTANCE && ray.color.w > 0.0D) {
48+
break;
49+
}
50+
51+
ray.o.scaleAdd(1.0E-4D, ray.d);
52+
}
53+
}
54+
}
55+
}

0 commit comments

Comments
 (0)