diff --git a/src/main/java/de/lemaik/chunky/denoiser/AlbedoRenderer.java b/src/main/java/de/lemaik/chunky/denoiser/AlbedoRenderer.java index 056b9e1..920290a 100644 --- a/src/main/java/de/lemaik/chunky/denoiser/AlbedoRenderer.java +++ b/src/main/java/de/lemaik/chunky/denoiser/AlbedoRenderer.java @@ -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 { @@ -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 diff --git a/src/main/java/de/lemaik/chunky/denoiser/ChunkyCompatHelper.java b/src/main/java/de/lemaik/chunky/denoiser/ChunkyCompatHelper.java index 7acd608..56c135d 100644 --- a/src/main/java/de/lemaik/chunky/denoiser/ChunkyCompatHelper.java +++ b/src/main/java/de/lemaik/chunky/denoiser/ChunkyCompatHelper.java @@ -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) { @@ -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); + } + } } } diff --git a/src/main/resources/plugin.json b/src/main/resources/plugin.json index aabbb8a..0c54bc7 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.2", + "version": "0.4.3", "targetVersion": "2.4.0", "description": "Renders normal and albedo maps to pfm files for use with denoisers." }