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

Fix still water #42

Merged
merged 1 commit into from
Oct 29, 2023
Merged
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
27 changes: 26 additions & 1 deletion src/main/java/de/lemaik/chunky/denoiser/ChunkyCompatHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private static Method getMethod(Class<?> className, String methodName, Class<?>.
try {
return className.getDeclaredMethod(methodName, parameterTypes);
} catch (NoSuchMethodException e) {
throw new RuntimeException("Could not invoke " + methodName + " on class " + className.getName(), e);
throw new RuntimeException("Could not get method " + methodName + " of class " + className.getName(), e);
}
}

Expand Down Expand Up @@ -64,4 +64,29 @@ public static void doWaterDisplacement(Ray ray) {
}
}
}

public static class Scene {
private static Method stillWaterEnabled;

private static Class<?> stillWaterShader;

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

public static boolean isStillWaterEnabled(se.llbit.chunky.renderer.scene.Scene scene) {
if (stillWaterEnabled != null) {
try {
return (boolean) stillWaterEnabled.invoke(scene);
} catch (InvocationTargetException | IllegalAccessException e) {
throw new RuntimeException("Could not invoke stillWaterEnabled()", e);
}
}
return stillWaterShader.isInstance(scene.getCurrentWaterShader());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private static class NormalTracer implements RayTracer {
public void trace(Scene scene, WorkerState state) {
Ray ray = state.ray;
if (PreviewRayTracer.nextIntersection(scene, ray)) {
if (BetterRenderManager.NORMAL_WATER_DISPLACEMENT && !scene.stillWaterEnabled()
if (BetterRenderManager.NORMAL_WATER_DISPLACEMENT && !ChunkyCompatHelper.Scene.isStillWaterEnabled(scene)
&& ray.getCurrentMaterial().isWater()) {
ChunkyCompatHelper.Water.doWaterDisplacement(ray);
}
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": "DenoiserPlugin",
"author": "leMaik",
"main": "de.lemaik.chunky.denoiser.DenoiserPlugin",
"version": "0.4.1",
"version": "0.4.2",
"targetVersion": "2.4.0",
"description": "Renders normal and albedo maps to pfm files for use with denoisers."
}