update java and js bindings (#9676)

* implement some missing javascript bindings

DOCS_FORCE

* use exclusively javadoc comments in Options.h

This is because this file is currently used to generate java and
javascript bindings and doxygen can ingest javadoc.

And regenerate javascript and java bindings

* add missing java bindings
This commit is contained in:
Mathias Agopian
2026-02-03 13:16:01 -08:00
committed by GitHub
parent bd67c9c67e
commit ef42c55f56
15 changed files with 1021 additions and 909 deletions

View File

@@ -18,6 +18,7 @@
#include <filament/Camera.h>
#include <utils/Entity.h>
#include <math/mat4.h>
@@ -40,6 +41,13 @@ Java_com_google_android_filament_Camera_nSetProjectionFov(JNIEnv*, jclass ,
camera->setProjection(fovInDegrees, aspect, near, far, (Camera::Fov) fov);
}
extern "C" JNIEXPORT jdouble JNICALL
Java_com_google_android_filament_Camera_nGetFieldOfViewInDegrees(JNIEnv*, jclass,
jlong nativeCamera, jint direction) {
Camera *camera = (Camera *) nativeCamera;
return camera->getFieldOfViewInDegrees((Camera::Fov) direction);
}
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_Camera_nSetLensProjection(JNIEnv*, jclass,
jlong nativeCamera, jdouble focalLength, jdouble aspect, jdouble near, jdouble far) {
@@ -62,6 +70,21 @@ Java_com_google_android_filament_Camera_nSetCustomProjection(JNIEnv *env, jclass
env->ReleaseDoubleArrayElements(inProjectionForCulling_, inProjectionForCulling, JNI_ABORT);
}
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_Camera_nSetCustomEyeProjection(JNIEnv *env, jclass,
jlong nativeCamera, jdoubleArray inProjection_, jint count, jdoubleArray inProjectionForCulling_,
jdouble near, jdouble far) {
Camera *camera = (Camera *) nativeCamera;
jdouble *inProjection = env->GetDoubleArrayElements(inProjection_, NULL);
jdouble *inProjectionForCulling = env->GetDoubleArrayElements(inProjectionForCulling_, NULL);
camera->setCustomEyeProjection(
reinterpret_cast<const filament::math::mat4 *>(inProjection), (size_t) count,
*reinterpret_cast<const filament::math::mat4 *>(inProjectionForCulling),
near, far);
env->ReleaseDoubleArrayElements(inProjection_, inProjection, JNI_ABORT);
env->ReleaseDoubleArrayElements(inProjectionForCulling_, inProjectionForCulling, JNI_ABORT);
}
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_Camera_nSetScaling(JNIEnv* env, jclass,
jlong nativeCamera, jdouble x, jdouble y) {
@@ -76,6 +99,17 @@ Java_com_google_android_filament_Camera_nSetShift(JNIEnv* env, jclass,
camera->setShift({(double)x, (double)y});
}
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_Camera_nGetShift(JNIEnv* env, jclass,
jlong nativeCamera, jdoubleArray out_) {
Camera *camera = (Camera *) nativeCamera;
jdouble *out = env->GetDoubleArrayElements(out_, NULL);
filament::math::double2 s = camera->getShift();
out[0] = s.x;
out[1] = s.y;
env->ReleaseDoubleArrayElements(out_, out, 0);
}
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_Camera_nLookAt(JNIEnv*, jclass, jlong nativeCamera,
jdouble eye_x, jdouble eye_y, jdouble eye_z, jdouble center_x, jdouble center_y,
@@ -115,6 +149,15 @@ Java_com_google_android_filament_Camera_nSetModelMatrixFp64(JNIEnv *env, jclass,
env->ReleaseDoubleArrayElements(in_, in, JNI_ABORT);
}
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_Camera_nSetEyeModelMatrix(JNIEnv *env, jclass,
jlong nativeCamera, jint eyeId, jdoubleArray model_) {
Camera* camera = (Camera *) nativeCamera;
jdouble *model = env->GetDoubleArrayElements(model_, NULL);
camera->setEyeModelMatrix((uint8_t)eyeId, *reinterpret_cast<const filament::math::mat4*>(model));
env->ReleaseDoubleArrayElements(model_, model, JNI_ABORT);
}
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_Camera_nGetProjectionMatrix(JNIEnv *env, jclass,
jlong nativeCamera, jdoubleArray out_) {
@@ -280,3 +323,5 @@ Java_com_google_android_filament_Camera_nComputeEffectiveFov(JNIEnv*, jclass,
jdouble fovInDegrees, jdouble focusDistance) {
return Camera::computeEffectiveFov(fovInDegrees, focusDistance);
}

View File

@@ -96,6 +96,14 @@ Java_com_google_android_filament_Material_nGetBlendingMode(JNIEnv*, jclass,
return (jint) material->getBlendingMode();
}
extern "C"
JNIEXPORT jint JNICALL
Java_com_google_android_filament_Material_nGetTransparencyMode(JNIEnv*, jclass,
jlong nativeMaterial) {
Material* material = (Material*) nativeMaterial;
return (jint) material->getTransparencyMode();
}
extern "C"
JNIEXPORT jint JNICALL

View File

@@ -564,3 +564,19 @@ Java_com_google_android_filament_MaterialInstance_nGetDepthFunc(JNIEnv* env, jcl
MaterialInstance* instance = (MaterialInstance*)nativeMaterialInstance;
return (jint)instance->getDepthFunc();
}
extern "C"
JNIEXPORT void JNICALL
Java_com_google_android_filament_MaterialInstance_nSetTransparencyMode(JNIEnv*, jclass,
jlong nativeMaterialInstance, jint mode) {
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
instance->setTransparencyMode((MaterialInstance::TransparencyMode) mode);
}
extern "C"
JNIEXPORT jint JNICALL
Java_com_google_android_filament_MaterialInstance_nGetTransparencyMode(JNIEnv*, jclass,
jlong nativeMaterialInstance) {
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
return (jint) instance->getTransparencyMode();
}

View File

@@ -173,6 +173,13 @@ Java_com_google_android_filament_Texture_nBuilderSwizzle(JNIEnv *, jclass ,
(Texture::Swizzle)r, (Texture::Swizzle)g, (Texture::Swizzle)b, (Texture::Swizzle)a);
}
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_Texture_nBuilderSamples(JNIEnv*, jclass,
jlong nativeBuilder, jint samples) {
Texture::Builder *builder = (Texture::Builder *) nativeBuilder;
builder->samples((uint8_t) samples);
}
extern "C"
JNIEXPORT void JNICALL
Java_com_google_android_filament_Texture_nBuilderImportTexture(JNIEnv*, jclass, jlong nativeBuilder, jlong id) {

View File

@@ -76,6 +76,12 @@ Java_com_google_android_filament_View_nSetVisibleLayers(JNIEnv*, jclass, jlong n
view->setVisibleLayers((uint8_t) select, (uint8_t) value);
}
extern "C" JNIEXPORT jint JNICALL
Java_com_google_android_filament_View_nGetVisibleLayers(JNIEnv*, jclass, jlong nativeView) {
View* view = (View*) nativeView;
return view->getVisibleLayers();
}
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_View_nSetShadowingEnabled(JNIEnv*, jclass, jlong nativeView, jboolean enabled) {
View* view = (View*) nativeView;
@@ -440,6 +446,18 @@ Java_com_google_android_filament_View_nIsShadowingEnabled(JNIEnv *, jclass, jlon
return (jboolean)view->isShadowingEnabled();
}
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_View_nSetFrustumCullingEnabled(JNIEnv*, jclass, jlong nativeView, jboolean enabled) {
View* view = (View*) nativeView;
view->setFrustumCullingEnabled(enabled);
}
extern "C" JNIEXPORT jboolean JNICALL
Java_com_google_android_filament_View_nIsFrustumCullingEnabled(JNIEnv*, jclass, jlong nativeView) {
View* view = (View*) nativeView;
return (jboolean)view->isFrustumCullingEnabled();
}
extern "C"
JNIEXPORT void JNICALL
Java_com_google_android_filament_View_nSetScreenSpaceRefractionEnabled(JNIEnv *, jclass,

View File

@@ -136,4 +136,13 @@ final class Asserts {
throw new ArrayIndexOutOfBoundsException("Array length must be at least 4");
}
}
@NonNull @Size(min = 2)
static double[] assertDouble2(@Nullable double[] out) {
if (out == null) out = new double[2];
else if (out.length < 2) {
throw new ArrayIndexOutOfBoundsException("Array length must be at least 2");
}
return out;
}
}

View File

@@ -343,6 +343,27 @@ public class Camera {
nSetScaling(getNativeObject(), xscaling, yscaling);
}
/**
* Sets a custom projection matrix for each eye.
*
* @param inProjection An array of projection matrices, one for each eye.
* Must have at least 16 * count elements.
* @param count Number of eyes to set.
* @param inProjectionForCulling Custom projection matrix for culling, must encompass all eyes.
* @param near Distance to the near plane.
* @param far Distance to the far plane.
*/
public void setCustomEyeProjection(
@NonNull double[] inProjection, int count,
@NonNull @Size(min = 16) double[] inProjectionForCulling,
double near, double far) {
Asserts.assertMat4dIn(inProjectionForCulling);
if (inProjection.length < 16 * count) {
throw new IllegalArgumentException("inProjection array too small for the given count");
}
nSetCustomEyeProjection(getNativeObject(), inProjection, count, inProjectionForCulling, near, far);
}
/**
* Sets an additional matrix that scales the projection matrix.
*
@@ -399,6 +420,31 @@ public class Camera {
nSetShift(getNativeObject(), xshift, yshift);
}
/**
* Returns the shift amount used to translate the projection matrix.
*
* @param out A 2-double array where the shift will be stored, or null.
* @return A 2-double array containing the x and y shift.
*/
@NonNull @Size(min = 2)
public double[] getShift(@Nullable @Size(min = 2) double[] out) {
out = Asserts.assertDouble2(out);
nGetShift(getNativeObject(), out);
return out;
}
/**
* Returns the camera's field of view in degrees.
*
* @param direction The direction of the FOV (VERTICAL or HORIZONTAL).
* @return The field of view in degrees.
*/
public double getFieldOfViewInDegrees(@NonNull Fov direction) {
return nGetFieldOfViewInDegrees(getNativeObject(), direction.ordinal());
}
/**
* Sets the camera's model matrix.
* <p>
@@ -745,6 +791,17 @@ public class Camera {
return mEntity;
}
/**
* Sets the model matrix for a specific eye.
*
* @param eyeId The index of the eye.
* @param model The model matrix for the eye.
*/
public void setEyeModelMatrix(int eyeId, @NonNull @Size(min = 16) double[] model) {
Asserts.assertMat4dIn(model);
nSetEyeModelMatrix(getNativeObject(), eyeId, model);
}
/**
* Helper to compute the effective focal length taking into account the focus distance
*
@@ -784,8 +841,13 @@ public class Camera {
private static native void nSetCustomProjection(long nativeCamera, double[] inProjection, double[] inProjectionForCulling, double near, double far);
private static native void nSetScaling(long nativeCamera, double x, double y);
private static native void nSetShift(long nativeCamera, double x, double y);
private static native void nGetShift(long nativeCamera, double[] out);
private static native void nSetModelMatrix(long nativeCamera, float[] in);
private static native void nSetModelMatrixFp64(long nativeCamera, double[] in);
private static native void nSetEyeModelMatrix(long nativeCamera, int eyeId, double[] model);
private static native void nSetCustomEyeProjection(long nativeCamera, double[] inProjection, int count, double[] inProjectionForCulling, double near, double far);
private static native double nGetFieldOfViewInDegrees(long nativeCamera, int direction);
private static native void nLookAt(long nativeCamera, double eyeX, double eyeY, double eyeZ, double centerX, double centerY, double centerZ, double upX, double upY, double upZ);
private static native double nGetNear(long nativeCamera);
private static native double nGetCullingFar(long nativeCamera);

View File

@@ -54,6 +54,7 @@ public class Material {
static final CullingMode[] sCullingModeValues = CullingMode.values();
static final VertexBuffer.VertexAttribute[] sVertexAttributeValues =
VertexBuffer.VertexAttribute.values();
static final TransparencyMode[] sTransparencyModeValues = TransparencyMode.values();
}
private long mNativeObject;
@@ -160,6 +161,31 @@ public class Material {
SCREEN,
}
/**
* How transparent objects are handled
*
* @see
* <a href="https://google.github.io/filament/Materials.html#materialdefinitions/materialblock/blendingandtransparency:transparencymode">
* Blending and transparency: transparencyMode</a>
*/
public enum TransparencyMode {
/** The transparent object is drawn honoring the raster state. */
DEFAULT,
/**
* The transparent object is first drawn in the depth buffer,
* then in the color buffer, honoring the culling mode, but ignoring the depth test function.
*/
TWO_PASSES_ONE_SIDE,
/**
* The transparent object is drawn twice in the color buffer,
* first with back faces only, then with front faces; the culling
* mode is ignored. Can be combined with two-sided lighting.
*/
TWO_PASSES_TWO_SIDES
}
/**
* Supported refraction modes
*
@@ -587,6 +613,18 @@ public class Material {
return EnumCache.sBlendingModeValues[nGetBlendingMode(getNativeObject())];
}
/**
* Returns the transparency mode of this material.
* This value only makes sense when the blending mode is transparent or fade.
*
* @see
* <a href="https://google.github.io/filament/Materials.html#materialdefinitions/materialblock/blendingandtransparency:transparencymode">
* Blending and transparency: transparencyMode</a>
*/
public TransparencyMode getTransparencyMode() {
return EnumCache.sTransparencyModeValues[nGetTransparencyMode(getNativeObject())];
}
/**
* Returns the refraction mode of this material.
*
@@ -1130,6 +1168,7 @@ public class Material {
private static native int nGetShading(long nativeMaterial);
private static native int nGetInterpolation(long nativeMaterial);
private static native int nGetBlendingMode(long nativeMaterial);
private static native int nGetTransparencyMode(long nativeMaterial);
private static native int nGetVertexDomain(long nativeMaterial);
private static native int nGetCullingMode(long nativeMaterial);
private static native boolean nIsColorWriteEnabled(long nativeMaterial);

View File

@@ -537,6 +537,14 @@ public class MaterialInstance {
nSetDoubleSided(getNativeObject(), doubleSided);
}
/**
* Sets the transparency mode for this material instance.
* @see Material.TransparencyMode
*/
public void setTransparencyMode(@NonNull Material.TransparencyMode mode) {
nSetTransparencyMode(getNativeObject(), mode.ordinal());
}
/**
* Returns whether double-sided lighting is enabled when the parent Material has double-sided
* capability.
@@ -545,6 +553,14 @@ public class MaterialInstance {
return nIsDoubleSided(getNativeObject());
}
/**
* Returns the transparency mode.
*/
@NonNull
public Material.TransparencyMode getTransparencyMode() {
return Material.EnumCache.sTransparencyModeValues[nGetTransparencyMode(getNativeObject())];
}
/**
* Overrides the default triangle culling state that was set on the material.
*
@@ -982,4 +998,6 @@ public class MaterialInstance {
private static native boolean nIsStencilWriteEnabled(long nativeMaterialInstance);
private static native boolean nIsDepthCullingEnabled(long nativeMaterialInstance);
private static native int nGetDepthFunc(long nativeMaterialInstance);
private static native void nSetTransparencyMode(long nativeMaterialInstance, int mode);
private static native int nGetTransparencyMode(long nativeMaterialInstance);
}

View File

@@ -795,6 +795,17 @@ public class Texture {
return this;
}
/**
* Specifies the number of samples for multisample anti-aliasing.
* @param samples number of samples, must be at least 1. Default is 1.
* @return This Builder, for chaining calls.
*/
@NonNull
public Builder samples(@IntRange(from = 1) int samples) {
nBuilderSamples(mNativeBuilder, samples);
return this;
}
/**
* Specifies the texture's internal format.
* <p>The internal format specifies how texels are stored (which may be different from how
@@ -1370,6 +1381,7 @@ public class Texture {
private static native void nBuilderFormat(long nativeBuilder, int format);
private static native void nBuilderUsage(long nativeBuilder, int flags);
private static native void nBuilderSwizzle(long nativeBuilder, int r, int g, int b, int a);
private static native void nBuilderSamples(long nativeBuilder, int samples);
private static native void nBuilderImportTexture(long nativeBuilder, long id);
private static native void nBuilderExternal(long nativeBuilder);
private static native long nBuilderBuild(long nativeBuilder, long nativeEngine);

View File

@@ -350,6 +350,26 @@ public class View {
nSetVisibleLayers(getNativeObject(), select & 0xFF, values & 0xFF);
}
/**
* Returns the visible layers.
*
* @return a bitmask specifying which layer is visible.
*/
public int getVisibleLayers() {
return nGetVisibleLayers(getNativeObject());
}
/**
* Enables or disables a specific layer.
*
* @param layer Index of the layer to enable or disable, must be between 0 and 7.
* @param enabled True to enable the layer, false to disable it.
*/
public void setLayerEnabled(@IntRange(from = 0, to = 7) int layer, boolean enabled) {
int mask = 1 << layer;
setVisibleLayers(mask, enabled ? mask : 0);
}
/**
* Enables or disables shadow mapping. Enabled by default.
*
@@ -368,6 +388,22 @@ public class View {
return nIsShadowingEnabled(getNativeObject());
}
/**
* Enables or disables frustum culling. Enabled by default.
*
* @param enabled true enables frustum culling, false disables it.
*/
public void setFrustumCullingEnabled(boolean enabled) {
nSetFrustumCullingEnabled(getNativeObject(), enabled);
}
/**
* @return whether frustum culling is enabled
*/
public boolean isFrustumCullingEnabled() {
return nIsFrustumCullingEnabled(getNativeObject());
}
/**
* Enables or disables screen space refraction. Enabled by default.
*
@@ -1322,6 +1358,9 @@ public class View {
private static native boolean nHasCamera(long nativeView);
private static native void nSetViewport(long nativeView, int left, int bottom, int width, int height);
private static native void nSetVisibleLayers(long nativeView, int select, int value);
private static native int nGetVisibleLayers(long nativeView);
private static native void nSetFrustumCullingEnabled(long nativeView, boolean enabled);
private static native boolean nIsFrustumCullingEnabled(long nativeView);
private static native void nSetShadowingEnabled(long nativeView, boolean enabled);
private static native void nSetRenderTarget(long nativeView, long nativeRenderTarget);
private static native void nSetSampleCount(long nativeView, int count);
@@ -1406,65 +1445,59 @@ public class View {
* by lowering the resolution of a View, or to increase the quality when the
* rendering is faster than the target frame rate.
*
* This structure can be used to specify the minimum scale factor used when
* <p>This structure can be used to specify the minimum scale factor used when
* lowering the resolution of a View, and the maximum scale factor used when
* increasing the resolution for higher quality rendering. The scale factors
* can be controlled on each X and Y axis independently. By default, all scale
* factors are set to 1.0.
* factors are set to 1.0.</p>
*
* enabled: enable or disables dynamic resolution on a View
* <ul>
* <li>enabled: enable or disables dynamic resolution on a View</li>
*
* homogeneousScaling: by default the system scales the major axis first. Set this to true
* to force homogeneous scaling.
* <li>homogeneousScaling: by default the system scales the major axis first. Set this to true
* to force homogeneous scaling.</li>
*
* minScale: the minimum scale in X and Y this View should use
* <li>minScale: the minimum scale in X and Y this View should use</li>
*
* maxScale: the maximum scale in X and Y this View should use
* <li>maxScale: the maximum scale in X and Y this View should use</li>
*
* quality: upscaling quality.
* LOW: 1 bilinear tap, Medium: 4 bilinear taps, High: 9 bilinear taps (tent)
* <li>quality: upscaling quality.
* LOW: 1 bilinear tap, Medium: 4 bilinear taps, High: 9 bilinear taps (tent)</li>
* </ul>
*
* \note
* <p>Note:
* Dynamic resolution is only supported on platforms where the time to render
* a frame can be measured accurately. On platforms where this is not supported,
* Dynamic Resolution can't be enabled unless minScale == maxScale.
* Dynamic Resolution can't be enabled unless <code>minScale == maxScale</code>.</p>
*
* @see Renderer::FrameRateOptions
* @see Renderer.FrameRateOptions
*
*/
public static class DynamicResolutionOptions {
/**
* minimum scale factors in x and y
*/
/** minimum scale factors in x and y */
public float minScale = 0.5f;
/**
* maximum scale factors in x and y
*/
/** maximum scale factors in x and y */
public float maxScale = 1.0f;
/**
* sharpness when QualityLevel::MEDIUM or higher is used [0 (disabled), 1 (sharpest)]
*/
/** sharpness when QualityLevel::MEDIUM or higher is used [0 (disabled), 1 (sharpest)] */
public float sharpness = 0.9f;
/**
* enable or disable dynamic resolution
*/
/** enable or disable dynamic resolution */
public boolean enabled = false;
/**
* set to true to force homogeneous scaling
*/
/** set to true to force homogeneous scaling */
public boolean homogeneousScaling = false;
/**
* Upscaling quality
* LOW: bilinear filtered blit. Fastest, poor quality
* MEDIUM: Qualcomm Snapdragon Game Super Resolution (SGSR) 1.0
* HIGH: AMD FidelityFX FSR1 w/ mobile optimizations
* ULTRA: AMD FidelityFX FSR1
* <ul>
* <li>LOW: bilinear filtered blit. Fastest, poor quality</li>
* <li>MEDIUM: Qualcomm Snapdragon Game Super Resolution (SGSR) 1.0</li>
* <li>HIGH: AMD FidelityFX FSR1 w/ mobile optimizations</li>
* <li>ULTRA: AMD FidelityFX FSR1</li>
* </ul>
* FSR1 and SGSR require a well anti-aliased (MSAA or TAA), noise free scene.
* Avoid FXAA and dithering.
*
* The default upscaling quality is set to LOW.
* <p>The default upscaling quality is set to LOW.</p>
*
* caveat: currently, 'quality' is always set to LOW if the View is TRANSLUCENT.
* <p>caveat: currently, <code>quality</code> is always set to LOW if the View is TRANSLUCENT.</p>
*/
@NonNull
public QualityLevel quality = QualityLevel.LOW;
@@ -1473,134 +1506,98 @@ public class View {
/**
* Options to control the bloom effect
*
* enabled: Enable or disable the bloom post-processing effect. Disabled by default.
* <ul>
* <li>enabled: Enable or disable the bloom post-processing effect. Disabled by default.</li>
*
* levels: Number of successive blurs to achieve the blur effect, the minimum is 3 and the
* <li>levels: Number of successive blurs to achieve the blur effect, the minimum is 3 and the
* maximum is 12. This value together with resolution influences the spread of the
* blur effect. This value can be silently reduced to accommodate the original
* image size.
* image size.</li>
*
* resolution: Resolution of bloom's minor axis. The minimum value is 2^levels and the
* <li>resolution: Resolution of bloom's minor axis. The minimum value is 2^levels and the
* the maximum is lower of the original resolution and 4096. This parameter is
* silently clamped to the minimum and maximum.
* It is highly recommended that this value be smaller than the target resolution
* after dynamic resolution is applied (horizontally and vertically).
* after dynamic resolution is applied (horizontally and vertically).</li>
*
* strength: how much of the bloom is added to the original image. Between 0 and 1.
* <li>strength: how much of the bloom is added to the original image. Between 0 and 1.</li>
*
* blendMode: Whether the bloom effect is purely additive (false) or mixed with the original
* image (true).
* <li>blendMode: Whether the bloom effect is purely additive (false) or mixed with the original
* image (true).</li>
*
* threshold: When enabled, a threshold at 1.0 is applied on the source image, this is
* useful for artistic reasons and is usually needed when a dirt texture is used.
* <li>threshold: When enabled, a threshold at 1.0 is applied on the source image, this is
* useful for artistic reasons and is usually needed when a dirt texture is used.</li>
*
* dirt: A dirt/scratch/smudges texture (that can be RGB), which gets added to the
* <li>dirt: A dirt/scratch/smudges texture (that can be RGB), which gets added to the
* bloom effect. Smudges are visible where bloom occurs. Threshold must be
* enabled for the dirt effect to work properly.
* enabled for the dirt effect to work properly.</li>
*
* dirtStrength: Strength of the dirt texture.
* <li>dirtStrength: Strength of the dirt texture.</li>
* </ul>
*/
public static class BloomOptions {
public enum BlendMode {
/**
* Bloom is modulated by the strength parameter and added to the scene
*/
/** Bloom is modulated by the strength parameter and added to the scene */
ADD,
/**
* Bloom is interpolated with the scene using the strength parameter
*/
/** Bloom is interpolated with the scene using the strength parameter */
INTERPOLATE,
}
/**
* user provided dirt texture
*/
/** user provided dirt texture */
@Nullable
public Texture dirt = null;
/**
* strength of the dirt texture
*/
/** strength of the dirt texture */
public float dirtStrength = 0.2f;
/**
* bloom's strength between 0.0 and 1.0
*/
/** bloom's strength between 0.0 and 1.0 */
public float strength = 0.10f;
/**
* resolution of vertical axis (2^levels to 2048)
*/
/** resolution of vertical axis (2^levels to 2048) */
public int resolution = 384;
/**
* number of blur levels (1 to 11)
*/
/** number of blur levels (1 to 11) */
public int levels = 6;
/**
* how the bloom effect is applied
*/
/** how the bloom effect is applied */
@NonNull
public BloomOptions.BlendMode blendMode = BloomOptions.BlendMode.ADD;
/**
* whether to threshold the source
*/
/** whether to threshold the source */
public boolean threshold = true;
/**
* enable or disable bloom
*/
/** enable or disable bloom */
public boolean enabled = false;
/**
* limit highlights to this value before bloom [10, +inf]
*/
/** limit highlights to this value before bloom [10, +inf] */
public float highlight = 1000.0f;
/**
* Bloom quality level.
* LOW (default): use a more optimized down-sampling filter, however there can be artifacts
* with dynamic resolution, this can be alleviated by using the homogenous mode.
* MEDIUM: Good balance between quality and performance.
* HIGH: In this mode the bloom resolution is automatically increased to avoid artifacts.
* <ul>
* <li>LOW (default): use a more optimized down-sampling filter, however there can be artifacts
* with dynamic resolution, this can be alleviated by using the homogenous mode.</li>
* <li>MEDIUM: Good balance between quality and performance.</li>
* <li>HIGH: In this mode the bloom resolution is automatically increased to avoid artifacts.
* This mode can be significantly slower on mobile, especially at high resolution.
* This mode greatly improves the anamorphic bloom.
* This mode greatly improves the anamorphic bloom.</li>
* </ul>
*/
@NonNull
public QualityLevel quality = QualityLevel.LOW;
/**
* enable screen-space lens flare
*/
/** enable screen-space lens flare */
public boolean lensFlare = false;
/**
* enable starburst effect on lens flare
*/
/** enable starburst effect on lens flare */
public boolean starburst = true;
/**
* amount of chromatic aberration
*/
/** amount of chromatic aberration */
public float chromaticAberration = 0.005f;
/**
* number of flare "ghosts"
*/
/** number of flare "ghosts" */
public int ghostCount = 4;
/**
* spacing of the ghost in screen units [0, 1[
*/
/** spacing of the ghost in screen units [0, 1[ */
public float ghostSpacing = 0.6f;
/**
* hdr threshold for the ghosts
*/
/** hdr threshold for the ghosts */
public float ghostThreshold = 10.0f;
/**
* thickness of halo in vertical screen units, 0 to disable
*/
/** thickness of halo in vertical screen units, 0 to disable */
public float haloThickness = 0.1f;
/**
* radius of halo in vertical screen units [0, 0.5]
*/
/** radius of halo in vertical screen units [0, 0.5] */
public float haloRadius = 0.4f;
/**
* hdr threshold for the halo
*/
/** hdr threshold for the halo */
public float haloThreshold = 10.0f;
}
/**
* Options to control large-scale fog in the scene. Materials can enable the `linearFog` property,
* Options to control large-scale fog in the scene. Materials can enable the <code>linearFog</code> property,
* which uses a simplified, linear equation for fog calculation; in this mode, the heightFalloff
* is ignored as well as the mipmap selection in IBL or skyColor mode.
*/
@@ -1614,12 +1611,12 @@ public class View {
* This can be used to exclude the skybox, which is desirable if it already contains clouds or
* fog. The default value is +infinity which applies the fog to everything.
*
* Note: The SkyBox is typically at a distance of 1e19 in world space (depending on the near
* plane distance and projection used though).
* <p>Note: The SkyBox is typically at a distance of 1e19 in world space (depending on the near
* plane distance and projection used though).</p>
*/
public float cutOffDistance = Float.POSITIVE_INFINITY;
/**
* fog's maximum opacity between 0 and 1. Ignored in `linearFog` mode.
* fog's maximum opacity between 0 and 1. Ignored in <code>linearFog</code> mode.
*/
public float maximumOpacity = 1.0f;
/**
@@ -1631,11 +1628,11 @@ public class View {
* It can be expressed as 1/H, where H is the altitude change in world units [m] that causes a
* factor 2.78 (e) change in fog density.
*
* A falloff of 0 means the fog density is constant everywhere and may result is slightly
* faster computations.
* <p>A falloff of 0 means the fog density is constant everywhere and may result is slightly
* faster computations.</p>
*
* In `linearFog` mode, only use to compute the slope of the linear equation. Completely
* ignored if set to 0.
* <p>In <code>linearFog</code> mode, only use to compute the slope of the linear equation. Completely
* ignored if set to 0.</p>
*/
public float heightFalloff = 1.0f;
/**
@@ -1645,11 +1642,11 @@ public class View {
* above one are allowed but could create a non energy-conservative fog (this is dependant
* on the IBL's intensity as well).
*
* We assume that our fog has no absorption and therefore all the light it scatters out
* <p>We assume that our fog has no absorption and therefore all the light it scatters out
* becomes ambient light in-scattering and has lost all directionality, i.e.: scattering is
* isotropic. This somewhat simulates Rayleigh scattering.
* isotropic. This somewhat simulates Rayleigh scattering.</p>
*
* This value is used as a tint instead, when fogColorFromIbl is enabled.
* <p>This value is used as a tint instead, when fogColorFromIbl is enabled.</p>
*
* @see #fogColorFromIbl
*/
@@ -1660,20 +1657,20 @@ public class View {
* light is absorbed and out-scattered per unit of distance. Each unit of extinction reduces
* the incoming light to 37% of its original value.
*
* Note: The extinction factor is related to the fog density, it's usually some constant K times
* <p>Note: The extinction factor is related to the fog density, it's usually some constant K times
* the density at sea level (more specifically at fog height). The constant K depends on
* the composition of the fog/atmosphere.
* the composition of the fog/atmosphere.</p>
*
* For historical reason this parameter is called `density`.
* <p>For historical reason this parameter is called <code>density</code>.</p>
*
* In `linearFog` mode this is the slope of the linear equation if heightFalloff is set to 0.
* <p>In <code>linearFog</code> mode this is the slope of the linear equation if heightFalloff is set to 0.
* Otherwise, heightFalloff affects the slope calculation such that it matches the slope of
* the standard equation at the camera height.
* the standard equation at the camera height.</p>
*/
public float density = 0.1f;
/**
* Distance in world units [m] from the camera where the Sun in-scattering starts.
* Ignored in `linearFog` mode.
* Ignored in <code>linearFog</code> mode.
*/
public float inScatteringStart = 0.0f;
/**
@@ -1681,16 +1678,16 @@ public class View {
* is scattered (by the fog) towards the camera.
* Size of the Sun in-scattering (>0 to activate). Good values are >> 1 (e.g. ~10 - 100).
* Smaller values result is a larger scattering size.
* Ignored in `linearFog` mode.
* Ignored in <code>linearFog</code> mode.
*/
public float inScatteringSize = -1.0f;
/**
* The fog color will be sampled from the IBL in the view direction and tinted by `color`.
* The fog color will be sampled from the IBL in the view direction and tinted by <code>color</code>.
* Depending on the scene this can produce very convincing results.
*
* This simulates a more anisotropic phase-function.
* <p>This simulates a more anisotropic phase-function.</p>
*
* `fogColorFromIbl` is ignored when skyTexture is specified.
* <p><code>fogColorFromIbl</code> is ignored when skyTexture is specified.</p>
*
* @see #skyColor
*/
@@ -1703,11 +1700,11 @@ public class View {
* level with a strong gaussian filter or even an irradiance filter and then generate mip
* levels as usual. How blurred the base level is somewhat of an artistic decision.
*
* This simulates a more anisotropic phase-function.
* <p>This simulates a more anisotropic phase-function.</p>
*
* `fogColorFromIbl` is ignored when skyTexture is specified.
* <p><code>fogColorFromIbl</code> is ignored when skyTexture is specified.</p>
*
* In `linearFog` mode mipmap level 0 is always used.
* <p>In <code>linearFog</code> mode mipmap level 0 is always used.</p>
*
* @see Texture
* @see #fogColorFromIbl
@@ -1723,9 +1720,9 @@ public class View {
/**
* Options to control Depth of Field (DoF) effect in the scene.
*
* cocScale can be used to set the depth of field blur independently of the camera
* <p>cocScale can be used to set the depth of field blur independently of the camera
* aperture, e.g. for artistic reasons. This can be achieved by setting:
* cocScale = cameraAperture / desiredDoFAperture
* cocScale = cameraAperture / desiredDoFAperture</p>
*
* @see Camera
*/
@@ -1736,59 +1733,24 @@ public class View {
MEDIAN,
}
/**
* circle of confusion scale factor (amount of blur)
*/
/** circle of confusion scale factor (amount of blur) */
public float cocScale = 1.0f;
/**
* width/height aspect ratio of the circle of confusion (simulate anamorphic lenses)
*/
/** width/height aspect ratio of the circle of confusion (simulate anamorphic lenses) */
public float cocAspectRatio = 1.0f;
/**
* maximum aperture diameter in meters (zero to disable rotation)
*/
/** maximum aperture diameter in meters (zero to disable rotation) */
public float maxApertureDiameter = 0.01f;
/**
* enable or disable depth of field effect
*/
/** enable or disable depth of field effect */
public boolean enabled = false;
/**
* filter to use for filling gaps in the kernel
*/
/** filter to use for filling gaps in the kernel */
@NonNull
public DepthOfFieldOptions.Filter filter = DepthOfFieldOptions.Filter.MEDIAN;
/**
* perform DoF processing at native resolution
*/
/** perform DoF processing at native resolution */
public boolean nativeResolution = false;
/**
* Number of of rings used by the gather kernels. The number of rings affects quality
* and performance. The actual number of sample per pixel is defined
* as (ringCount * 2 - 1)^2. Here are a few commonly used values:
* 3 rings : 25 ( 5x 5 grid)
* 4 rings : 49 ( 7x 7 grid)
* 5 rings : 81 ( 9x 9 grid)
* 17 rings : 1089 (33x33 grid)
*
* With a maximum circle-of-confusion of 32, it is never necessary to use more than 17 rings.
*
* Usually all three settings below are set to the same value, however, it is often
* acceptable to use a lower ring count for the "fast tiles", which improves performance.
* Fast tiles are regions of the screen where every pixels have a similar
* circle-of-confusion radius.
*
* A value of 0 means default, which is 5 on desktop and 3 on mobile.
*
* @{
*/
/** number of kernel rings for foreground tiles */
public int foregroundRingCount = 0;
/**
* number of kernel rings for background tiles
*/
/** number of kernel rings for background tiles */
public int backgroundRingCount = 0;
/**
* number of kernel rings for fast tiles
*/
/** number of kernel rings for fast tiles */
public int fastGatherRingCount = 0;
/**
* maximum circle-of-confusion in pixels for the foreground, must be in [0, 32] range.
@@ -1806,26 +1768,16 @@ public class View {
* Options to control the vignetting effect.
*/
public static class VignetteOptions {
/**
* high values restrict the vignette closer to the corners, between 0 and 1
*/
/** high values restrict the vignette closer to the corners, between 0 and 1 */
public float midPoint = 0.5f;
/**
* controls the shape of the vignette, from a rounded rectangle (0.0), to an oval (0.5), to a circle (1.0)
*/
/** controls the shape of the vignette, from a rounded rectangle (0.0), to an oval (0.5), to a circle (1.0) */
public float roundness = 0.5f;
/**
* softening amount of the vignette effect, between 0 and 1
*/
/** softening amount of the vignette effect, between 0 and 1 */
public float feather = 0.5f;
/**
* color of the vignette effect, alpha is currently ignored
*/
/** color of the vignette effect, alpha is currently ignored */
@NonNull @Size(min = 4)
public float[] color = {0.0f, 0.0f, 0.0f, 1.0f};
/**
* enables or disables the vignette effect
*/
/** enables or disables the vignette effect */
public boolean enabled = false;
}
@@ -1839,11 +1791,11 @@ public class View {
/**
* Sets the quality of the HDR color buffer.
*
* A quality of HIGH or ULTRA means using an RGB16F or RGBA16F color buffer. This means
* <p>A quality of HIGH or ULTRA means using an RGB16F or RGBA16F color buffer. This means
* colors in the LDR range (0..1) have a 10 bit precision. A quality of LOW or MEDIUM means
* using an R11G11B10F opaque color buffer or an RGBA16F transparent color buffer. With
* R11G11B10F colors in the LDR range have a precision of either 6 bits (red and green
* channels) or 5 bits (blue channel).
* channels) or 5 bits (blue channel).</p>
*/
@NonNull
public QualityLevel hdrColorBuffer = QualityLevel.HIGH;
@@ -1855,72 +1807,44 @@ public class View {
*/
public static class AmbientOcclusionOptions {
public enum AmbientOcclusionType {
/**
* use Scalable Ambient Occlusion
*/
/** use Scalable Ambient Occlusion */
SAO,
/**
* use Ground Truth-Based Ambient Occlusion
*/
/** use Ground Truth-Based Ambient Occlusion */
GTAO,
}
/**
* Type of ambient occlusion algorithm.
*/
/** Type of ambient occlusion algorithm. */
@NonNull
public AmbientOcclusionOptions.AmbientOcclusionType aoType = AmbientOcclusionOptions.AmbientOcclusionType.SAO;
/**
* Ambient Occlusion radius in meters, between 0 and ~10.
*/
/** Ambient Occlusion radius in meters, between 0 and ~10. */
public float radius = 0.3f;
/**
* Controls ambient occlusion's contrast. Must be positive.
*/
/** Controls ambient occlusion's contrast. Must be positive. */
public float power = 1.0f;
/**
* Self-occlusion bias in meters. Use to avoid self-occlusion.
* Between 0 and a few mm. No effect when aoType set to GTAO
*/
public float bias = 0.0005f;
/**
* How each dimension of the AO buffer is scaled. Must be either 0.5 or 1.0.
*/
/** How each dimension of the AO buffer is scaled. Must be either 0.5 or 1.0. */
public float resolution = 0.5f;
/**
* Strength of the Ambient Occlusion effect.
*/
/** Strength of the Ambient Occlusion effect. */
public float intensity = 1.0f;
/**
* depth distance that constitute an edge for filtering
*/
/** depth distance that constitute an edge for filtering */
public float bilateralThreshold = 0.05f;
/**
* affects # of samples used for AO and params for filtering
*/
/** affects # of samples used for AO and params for filtering */
@NonNull
public QualityLevel quality = QualityLevel.LOW;
/**
* affects AO smoothness. Recommend setting to HIGH when aoType set to GTAO.
*/
/** affects AO smoothness. Recommend setting to HIGH when aoType set to GTAO. */
@NonNull
public QualityLevel lowPassFilter = QualityLevel.MEDIUM;
/**
* affects AO buffer upsampling quality
*/
/** affects AO buffer upsampling quality */
@NonNull
public QualityLevel upsampling = QualityLevel.LOW;
/**
* enables or disables screen-space ambient occlusion
*/
/** enables or disables screen-space ambient occlusion */
public boolean enabled = false;
/**
* enables bent normals computation from AO, and specular AO
*/
/** enables bent normals computation from AO, and specular AO */
public boolean bentNormals = false;
/**
* min angle in radian to consider. No effect when aoType set to GTAO.
*/
/** min angle in radian to consider. No effect when aoType set to GTAO. */
public float minHorizonAngleRad = 0.0f;
/**
* Screen Space Cone Tracing (SSCT) options
@@ -2006,12 +1930,10 @@ public class View {
* @see #setMultiSampleAntiAliasingOptions
*/
public static class MultiSampleAntiAliasingOptions {
/**
* enables or disables msaa
*/
/** enables or disables msaa */
public boolean enabled = false;
/**
* sampleCount number of samples to use for multi-sampled anti-aliasing.\n
* sampleCount number of samples to use for multi-sampled anti-aliasing.<br>
* 0: treated as 1
* 1: no anti-aliasing
* n: sample count. Effective sample could be different depending on the
@@ -2030,106 +1952,75 @@ public class View {
* shaders to be recompiled. These options should be changed or set during initialization.
* `filterWidth`, `feedback` and `jitterPattern`, however, can be changed at any time.
*
* `feedback` of 0.1 effectively accumulates a maximum of 19 samples in steady state.
* see "A Survey of Temporal Antialiasing Techniques" by Lei Yang and all for more information.
* <p><code>feedback</code> of 0.1 effectively accumulates a maximum of 19 samples in steady state.
* see "A Survey of Temporal Antialiasing Techniques" by Lei Yang and all for more information.</p>
*
* @see #setTemporalAntiAliasingOptions
*/
public static class TemporalAntiAliasingOptions {
public enum BoxType {
/**
* use an AABB neighborhood
*/
/** use an AABB neighborhood */
AABB,
/**
* use both AABB and variance
*/
/** use both AABB and variance */
AABB_VARIANCE,
}
public enum BoxClipping {
/**
* Accurate box clipping
*/
/** Accurate box clipping */
ACCURATE,
/**
* clamping
*/
/** clamping */
CLAMP,
/**
* no rejections (use for debugging)
*/
/** no rejections (use for debugging) */
NONE,
}
public enum JitterPattern {
/** 4-samples, rotated grid sampling */
RGSS_X4,
/** 4-samples, uniform grid in helix sequence */
UNIFORM_HELIX_X4,
/** 8-samples of halton 2,3 */
HALTON_23_X8,
/** 16-samples of halton 2,3 */
HALTON_23_X16,
/** 32-samples of halton 2,3 */
HALTON_23_X32,
}
/**
* @deprecated has no effect.
*/
/** @deprecated has no effect. */
public float filterWidth = 1.0f;
/**
* history feedback, between 0 (maximum temporal AA) and 1 (no temporal AA).
*/
/** history feedback, between 0 (maximum temporal AA) and 1 (no temporal AA). */
public float feedback = 0.12f;
/**
* texturing lod bias (typically -1 or -2)
*/
/** texturing lod bias (typically -1 or -2) */
public float lodBias = -1.0f;
/**
* post-TAA sharpen, especially useful when upscaling is true.
*/
/** post-TAA sharpen, especially useful when upscaling is true. */
public float sharpness = 0.0f;
/**
* enables or disables temporal anti-aliasing
*/
/** enables or disables temporal anti-aliasing */
public boolean enabled = false;
/**
* Upscaling factor. Disables Dynamic Resolution. [BETA]
*/
/** Upscaling factor. Disables Dynamic Resolution. [BETA] */
public float upscaling = 1.0f;
/**
* whether to filter the history buffer
*/
/** whether to filter the history buffer */
public boolean filterHistory = true;
/**
* whether to apply the reconstruction filter to the input
*/
/** whether to apply the reconstruction filter to the input */
public boolean filterInput = true;
/**
* whether to use the YcoCg color-space for history rejection
*/
/** whether to use the YcoCg color-space for history rejection */
public boolean useYCoCg = false;
/**
* set to true for HDR content
*/
/** set to true for HDR content */
public boolean hdr = true;
/**
* type of color gamut box
*/
/** type of color gamut box */
@NonNull
public TemporalAntiAliasingOptions.BoxType boxType = TemporalAntiAliasingOptions.BoxType.AABB;
/**
* clipping algorithm
*/
/** clipping algorithm */
@NonNull
public TemporalAntiAliasingOptions.BoxClipping boxClipping = TemporalAntiAliasingOptions.BoxClipping.ACCURATE;
/** Jitter Pattern */
@NonNull
public TemporalAntiAliasingOptions.JitterPattern jitterPattern = TemporalAntiAliasingOptions.JitterPattern.HALTON_23_X16;
/** High values increases ghosting artefact, lower values increases jittering, range [0.75, 1.25] */
public float varianceGamma = 1.0f;
/**
* adjust the feedback dynamically to reduce flickering
*/
/** adjust the feedback dynamically to reduce flickering */
public boolean preventFlickering = false;
/**
* whether to apply history reprojection (debug option)
*/
/** whether to apply history reprojection (debug option) */
public boolean historyReprojection = true;
}
@@ -2138,30 +2029,22 @@ public class View {
* @see #setScreenSpaceReflectionsOptions
*/
public static class ScreenSpaceReflectionsOptions {
/**
* ray thickness, in world units
*/
/** ray thickness, in world units */
public float thickness = 0.1f;
/**
* bias, in world units, to prevent self-intersections
*/
/** bias, in world units, to prevent self-intersections */
public float bias = 0.01f;
/**
* maximum distance, in world units, to raycast
*/
/** maximum distance, in world units, to raycast */
public float maxDistance = 3.0f;
/**
* stride, in texels, for samples along the ray.
*/
/** stride, in texels, for samples along the ray. */
public float stride = 2.0f;
public boolean enabled = false;
}
/**
* Options for the screen-space guard band.
* A guard band can be enabled to avoid some artifacts towards the edge of the screen when
* <p>A guard band can be enabled to avoid some artifacts towards the edge of the screen when
* using screen-space effects such as SSAO. Enabling the guard band reduces performance slightly.
* Currently the guard band can only be enabled or disabled.
* Currently the guard band can only be enabled or disabled.</p>
*/
public static class GuardBandOptions {
public boolean enabled = false;
@@ -2174,13 +2057,9 @@ public class View {
* @see #setSampleCount
*/
public enum AntiAliasing {
/**
* no anti aliasing performed as part of post-processing
*/
/** no anti aliasing performed as part of post-processing */
NONE,
/**
* FXAA is a low-quality but very efficient type of anti-aliasing. (default).
*/
/** FXAA is a low-quality but very efficient type of anti-aliasing. (default). */
FXAA,
}
@@ -2188,13 +2067,9 @@ public class View {
* List of available post-processing dithering techniques.
*/
public enum Dithering {
/**
* No dithering
*/
/** No dithering */
NONE,
/**
* Temporal dithering (default)
*/
/** Temporal dithering (default) */
TEMPORAL,
}
@@ -2203,21 +2078,13 @@ public class View {
* @see #setShadowType
*/
public enum ShadowType {
/**
* percentage-closer filtered shadows (default)
*/
/** percentage-closer filtered shadows (default) */
PCF,
/**
* variance shadows
*/
/** variance shadows */
VSM,
/**
* PCF with contact hardening simulation
*/
/** PCF with contact hardening simulation */
DPCF,
/**
* PCF with soft shadows and contact hardening
*/
/** PCF with soft shadows and contact hardening */
PCSS,
PCFd,
}
@@ -2225,14 +2092,14 @@ public class View {
/**
* View-level options for VSM Shadowing.
* @see #setVsmShadowOptions
* @warning This API is still experimental and subject to change.
* <b>Warning:</b> This API is still experimental and subject to change.
*/
public static class VsmShadowOptions {
/**
* Sets the number of anisotropic samples to use when sampling a VSM shadow map. If greater
* than 0, mipmaps will automatically be generated each frame for all lights.
*
* The number of anisotropic samples = 2 ^ vsmAnisotropy.
* <p>The number of anisotropic samples = 2 ^ vsmAnisotropy.</p>
*/
public int anisotropy = 0;
/**
@@ -2266,7 +2133,7 @@ public class View {
/**
* View-level options for DPCF and PCSS Shadowing.
* @see #setSoftShadowOptions
* @warning This API is still experimental and subject to change.
* <b>Warning:</b> This API is still experimental and subject to change.
*/
public static class SoftShadowOptions {
/**