Skip to content

Commit

Permalink
Fix compatibility with recent snapshots due to Sky being moved to sky…
Browse files Browse the repository at this point in the history
… package.

Fixes #43
  • Loading branch information
leMaik committed Feb 9, 2024
1 parent 23d7c54 commit 9363994
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/main/java/de/lemaik/chunky/denoiser/AlbedoRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import se.llbit.chunky.renderer.scene.PreviewRayTracer;
import se.llbit.chunky.renderer.scene.RayTracer;
import se.llbit.chunky.renderer.scene.Scene;
import se.llbit.chunky.world.Material;
import se.llbit.math.Ray;

public class AlbedoRenderer extends PathTracingRenderer {
Expand Down Expand Up @@ -36,7 +35,7 @@ public void trace(Scene scene, WorkerState state) {
} else if (ray.depth == 0) {
// direct sky hit
if (!scene.transparentSky()) {
scene.sky().getSkyColorInterpolated(ray);
ChunkyCompatHelper.Scene.getSkyColorInterpolated(scene, ray);
}
}
// ignore indirect sky hits
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/de/lemaik/chunky/denoiser/ChunkyCompatHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,22 @@ public static class Scene {

private static Class<?> stillWaterShader;

private static Method getSky;

private static Class<?> sky;

private static Method getSkyColorInterpolated;

static {
try {
stillWaterEnabled = se.llbit.chunky.renderer.scene.Scene.class.getDeclaredMethod("stillWaterEnabled");
} catch (NoSuchMethodException e) {
stillWaterShader = ChunkyCompatHelper.getClass("se.llbit.chunky.renderer.scene.StillWaterShader");
}

getSky = ChunkyCompatHelper.getMethod(se.llbit.chunky.renderer.scene.Scene.class, "sky");
sky = ChunkyCompatHelper.getClass("se.llbit.chunky.renderer.scene.Sky", "se.llbit.chunky.renderer.scene.sky.Sky");
getSkyColorInterpolated = ChunkyCompatHelper.getMethod(sky, "getSkyColorInterpolated", Ray.class);
}

public static boolean isStillWaterEnabled(se.llbit.chunky.renderer.scene.Scene scene) {
Expand All @@ -88,5 +98,13 @@ public static boolean isStillWaterEnabled(se.llbit.chunky.renderer.scene.Scene s
}
return stillWaterShader.isInstance(scene.getCurrentWaterShader());
}

public static void getSkyColorInterpolated(se.llbit.chunky.renderer.scene.Scene scene, Ray ray) {
try {
getSkyColorInterpolated.invoke(getSky.invoke(scene), ray);
} catch (InvocationTargetException | IllegalAccessException e2) {
throw new RuntimeException("Could not invoke sky().getSkyColorInterpolated(ray)", e2);
}
}
}
}
2 changes: 1 addition & 1 deletion 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.2",
"version": "0.4.3",
"targetVersion": "2.4.0",
"description": "Renders normal and albedo maps to pfm files for use with denoisers."
}

0 comments on commit 9363994

Please sign in to comment.