Skip to content

Commit

Permalink
Update plugin for the latest snapshot (#40)
Browse files Browse the repository at this point in the history
* Changes from 3580f75

* Update build to Java17. Add GH actions build script. (#31)

* Update gradle build to Java 17

* Add gh actions build. Fix line endings.

* Update plugin for latest snapshot

---------

Co-authored-by: Alex <[email protected]>
  • Loading branch information
Peregrine05 and ThatRedox authored Oct 3, 2023
1 parent 4d4db51 commit 6c461ff
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 42 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/plugin_build.yml
Original file line number Diff line number Diff line change
@@ -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
39 changes: 31 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
54 changes: 28 additions & 26 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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/'
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions src/main/java/de/lemaik/chunky/denoiser/AlbedoRenderer.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/de/lemaik/chunky/denoiser/DenoiserTabImpl.java
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}

0 comments on commit 6c461ff

Please sign in to comment.