Skip to content

Commit

Permalink
Merge branch 'rc/1.9.17' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
bejado committed Mar 22, 2021
2 parents c15db68 + 50b50d6 commit 994fdf4
Show file tree
Hide file tree
Showing 54 changed files with 2,043 additions and 832 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/presubmit.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Presubmit

on: [pull_request]
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build-desktop:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ repositories {
}
dependencies {
implementation 'com.google.android.filament:filament-android:1.9.16'
implementation 'com.google.android.filament:filament-android:1.9.17'
}
```

Expand Down Expand Up @@ -63,7 +63,7 @@ A much smaller alternative to `filamat-android` that can only generate OpenGL sh
iOS projects can use CocoaPods to install the latest release:

```
pod 'Filament', '~> 1.9.16'
pod 'Filament', '~> 1.9.17'
```

### Snapshots
Expand Down
13 changes: 12 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ A new header is inserted each time a *tag* is created.

## Next release (main branch)

## v1.9.17

- engine: New shift parameter on `Camera` to translate the viewport and emulate a tilt/shift lens.
- engine: `Camera::setCustomProjection()` now allows to set a different projection for culling and rendering.
- engine: Fixed depth of field rendering with custom projection matrices.
- engine: Fix a rare indefinite hang.
- gltfio: `SimpleViewer` now exposes more rendering parameters, including `ColorGrading`.
- gltfio: Fix tangents when morphing is enabled.
- Metal/Vulkan: fix incorrect dominant light shadows rendering.
- Fixe some issues with imported rendertargets.

## v1.9.16

gltfio: Add ResourceLoader evict API.
Expand All @@ -13,7 +24,7 @@ iOS: Disable exceptions to reduce binary size.

## v1.9.15

filamat / matc: fix sporatic crash.
- filamat/matc: fix sporadic crash.

## v1.9.14

Expand Down
2 changes: 2 additions & 0 deletions android/filament-android/libfilament-jni.map
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ LIBFILAMENT {
Java_com_google_android_filament_*;
JNI*;
*filament*Camera*;
*filament*Color*;
*filament*Exposure*;
*filament*Skybox*;
*filament*Engine*;
Expand All @@ -11,6 +12,7 @@ LIBFILAMENT {
*filament*IndirectLight*;
*filament*LightManager*;
*filament*Renderer*;
*filament*Scene*;
*filament*Transform*;
*filament*Material*;
*filament*IndexBuffer*;
Expand Down
27 changes: 19 additions & 8 deletions android/filament-android/src/main/cpp/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,31 @@ Java_com_google_android_filament_Camera_nSetLensProjection(JNIEnv*, jclass,

extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_Camera_nSetCustomProjection(JNIEnv *env, jclass,
jlong nativeCamera, jdoubleArray inMatrix_, jdouble near, jdouble far) {
jlong nativeCamera, jdoubleArray inProjection_, jdoubleArray inProjectionForCulling_,
jdouble near, jdouble far) {
Camera *camera = (Camera *) nativeCamera;
jdouble *inMatrix = env->GetDoubleArrayElements(inMatrix_, NULL);
camera->setCustomProjection(*reinterpret_cast<const filament::math::mat4 *>(inMatrix), near, far);
env->ReleaseDoubleArrayElements(inMatrix_, inMatrix, JNI_ABORT);
jdouble *inProjection = env->GetDoubleArrayElements(inProjection_, NULL);
jdouble *inProjectionForCulling = env->GetDoubleArrayElements(inProjectionForCulling_, NULL);
camera->setCustomProjection(
*reinterpret_cast<const filament::math::mat4 *>(inProjection),
*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, jdoubleArray inScaling_) {
jlong nativeCamera, jdouble x, jdouble y) {
Camera *camera = (Camera *) nativeCamera;
jdouble *inScaling = env->GetDoubleArrayElements(inScaling_, NULL);
camera->setScaling(*reinterpret_cast<const filament::math::double4*>(inScaling));
env->ReleaseDoubleArrayElements(inScaling_, inScaling, JNI_ABORT);
camera->setScaling({(double)x, (double)y});
}

extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_Camera_nSetShift(JNIEnv* env, jclass,
jlong nativeCamera, jdouble x, jdouble y) {
Camera *camera = (Camera *) nativeCamera;
camera->setShift({(double)x, (double)y});
}

extern "C" JNIEXPORT void JNICALL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ public void setLensProjection(double focalLength, double aspect, double near, do
}

/**
* Sets the projection matrix.
* Sets a custom projection matrix.
*
* @param inMatrix custom projection matrix.
* @param inProjection custom projection matrix for rendering and culling
*
* @param near distance in world units from the camera to the near plane.
* The near plane's position in view space is z = -<code>near</code>.
Expand All @@ -266,10 +266,71 @@ public void setLensProjection(double focalLength, double aspect, double near, do
* <code>far</code> != <code>near</code>
* for {@link Projection#ORTHO}.
*/
public void setCustomProjection(@NonNull @Size(min = 16) double[] inMatrix,
public void setCustomProjection(@NonNull @Size(min = 16) double[] inProjection,
double near, double far) {
Asserts.assertMat4dIn(inMatrix);
nSetCustomProjection(getNativeObject(), inMatrix, near, far);
Asserts.assertMat4dIn(inProjection);
nSetCustomProjection(getNativeObject(), inProjection, inProjection, near, far);
}

/**
* Sets a custom projection matrix.
*
* @param inProjection custom projection matrix for rendering.
*
* @param inProjectionForCulling custom projection matrix for culling.
*
* @param near distance in world units from the camera to the near plane.
* The near plane's position in view space is z = -<code>near</code>.
* Precondition:
* <code>near</code> > 0 for {@link Projection#PERSPECTIVE} or
* <code>near</code> != <code>far</code> for {@link Projection#ORTHO}.
*
* @param far distance in world units from the camera to the far plane.
* The far plane's position in view space is z = -<code>far</code>.
* Precondition:
* <code>far</code> > <code>near</code>
* for {@link Projection#PERSPECTIVE} or
* <code>far</code> != <code>near</code>
* for {@link Projection#ORTHO}.
*/
public void setCustomProjection(
@NonNull @Size(min = 16) double[] inProjection,
@NonNull @Size(min = 16) double[] inProjectionForCulling,
double near, double far) {
Asserts.assertMat4dIn(inProjection);
Asserts.assertMat4dIn(inProjectionForCulling);
nSetCustomProjection(getNativeObject(), inProjection, inProjectionForCulling, near, far);
}

/**
* Sets an additional matrix that scales the projection matrix.
*
* <p>This is useful to adjust the aspect ratio of the camera independent from its projection.
* First, pass an aspect of 1.0 to setProjection. Then set the scaling with the desired aspect
* ratio:<br>
*
* <code>
* double aspect = width / height;
*
* // with Fov.HORIZONTAL passed to setProjection:
* camera.setScaling(1.0, aspect);
*
* // with Fov.VERTICAL passed to setProjection:
* camera.setScaling(1.0 / aspect, 1.0);
* </code>
*
* By default, this is an identity matrix.
* </p>
*
* @param xscaling horizontal scaling to be applied after the projection matrix.
* @param yscaling vertical scaling to be applied after the projection matrix.
*
* @see Camera#setProjection
* @see Camera#setLensProjection
* @see Camera#setCustomProjection
*/
public void setScaling(double xscaling, double yscaling) {
nSetScaling(getNativeObject(), xscaling, yscaling);
}

/**
Expand Down Expand Up @@ -299,10 +360,32 @@ public void setCustomProjection(@NonNull @Size(min = 16) double[] inMatrix,
* @see Camera#setProjection
* @see Camera#setLensProjection
* @see Camera#setCustomProjection
*
* @deprecated use {@link #setScaling(double, double)}
*
*/
public void setScaling(@NonNull @Size(min = 4) double[] inScaling) {
Asserts.assertDouble4In(inScaling);
nSetScaling(getNativeObject(), inScaling);
setScaling(inScaling[0], inScaling[1]);
}

/**
* Sets an additional matrix that shifts (translates) the projection matrix.
* <p>
* The shift parameters are specified in NDC coordinates, that is, if the translation must
* be specified in pixels, the xshift and yshift parameters be scaled by 1.0 / viewport.width
* and 1.0 / viewport.height respectively.
* </p>
*
* @param xshift horizontal shift in NDC coordinates applied after the projection
* @param yshift vertical shift in NDC coordinates applied after the projection
*
* @see Camera#setProjection
* @see Camera#setLensProjection
* @see Camera#setCustomProjection
*/
public void setShift(double xshift, double yshift) {
nSetShift(getNativeObject(), xshift, yshift);
}

/**
Expand Down Expand Up @@ -581,8 +664,9 @@ void clearNativeObject() {
private static native void nSetProjection(long nativeCamera, int projection, double left, double right, double bottom, double top, double near, double far);
private static native void nSetProjectionFov(long nativeCamera, double fovInDegrees, double aspect, double near, double far, int fov);
private static native void nSetLensProjection(long nativeCamera, double focalLength, double aspect, double near, double far);
private static native void nSetCustomProjection(long nativeCamera, double[] inMatrix, double near, double far);
private static native void nSetScaling(long nativeCamera, double[] inScaling);
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 nSetModelMatrix(long nativeCamera, float[] in);
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 float nGetNear(long nativeCamera);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ public enum ToneMapping {
DISPLAY_RANGE,
}

ColorGrading(long colorGrading) {
// NOTE: This constructor is public only so that filament-utils can use it.
public ColorGrading(long colorGrading) {
mNativeObject = colorGrading;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import androidx.annotation.Nullable;
import androidx.annotation.Size;

import com.google.android.filament.proguard.UsedByReflection;

/**
* <code>IndirectLight</code> is used to simulate environment lighting, a form of global illumination.
*
Expand Down Expand Up @@ -430,6 +428,7 @@ public static float[] getDirectionEstimate(@NonNull float[] sh, @Nullable @Size(
}

/** @deprecated */
@Deprecated
@NonNull @Size(min = 3)
public float[] getDirectionEstimate(@Nullable @Size(min = 3) float[] direction) {
direction = Asserts.assertFloat3(direction);
Expand Down Expand Up @@ -472,6 +471,7 @@ public static float[] getColorEstimate(@Nullable @Size(min = 4) float[] colorInt


/** @deprecated */
@Deprecated
@NonNull @Size(min = 4)
public float[] getColorEstimate(@Nullable @Size(min = 4) float[] colorIntensity, float x, float y, float z) {
colorIntensity = Asserts.assertFloat4(colorIntensity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

import static com.google.android.filament.Colors.LinearColor;

import com.google.android.filament.proguard.UsedByReflection;

/**
* Skybox
* <p>When added to a {@link Scene}, the <code>Skybox</code> fills all untouched pixels.</p>
Expand Down
39 changes: 38 additions & 1 deletion android/filament-utils-android/src/main/cpp/AutomationEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

using namespace filament;
using namespace filament::viewer;
using namespace utils;

extern "C" JNIEXPORT jlong JNICALL
Java_com_google_android_filament_utils_AutomationEngine_nCreateAutomationEngine(JNIEnv* env, jclass,
Expand All @@ -33,7 +34,7 @@ Java_com_google_android_filament_utils_AutomationEngine_nCreateAutomationEngine(
extern "C" JNIEXPORT jlong JNICALL
Java_com_google_android_filament_utils_AutomationEngine_nCreateDefaultAutomationEngine(JNIEnv* env,
jclass klass) {
return (jlong) AutomationEngine::createDefaultTest();
return (jlong) AutomationEngine::createDefault();
}

extern "C" JNIEXPORT void JNICALL
Expand Down Expand Up @@ -90,6 +91,42 @@ Java_com_google_android_filament_utils_AutomationEngine_nTick(JNIEnv* env, jclas
}
}

extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_utils_AutomationEngine_nApplySettings(JNIEnv* env, jclass klass,
jlong nativeAutomation, jstring json, jlong view, jlongArray materials, jlong nativeIbl,
jint lightEntity, jlong nativeLm, jlong scene) {
using MaterialPointer = MaterialInstance*;
jsize materialCount = 0;
jlong* longMaterials = nullptr;
MaterialPointer* ptrMaterials = nullptr;
if (materials) {
materialCount = env->GetArrayLength(materials);
ptrMaterials = new MaterialPointer[materialCount];
longMaterials = env->GetLongArrayElements(materials, nullptr);
for (jsize i = 0; i < materialCount; i++) {
ptrMaterials[i] = (MaterialPointer) longMaterials[i];
}
}
AutomationEngine* automation = (AutomationEngine*) nativeAutomation;
const char* nativeJson = env->GetStringUTFChars(json, 0);
size_t jsonLength = env->GetStringUTFLength(json);
automation->applySettings(nativeJson, jsonLength, (View*) view, ptrMaterials, materialCount,
(IndirectLight*) nativeIbl, (Entity&) lightEntity, (LightManager*) nativeLm,
(Scene*) scene);
env->ReleaseStringUTFChars(json, nativeJson);
if (longMaterials) {
env->ReleaseLongArrayElements(materials, longMaterials, 0);
delete[] ptrMaterials;
}
}

extern "C" JNIEXPORT jlong JNICALL
Java_com_google_android_filament_utils_AutomationEngine_nGetColorGrading(JNIEnv*, jclass,
jlong nativeObject, jlong nativeEngine) {
AutomationEngine* automation = (AutomationEngine*) nativeObject;
return (jlong) automation->getColorGrading((Engine*) nativeEngine);
}

extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_utils_AutomationEngine_nSignalBatchMode(JNIEnv*, jclass, jlong native) {
AutomationEngine* automation = (AutomationEngine*) native;
Expand Down
Loading

0 comments on commit 994fdf4

Please sign in to comment.