diff --git a/src/main/java/dev/thatredox/chunkyaov/raytracer/DepthTracer.java b/src/main/java/dev/thatredox/chunkyaov/raytracer/DepthTracer.java index e380040..022d166 100644 --- a/src/main/java/dev/thatredox/chunkyaov/raytracer/DepthTracer.java +++ b/src/main/java/dev/thatredox/chunkyaov/raytracer/DepthTracer.java @@ -29,6 +29,7 @@ public class DepthTracer implements RayTracer { public static double NORMALIZATION_FACTOR = 100.0; + public static boolean INFINITE_SKY_DISTANCE = true; private DepthTracer() {} @@ -50,7 +51,8 @@ public static void register() { @Override public void trace(Scene scene, WorkerState state) { Ray ray = state.ray; - double distance = 0.0; + double distance = INFINITE_SKY_DISTANCE ? Double.MAX_VALUE : 0.0; + if (PreviewRayTracer.nextIntersection(scene, ray)) { distance = ray.distance; } diff --git a/src/main/java/dev/thatredox/chunkyaov/ui/ChunkyAovTab.java b/src/main/java/dev/thatredox/chunkyaov/ui/ChunkyAovTab.java index 949fc7b..219d288 100644 --- a/src/main/java/dev/thatredox/chunkyaov/ui/ChunkyAovTab.java +++ b/src/main/java/dev/thatredox/chunkyaov/ui/ChunkyAovTab.java @@ -28,6 +28,7 @@ import javafx.scene.control.Separator; import javafx.scene.control.Tooltip; import javafx.scene.layout.VBox; +import javafx.scene.text.Text; import se.llbit.chunky.renderer.scene.Scene; import se.llbit.chunky.ui.DoubleAdjuster; import se.llbit.chunky.ui.SliderAdjuster; @@ -40,6 +41,7 @@ public class ChunkyAovTab implements RenderControlsTab { private final SimpleBooleanProperty nmPositive = new SimpleBooleanProperty(NormalTracer.MAP_POSITIVE); private final SimpleBooleanProperty nmWaterDisplacement = new SimpleBooleanProperty(NormalTracer.WATER_DISPLACEMENT); private final SimpleDoubleProperty depthNormFactor = new SimpleDoubleProperty(DepthTracer.NORMALIZATION_FACTOR); + private final SimpleBooleanProperty infiniteSkyDepth = new SimpleBooleanProperty(DepthTracer.INFINITE_SKY_DISTANCE); public ChunkyAovTab() { nmPositive.addListener((observable, oldValue, newValue) -> { @@ -64,6 +66,13 @@ public ChunkyAovTab() { scene.refresh(); } }); + infiniteSkyDepth.addListener((observable, oldValue, newValue) -> { + DepthTracer.INFINITE_SKY_DISTANCE = newValue; + if (scene != null) { + scene.setAdditionalData("aov_infinite_sky_depth", Json.of(newValue)); + scene.refresh(); + } + }); box.setPadding(new Insets(10.0, 10.0, 10.0, 10.0)); @@ -86,6 +95,16 @@ public ChunkyAovTab() { depthNormAdjuster.setRange(1.0, 1000.0); depthNormAdjuster.clampMin(); box.getChildren().add(depthNormAdjuster); + + CheckBox enableInfiniteSkyDepth = new CheckBox("Infinite Sky Depth"); + enableInfiniteSkyDepth.selectedProperty().bindBidirectional(infiniteSkyDepth); + box.getChildren().add(enableInfiniteSkyDepth); + + box.getChildren().add(new Separator()); + + Text text = new Text("For accurate results, set the Postprocessing filter in the Postprocessing tab to None."); + text.setWrappingWidth(350); + box.getChildren().add(text); } @Override @@ -94,6 +113,7 @@ public void update(Scene scene) { nmPositive.set(scene.getAdditionalData("aov_normal_positive").boolValue(nmPositive.get())); nmWaterDisplacement.set(scene.getAdditionalData("aov_normal_water_displacement").boolValue(nmWaterDisplacement.get())); depthNormFactor.set(scene.getAdditionalData("aov_depth_normalization").doubleValue(depthNormFactor.get())); + infiniteSkyDepth.set(scene.getAdditionalData("aov_infinite_sky_depth").boolValue(infiniteSkyDepth.get())); } @Override diff --git a/src/main/resources/plugin.json b/src/main/resources/plugin.json index 9242851..e848558 100644 --- a/src/main/resources/plugin.json +++ b/src/main/resources/plugin.json @@ -2,7 +2,7 @@ "name": "Chunky AOV", "author": "Redox", "main": "dev.thatredox.chunkyaov.ChunkyAOV", - "version": "0.0.1", + "version": "0.0.2", "targetVersion": "2.4.2", "description": "Arbitrary output variable renderers for Chunky." } \ No newline at end of file