Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sky depth infinite #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}

Expand All @@ -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;
}
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/dev/thatredox/chunkyaov/ui/ChunkyAovTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) -> {
Expand All @@ -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));

Expand All @@ -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
Expand All @@ -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
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 @@ -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."
}