From 229fdc9be51f816aa63907ccedf71d65b51d675e Mon Sep 17 00:00:00 2001 From: Ben Doherty Date: Wed, 30 Sep 2020 13:20:39 -0600 Subject: [PATCH] Add View::setShadowType JNI binding (#3094) --- .../filament-android/src/main/cpp/View.cpp | 6 ++++ .../com/google/android/filament/View.java | 29 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/android/filament-android/src/main/cpp/View.cpp b/android/filament-android/src/main/cpp/View.cpp index ebcb094541..a2ed9d2f6d 100644 --- a/android/filament-android/src/main/cpp/View.cpp +++ b/android/filament-android/src/main/cpp/View.cpp @@ -130,6 +130,12 @@ Java_com_google_android_filament_View_nSetDynamicResolutionOptions(JNIEnv*, jcla view->setDynamicResolutionOptions(options); } +extern "C" JNIEXPORT void JNICALL +Java_com_google_android_filament_View_nSetShadowType(JNIEnv*, jclass, jlong nativeView, jint type) { + View* view = (View*) nativeView; + view->setShadowType((View::ShadowType) type); +} + extern "C" JNIEXPORT void JNICALL Java_com_google_android_filament_View_nSetRenderQuality(JNIEnv*, jclass, diff --git a/android/filament-android/src/main/java/com/google/android/filament/View.java b/android/filament-android/src/main/java/com/google/android/filament/View.java index 82a42af400..3c3a83ef4e 100644 --- a/android/filament-android/src/main/java/com/google/android/filament/View.java +++ b/android/filament-android/src/main/java/com/google/android/filament/View.java @@ -565,6 +565,23 @@ public class View { TEMPORAL } + /** + * List of available shadow mapping techniques. + * + * @see #setShadowType + */ + public enum ShadowType { + /** + * Percentage-closer filtered shadows (default). + */ + PCF, + + /** + * Variance shadows. + */ + VSM + } + /** * Used to select buffers. */ @@ -1146,6 +1163,17 @@ public class View { nSetDynamicLightingOptions(getNativeObject(), zLightNear, zLightFar); } + /** + * Sets the shadow mapping technique this View uses. + * + * The ShadowType affects all the shadows seen within the View. + * + * Warning: This API is still experimental and subject to change. + */ + public void setShadowType(ShadowType type) { + nSetShadowType(getNativeObject(), type.ordinal()); + } + /** * Activates or deactivates ambient occlusion. * @see #setAmbientOcclusionOptions @@ -1337,6 +1365,7 @@ public class View { private static native void nSetDynamicResolutionOptions(long nativeView, boolean enabled, boolean homogeneousScaling, float minScale, float maxScale, int quality); private static native void nSetRenderQuality(long nativeView, int hdrColorBufferQuality); private static native void nSetDynamicLightingOptions(long nativeView, float zLightNear, float zLightFar); + private static native void nSetShadowType(long nativeView, int type); private static native void nSetColorGrading(long nativeView, long nativeColorGrading); private static native void nSetPostProcessingEnabled(long nativeView, boolean enabled); private static native boolean nIsPostProcessingEnabled(long nativeView);