Skip to content

Commit

Permalink
Update for Chunky 2.5.0 snapshots.
Browse files Browse the repository at this point in the history
  • Loading branch information
leMaik committed Sep 25, 2023
1 parent 18a6c58 commit fa30d60
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 23 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Denoising Plugin
z# Denoising Plugin

**Note: This README is for an development version of the plugin that is not yet released. Click [here](https://github.com/chunky-dev/chunky-denoiser/blob/4d4db51a4a81f77c24cc1def717686c9df67a95d/README.md) for the README for the current version of the plugin, which is 0.4.0.**
**Note: This README is for an development version of the plugin that is not yet released (for Chunky 2.5). Click [here](https://github.com/chunky-dev/chunky-denoiser/blob/4d4db51a4a81f77c24cc1def717686c9df67a95d/README.md) for the README for the current stable version of the plugin, which is 0.4.0 (for Chunky 2.4).**

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].

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ configurations {
}

dependencies {
provided 'se.llbit:chunky-core:2.4.0'
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'
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/lemaik/chunky/denoiser/AlbedoTracer.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.WorkerState;
import se.llbit.chunky.renderer.scene.PreviewRayTracer;
import se.llbit.chunky.renderer.scene.RayTracer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
import se.llbit.log.Log;
import se.llbit.util.TaskTracker;

import java.io.*;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteOrder;
import java.nio.file.Files;

public class DenoisedPathTracingRenderer extends MultiPassRenderer {
protected final DenoiserSettings settings;
Expand Down Expand Up @@ -64,8 +68,8 @@ public void render(DefaultRenderManager manager) throws InterruptedException {
int maxSpp = Math.max(sceneTarget, Math.max(settings.albedoSpp.get(), settings.normalSpp.get()));
scene.setTargetSpp(maxSpp);

RayTracer[] tracers = new RayTracer[] {albedoTracer, normalTracer, tracer};
float[][] buffers = new float[][] {
RayTracer[] tracers = new RayTracer[]{albedoTracer, normalTracer, tracer};
float[][] buffers = new float[][]{
settings.renderAlbedo.get() ? new float[sampleBuffer.length] : null,
settings.renderNormal.get() ? new float[sampleBuffer.length] : null,
null};
Expand All @@ -86,13 +90,12 @@ public void render(DefaultRenderManager manager) throws InterruptedException {

if (!aborted && settings.saveBeauty.get()) {
File out = manager.context.getSceneFile(scene.name + ".beauty.pfm");
scene.saveFrame(out, PortableFloatMap.getPfmExportFormat(),
TaskTracker.NONE, manager.context.numRenderThreads());
scene.saveFrame(out, PortableFloatMap.getPfmExportFormat(), TaskTracker.NONE);
}

if (!aborted && settings.saveAlbedo.get()) {
File out = manager.context.getSceneFile(scene.name + ".albedo.pfm");
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(out))) {
try (OutputStream os = new BufferedOutputStream(Files.newOutputStream(out.toPath()))) {
PortableFloatMap.writeImage(buffers[0], scene.width, scene.height, ByteOrder.LITTLE_ENDIAN, os);
} catch (IOException e) {
Log.error("Failed to save albedo pass", e);
Expand All @@ -101,7 +104,7 @@ public void render(DefaultRenderManager manager) throws InterruptedException {

if (!aborted && settings.saveNormal.get()) {
File out = manager.context.getSceneFile(scene.name + ".normal.pfm");
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(out))) {
try (OutputStream os = new BufferedOutputStream(Files.newOutputStream(out.toPath()))) {
PortableFloatMap.writeImage(buffers[1], scene.width, scene.height, ByteOrder.LITTLE_ENDIAN, os);
} catch (IOException e) {
Log.error("Failed to save normal pass", e);
Expand Down
17 changes: 10 additions & 7 deletions src/main/java/de/lemaik/chunky/denoiser/DenoiserPassRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
import se.llbit.log.Log;
import se.llbit.util.TaskTracker;

import java.io.*;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteOrder;
import java.nio.file.Files;

public class DenoiserPassRenderer extends MultiPassRenderer {
protected final DenoiserSettings settings;
Expand Down Expand Up @@ -61,8 +65,8 @@ public void render(DefaultRenderManager manager) throws InterruptedException {

scene.setTargetSpp(Math.max(settings.albedoSpp.get(), settings.normalSpp.get()));

RayTracer[] tracers = new RayTracer[] {albedoTracer, normalTracer};
float[][] buffers = new float[][] {
RayTracer[] tracers = new RayTracer[]{albedoTracer, normalTracer};
float[][] buffers = new float[][]{
settings.renderAlbedo.get() ? new float[sampleBuffer.length] : null,
settings.renderNormal.get() ? new float[sampleBuffer.length] : null,
};
Expand All @@ -81,13 +85,12 @@ public void render(DefaultRenderManager manager) throws InterruptedException {

if (!aborted && settings.saveBeauty.get()) {
File out = manager.context.getSceneFile(scene.name + ".beauty.pfm");
scene.saveFrame(out, PortableFloatMap.getPfmExportFormat(),
TaskTracker.NONE, manager.context.numRenderThreads());
scene.saveFrame(out, PortableFloatMap.getPfmExportFormat(), TaskTracker.NONE);
}

if (!aborted && settings.saveAlbedo.get()) {
File out = manager.context.getSceneFile(scene.name + ".albedo.pfm");
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(out))) {
try (OutputStream os = new BufferedOutputStream(Files.newOutputStream(out.toPath()))) {
PortableFloatMap.writeImage(buffers[0], scene.width, scene.height, ByteOrder.LITTLE_ENDIAN, os);
} catch (IOException e) {
Log.error("Failed to save albedo pass", e);
Expand All @@ -96,7 +99,7 @@ public void render(DefaultRenderManager manager) throws InterruptedException {

if (!aborted && settings.saveNormal.get()) {
File out = manager.context.getSceneFile(scene.name + ".normal.pfm");
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(out))) {
try (OutputStream os = new BufferedOutputStream(Files.newOutputStream(out.toPath()))) {
PortableFloatMap.writeImage(buffers[1], scene.width, scene.height, ByteOrder.LITTLE_ENDIAN, os);
} catch (IOException e) {
Log.error("Failed to save normal pass", e);
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 {
protected final DenoiserSettings settings;
protected Scene scene;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/lemaik/chunky/denoiser/NormalTracer.java
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.WorkerState;
import se.llbit.chunky.renderer.scene.PreviewRayTracer;
import se.llbit.chunky.renderer.scene.RayTracer;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"author": "leMaik",
"main": "de.lemaik.chunky.denoiser.DenoiserPlugin",
"version": "0.5.0",
"targetVersion": "2.4.0",
"targetVersion": "2.5.0",
"description": "Renders normal and albedo maps to pfm files for use with denoisers."
}

0 comments on commit fa30d60

Please sign in to comment.