diff --git a/.github/workflows/plugin_build.yml b/.github/workflows/plugin_build.yml new file mode 100644 index 0000000..9e553ad --- /dev/null +++ b/.github/workflows/plugin_build.yml @@ -0,0 +1,34 @@ +name: Plugin Build + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Setup JDK 17 + uses: actions/setup-java@v2 + with: + distribution: 'temurin' + java-version: '17' + java-package: jdk + + - name: Grant executable permission for gradlew + run: chmod +x gradlew + + - name: Build with Gradle + run: ./gradlew pluginJar + + - name: Upload the plugin Jar + uses: actions/upload-artifact@v3 + with: + name: ChunkyDenoiser + path: build/libs/*.jar + if-no-files-found: error diff --git a/README.md b/README.md index df9c70c..d40593b 100644 --- a/README.md +++ b/README.md @@ -8,27 +8,50 @@ Please use [version 0.3.2](https://github.com/chunky-dev/chunky-denoiser/release Download the latest plugin release for your Chunky version from the [releases page](https://github.com/leMaik/chunky-denoiser/releases). In the Chunky Launcher, click on _Manage plugins_ and then on _Add_ and select the `.jar` file you just downloaded. Click on `Save` to store the updated configuration, then start Chunky as usual. -**Compatibility note:** If you are using the [Discord plugin](https://github.com/leMaik/chunky-discord), make sure that it is loaded _after_ the Denoising plugin, i.e. use the _Down_ button to move it below it in the plugin list. Otherwise the denoiser plugin will not work. +Download the Intel Open Image Denoiser [here][openimagedenoise-dl]. After unpacking the archive in a safe location, you can configure the denoiser executable (`denoiser.exe` on Windows, `denoiser` on Linux) in the `Denoiser` tab inside Chunky. ## Usage -Just render a scene as usual. It will render three images and save them as _Portable Float Maps_. +Select the `DenoisedPathTracer` in the `Advanced` tab: -### Denoise automatically +![image](https://user-images.githubusercontent.com/42661490/147403029-54d291c2-8142-4a36-b6ea-4485156f9484.png) -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. +Then render the scene as usual. It will automatically render all passes and denoise the final image. -### Invoke the denoiser manually +### Denoising an Existing Render -After the rendering is done, the plugin will save the resulting image as `scene-name.pfm` in the scene directory and start to render a normal image (saved as `scene-name.normal.pfm`) and an Albedo image (`scene-name.albedo.pfm`). These files can be used by [Intel Open Image Denoise][openimagedenoise-dl] like this: +Existing renders can be denoised by clicking on the `Denoise Current Render` button in the `Denoiser` tab: + +![image](https://user-images.githubusercontent.com/42661490/147403139-67f3661c-1575-407f-af05-1d8780f68c73.png) + +**WARNING: this will overwrite your existing render.** + +It will automatically render all passes and denoise the final image. + +### Denoising Outside Chunky + +By checking `Save albedo map` and `Save normal map`, the denoised renderers will automatically save the albedo and normal maps as `.pfm` files inside the scene directory. + +![image](https://user-images.githubusercontent.com/42661490/147403108-78aa1b33-5549-46de-8194-3f33d2e799a0.png) + +These files can be used by [Intel Open Image Denoise][openimagedenoise-dl] like this: ``` ./denoise -ldr scene-name.pfm -alb scene-name.albedo.pfm -nrm scene-name.normal.pfm -o output.pfm ``` -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]. +# Development + +It is recommended to use [IntelliJ](https://www.jetbrains.com/idea/). Install the Java17 JDK ([Temurin](https://adoptium.net/) is the recommended distribution). +Then, [clone](https://www.jetbrains.com/help/idea/set-up-a-git-repository.html#clone-repo) the Chunky repository and let IntelliJ index the project. +Navigate to `src/main/java/de/lemaik/chunky/denoiser/DenoiserPlugin` and click the green play button next to `public class DenoiserPlugin implements Plugin {` to build and run the denoiser plugin. + +To build the plugin externally, run the `gradlew` script in the project root directory. Gradle is setup with a few main tasks: + +* `gradlew pluginJar` - Build the denoiser plugin Jar +* `gradlew clean` - Cleans the project. Removes old builds. -## License +# License Copyright 2019-2021 Maik Marschner (leMaik) diff --git a/build.gradle b/build.gradle index 2cce7b8..11f183e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,45 +1,47 @@ -apply plugin: 'java' +plugins { + id 'org.openjfx.javafxplugin' version '0.0.10' +} jar.enabled = false -compileJava { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 +sourceCompatibility = '1.8' +targetCompatibility = '1.8' + +configurations { + implementation.extendsFrom(provided) + implementation.extendsFrom(bundled) } -sourceSets { - main { - if (project.properties.get("chunky") == "1") { - java.srcDir 'src/main/java' - java.srcDir 'src/chunky-1/java' - resources.srcDir 'src/main/resources' - resources.srcDir 'src/chunky-1/resources' - } else { - java.srcDir 'src/main/java' - java.srcDir 'src/chunky-2/java' - resources.srcDir 'src/main/resources' - resources.srcDir 'src/chunky-2/resources' - } - } +dependencies { + provided 'se.llbit:chunky-core:2.5.0-SNAPSHOT' + provided 'org.apache.commons:commons-math3:3.2' + provided 'it.unimi.dsi:fastutil:8.4.4' + provided 'se.llbit:jo-json:1.3.1' } task pluginJar(type: Jar) { - classifier = 'chunky' + project.properties.get("chunky") with jar } -dependencies { - if (project.properties.get("chunky") == "1") { - compile 'se.llbit:chunky-core:1.4.5' - } else { - compile 'se.llbit:chunky-core:2.0-beta6' +jar { + manifest { + attributes "Main-Class": "de.lemaik.chunky.denoiser.DenoiserPlugin" } - runtimeClasspath 'org.apache.commons:commons-math3:3.2' + + from { + configurations.bundled.collect { it.isDirectory() ? it : zipTree(it) } + } +} + +javafx { + version = '17' + modules = ['javafx.base', 'javafx.controls', 'javafx.fxml'] + configuration = 'provided' } repositories { mavenLocal() mavenCentral() maven { - url 'https://oss.sonatype.org/content/repositories/snapshots/' + url 'https://repo.lemaik.de/' } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 290541c..ffed3a2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/de/lemaik/chunky/denoiser/AlbedoRenderer.java b/src/main/java/de/lemaik/chunky/denoiser/AlbedoRenderer.java index 6e3214a..b40bb1c 100644 --- a/src/main/java/de/lemaik/chunky/denoiser/AlbedoRenderer.java +++ b/src/main/java/de/lemaik/chunky/denoiser/AlbedoRenderer.java @@ -1,7 +1,7 @@ package de.lemaik.chunky.denoiser; -import se.llbit.chunky.block.Air; -import se.llbit.chunky.block.Water; +import se.llbit.chunky.block.minecraft.Air; +import se.llbit.chunky.block.minecraft.Water; import se.llbit.chunky.renderer.PathTracingRenderer; import se.llbit.chunky.renderer.WorkerState; import se.llbit.chunky.renderer.scene.PreviewRayTracer; diff --git a/src/main/java/de/lemaik/chunky/denoiser/DenoiserTabImpl.java b/src/main/java/de/lemaik/chunky/denoiser/DenoiserTabImpl.java index 2a206aa..6aa8f12 100644 --- a/src/main/java/de/lemaik/chunky/denoiser/DenoiserTabImpl.java +++ b/src/main/java/de/lemaik/chunky/denoiser/DenoiserTabImpl.java @@ -1,12 +1,13 @@ package de.lemaik.chunky.denoiser; -import java.io.IOException; import javafx.fxml.FXMLLoader; import javafx.scene.Node; import se.llbit.chunky.renderer.scene.Scene; -import se.llbit.chunky.ui.RenderControlsFxController; +import se.llbit.chunky.ui.controller.RenderControlsFxController; import se.llbit.chunky.ui.render.RenderControlsTab; +import java.io.IOException; + public class DenoiserTabImpl implements RenderControlsTab { @Override public void update(Scene scene) { diff --git a/src/main/java/de/lemaik/chunky/denoiser/NormalRenderer.java b/src/main/java/de/lemaik/chunky/denoiser/NormalRenderer.java index 4da6509..5adc0ea 100644 --- a/src/main/java/de/lemaik/chunky/denoiser/NormalRenderer.java +++ b/src/main/java/de/lemaik/chunky/denoiser/NormalRenderer.java @@ -1,6 +1,6 @@ package de.lemaik.chunky.denoiser; -import se.llbit.chunky.model.WaterModel; +import se.llbit.chunky.model.minecraft.WaterModel; import se.llbit.chunky.renderer.PathTracingRenderer; import se.llbit.chunky.renderer.WorkerState; import se.llbit.chunky.renderer.scene.PreviewRayTracer; diff --git a/src/main/resources/plugin.json b/src/main/resources/plugin.json index 3de9297..1f6eee8 100644 --- a/src/main/resources/plugin.json +++ b/src/main/resources/plugin.json @@ -2,7 +2,7 @@ "name": "DenoiserPlugin", "author": "leMaik", "main": "de.lemaik.chunky.denoiser.DenoiserPlugin", - "version": "0.4.0", - "targetVersion": "2.4.0", + "version": "0.4.1", + "targetVersion": "2.5.0", "description": "Renders normal and albedo maps to pfm files for use with denoisers." }