Commit Graph

2746 Commits

Author SHA1 Message Date
Ben Doherty
1ac6f5bbfe Cast shadows by default in gltf_viewer (#2538) 2020-05-15 09:43:21 -07:00
Philip Rideout
764d4198bc Add headless support to FilamentApp and frame_generator.
These changes make it easier to test headless rendering in macOS.

I verified that this works using the frame_generator tool, however
it requires the fixes in PR #2529.
2020-05-14 16:41:39 -07:00
Philip Rideout
d5d77a46ec macOS: fix headless rendering. 2020-05-14 16:38:07 -07:00
Philip Rideout
fb8b9af8fd FilamentApp: do not recreate SwapChain upon resize.
This is done for consistency with the Android samples. Tested with
gltf_viewer against Vulkan, Metal, and OpenGL. Dragged window between
high DPI and low DPI displays.

Since resizing does not trigger the "NSView has changed" handler in
PlatformCocoaGL, it now must to detect a resize in order to make the
required call to NSOpenGLContext::update() as per the following
documentation.

https://developer.apple.com/documentation/appkit/nsopenglcontext/1436135-update

Fixes #2528
2020-05-14 16:38:07 -07:00
Ben Doherty
f26b556fce Metal: allow swapchain size to change (#2535) 2020-05-14 15:47:49 -07:00
Pixelflinger
9e11e52c92 always hold a global ref on the surfacetexture
We were not holding a global ref on more recent version of android,
this made the Stream API inconsistant. 
Filament now always keeps a global ref on the surfacetexture while in
use.
2020-05-14 15:27:15 -07:00
Pixelflinger
52573ecd95 don't kick the driver thread after each framegraph pass
this was a misguided optimization, on low-end devices this actually
has a large overhead (presumably because of the smaller cache and
increased branch missprediction as well as extra synchronization).

on some low-end devices we see the gl thread go from ~40ms to ~10ms
with the gltf sample.
2020-05-13 19:36:19 -07:00
Pixelflinger
79995349d8 use systrace when EXT_debug_marker is not supported
EXT_debug_marker is not supported GL debuggers won't show these
markers, so as an alternative, we dump them in systrace.
2020-05-13 19:36:03 -07:00
Pixelflinger
e31ebb7a82 Fix a few issues with dithering
- only triangular noise needs to be scaled between +/-1, other noises
  have a uniform distribution and need to be scaled between +/-0.5

- all dither routines work in RGBA

- fixed FXAA in opaque mode when dithering modified the alpha channel
  (which is used by FXAA). This fixes flickering when FXAA and dithering
  was enabled.

- use triangular noise dithering on mobile and desktop. The cost in
  not measurable on a pixel 4 / 1080p, and the quality is better.

- refactor dithering code a bit such that:
  - noise methods are not temporal
  - all dither functions have the same structure
2020-05-13 17:16:58 -07:00
Pixelflinger
b4f09325f1 PerViewUib header and .cpp padding didn't match
It wouldn't really cause any issues, because still.
2020-05-13 10:58:23 -07:00
Mathias Agopian
ee3c3d0965 debug option to track Entities (#2526)
* debug option to track Entities

Set FILAMENT_UTILS_TRACK_ENTITIES to true when building libutils to
activate entity tracking. This adds two public methods:

getActiveEntities() and dumpActiveEntities() the later displays the
stack trace of where the remaining entities were allocated.

This is useful for tracking leaks.

* Update libs/utils/include/utils/EntityManager.h

Co-authored-by: Philip Rideout <philiprideout@gmail.com>

Co-authored-by: Philip Rideout <philiprideout@gmail.com>
2020-05-12 17:55:39 -07:00
Mathias Agopian
d08a4e8bd9 Very basic SwiftShader support (#2523)
* Very basic SwiftShader support

- we only provide SwiftShader's khornos headers in third_party

- swiftshader itself must be available on the host (for instance it
  can be compiled from source).

- to enable pass -DFILAMENT_USE_SWIFTSHADER=ON option to cmake

- only GLES 3.0 is supported. Vulkan is not yet supported.

CMake should find the swiftshader libraries automatically, but if
they're installed in a non-standard place, the environment variable
SWIFTSHADER_LD_LIBRARY_PATH can be set to that place.


We also use the GLES 3.0 headers everywhere, since we don't rely on 3.1
at this point.

* add a tnt folder with a README
2020-05-12 17:45:16 -07:00
Philip Rideout
0a9236c2eb Make JNI constructors private unless they take Engine.
This removes (rather than deprecates) all public constructors that
take a native pointer without an accompanying Engine.

Most notably, MaterialInstance had a public pointer constructor which
is now package private. This means that FilamentAsset needs an Engine,
so it now takes the one from AssetLoader.
2020-05-12 15:41:19 -07:00
Philip Rideout
0a61faa57a KtxLoader should pass Engine to Texture constructor. 2020-05-12 10:57:21 -07:00
Philip Rideout
26520c8d23 filament-utils: Improve ModelViewer flexibility. 2020-05-12 10:57:21 -07:00
Pixelflinger
64b3d7807b Fix Entity leaks with Camera
- When creating a Camera component, it is the responsibility of the caller
to destroy the Entity. ShadowMap didn't do that, so it would leak two
entities.

- When destroying a Camera component with the legacy (and deprecated)
API, Engine::destroyCamera() should destroy the associated Entity
(and was documented as doing so). However, it actually didn't.

- don't use the static EntityManager is ShadowMap.
2020-05-12 10:08:13 -07:00
Pixelflinger
ec77086186 only libbackend should link against gl/vlukan/etc...
filament itself should be agnostic to the rendering api
2020-05-12 10:07:53 -07:00
brian.wang
0187caf10f Fix minor bug in Vulkan backend on Windows
* fix compile error when vulkan

* matc:print shaders support

* fix link error

* ussage for matc print flag

Co-authored-by: brian.wang <brian.wang@noitom.com>
2020-05-12 08:59:25 -07:00
Philip Rideout
823f5c9c1f WebGL: upgrade and accommodate EMSDK.
Fixes #2515.
2020-05-11 13:58:07 -07:00
Philip Rideout
9a47178b3d gltfio: expose getMaterialInstances to Java.
Tested locally by hacking gltf-viewer on Android, added the following
lines to MainActivity:

```kotlin
for (mat in modelViewer.asset!!.materialInstances) {
    Log.d("gltf-viewer", mat.name)
}
```
2020-05-11 10:39:13 -07:00
Ben Doherty
a3fb5c41f1 Make note of VS2019 for building Android on Windows 2020-05-11 09:47:14 -07:00
Ben Doherty
58df2681dd Fix unused variable in release (#2504) 2020-05-11 09:33:51 -07:00
Kostiantyn Zghirovskyi
5ef816ef2a Clarify Windows build instructions (#2507) 2020-05-11 09:33:14 -07:00
Romain Guy
91f052a9b0 Clarify doc 2020-05-10 14:15:42 -07:00
Romain Guy
6a0a2d965e Update documentation 2020-05-09 15:13:25 -07:00
Kostiantyn Zghirovskyi
2260fe5b62 Fix filament-utils-android build on Windows (#2508)
* Fix filament-utils-android build on Windows

* Update build.gradle

* nit: use char version instead

* Fix No signature of method: java.lang.String.replace() is applicable for argument types: (Character, String) values: [\, /]
2020-05-08 16:57:16 -07:00
Pixelflinger
e07f0dd244 Texture(Engine, long) instead of Texture(long)
deprecated Texture(long nativeTexture) in favor of
Texture(Engine, long nativeTexture), there is no difference
currently,  but in the future Texture(Engine, long nativeTexture) 
will be able to validate the native pointer.
2020-05-08 15:39:14 -07:00
Pixelflinger
d194eec0ad report to java when an object can't be destroyed
The JNI layer already does this, but can only track objects it created,
sometimes developers might create filament objects on the native side
and wrap them into java objects and this might cause a failure to
detected when objects are double-destroyed.

However, this can often be caught by the native code -- so, when the
native side is asked to destroy an object that doesn't exist, we now
return an error (exception if enabled) and we throw an exception
on the java side.

Filament typically doesn't do this kind of tests, however these bugs
can be very hard to find, and the cost is small.
2020-05-08 15:39:14 -07:00
Pixelflinger
addf325d42 better handling of invalid handles
- all backend return nullptr when handle_cast<> is called with
  an invalid handle. this ensures a prompt crash on all backends rather
  than different behaviors, some including potential memory corruptions.
  assert() in debug builds. The proper way to check is to cast the
  handle to bool.

- be more consistent in the GL backend about where we check for the
  validity of handle -- which is basically nowhere, except for destroy
  (because we have the same semantic than free(nullptr) -- i.e. no-op.
  Other places are treated like bad pointers, and as per above
  handle_cast<> will return nullptr.

- make sure we don't call FScene::updateUBOs with an invalid handle
  when the scene is empty
2020-05-08 15:39:14 -07:00
Pixelflinger
c019781471 only log "no texture bound" in debug builds
This is way to verbose in release builds, and since it's not
a bug issue on GLES, we silence this for now.
2020-05-08 15:39:14 -07:00
Pixelflinger
de849fa21f removed a wrong assert() 2020-05-08 15:39:14 -07:00
Philip Rideout
072d17d64f gltfio: use the new material name feature.
To see proof that this works, use gltf_viewer with -u and examine the
node hierarchy. You will now see the correct material names instead of
the ubershader names.
2020-05-08 11:24:38 -07:00
Philip Rideout
38b9cf4fe3 Vulkan: add support for resizing the window.
Fixes #334.
2020-05-08 09:46:49 -07:00
Philip Rideout
d0a8c6b4fa Vulkan: refactor destroySwapChain. 2020-05-08 09:46:49 -07:00
Philip Rideout
ab2ae245ba Vulkan: refactor createVkSurfaceKHR. 2020-05-08 09:46:49 -07:00
Philip Rideout
f53f03b5dd Java MaterialInstance::getName now creates string lazily. 2020-05-08 09:44:49 -07:00
Philip Rideout
474fe9c5ed Change behavior of MaterialInstance::getName. 2020-05-08 09:44:49 -07:00
Philip Rideout
c3c8293862 MaterialInstance now has an optional name.
When no name is provided during instance creation, it does NOT inherit
the name of its parent material. This is because instances should be
lightweight and users can already do instance->getMaterial()->getName().

In a subsequent PR, this feature will be exercised and tested via the
gltfio AssetLoader.

Fixes #2485.
2020-05-08 09:44:49 -07:00
Ben Doherty
3c42ace496 Fix, don't sample from cascades without visible shadows (#2501) 2020-05-07 16:50:34 -07:00
Romain Guy
2702ef123c Update README.md 2020-05-07 13:26:57 -07:00
Romain Guy
89e76fde57 Update README.md 2020-05-07 13:18:23 -07:00
Romain Guy
37c8f1d8ea Update README.md 2020-05-07 13:16:43 -07:00
Romain Guy
8416553724 Update README.md 2020-05-07 13:15:12 -07:00
Romain Guy
f3baecc4be Update README.md 2020-05-07 13:11:20 -07:00
Ben Doherty
89df8355aa Fix build warning (#2499) 2020-05-06 18:30:58 -07:00
Ben Doherty
0e00dbb967 Add up and down movement to free flight camera (#2494) 2020-05-06 18:30:43 -07:00
Pixelflinger
786dbdc6e4 fix JNI objects allocation and memory corruption
- we were allocating objects with a destructor in the command stream
  which is always invalid because there is no guarantee that when 
  the callback is called, the underlaying memory is still valid
  (and it wasn't).

- AutoBuffer move-ctor wasn't moving some of its state, which would
  lead to destroying the same ref several times.
2020-05-06 18:08:13 -07:00
KJ Liu
920dc6b167 AssetLoader now loads names for mesh-free nodes. 2020-05-06 17:59:20 -07:00
Pixelflinger
809379b93d only implement flushAndWait() debugging on android
it's causing some unrelated problem on the iOS simulator, and we're
looking for an Android bug anyways.
2020-05-06 17:42:48 -07:00
Ben Doherty
4701945c87 Add rudimentary cascading shadow map support (#2482) 2020-05-06 17:20:04 -07:00