Commit Graph

160 Commits

Author SHA1 Message Date
Mathias Agopian
f8e8c27c04 Add a Renderer API to force skipping frames (#9313)
* Add a Renderer API to force skipping frames

Renderer::skipNextFrames(size_t) can be used to force filament to
pretend the next N frames must be skipped. This is mostly useful for
debugging.

* Add DebugOptions to Settings

We still need to move the "Debug" features of gltf_viewer to this,
but this give us a framework to do it. 
Currently there is one debug option that allows to set a number of
frames to skip.

ViewerGui propose a button to skip 10 frames using this framework

* Update libs/viewer/src/Settings.cpp

Co-authored-by: Powei Feng <powei@google.com>

* Update libs/viewer/src/Settings.cpp

Co-authored-by: Powei Feng <powei@google.com>

---------

Co-authored-by: Powei Feng <powei@google.com>
2025-10-13 12:52:17 -07:00
Eliza
8e5dabfa8e utils: split Slice into mutable and constant types (#9276)
* slice: fix memory semantics

* slice: prefer passing slice by value

This lets us do nice things like coercing Slice<T> to Slice<const T>, etc.

* slice: fix unit tests

* slice: fix copy/assignment, hash function

Don't attempt to define a copy constructor/assignment operator which would
convert a constant type to a mutable type.

Additionally, fix the hash function such that we're hashing U instead of const
U.
2025-10-01 22:40:50 +00:00
Mathias Agopian
15bb295ec6 A new froxel grid vizualization for FilamentApp
FilamentApp now has debugging options to enable or disable the
camera and directional shadow frustums, as well as the new
"froxel grid" visualization.

"froxel grid" is automatically enabled when "froxel debugging" is
enabled in the debug gui in gltf_viewer.


New corresponding debugging APIs were added to View.
2025-08-22 15:55:46 -07:00
Mathias Agopian
30112b5b5b gltf_Viewer: the -y (--eyes) options wasn't working 2025-08-22 15:37:06 -07:00
Powei Feng
45fcea101f webgpu: enable choosing vulkan backend on MacOS (#9106)
- Add a Configuration struct to the WebGPUPlatform class.  This
   allows for client-side setting of WebGPU backend configurations.
 - Add a configuration for forcing the wgpu backend to pick a
   certain backend.
 - Add Vulkan as a potential backend for WebGPU + MacOS.
 - Locally modify Dawn so that it does not assume only switfshader
   is available for Vulkan on MacOS.
 - Enable vulkan support for Dawn (third_party/dawn/tnt/CMakeLists.txt)
 - Plumb option to pick different WebGPU backend through
   FilamentApp and gltf_viewer.
2025-08-20 04:50:17 +00:00
Powei Feng
3ce752c47b gltfio: enable passing in variant filters (#8851)
This enables filtering variants when using the JitMaterialProvider.
2025-06-13 21:06:22 +00:00
Juan Caldas
ad8c9ce4e0 Add common CLI Args parser for the samples (#8819) 2025-06-05 18:18:41 +00:00
Powei Feng
db30a9a50c viewer: add option to export TIFF in automation (#8472)
PPM does not store alpha channel, but TIFF does.  We add a method
to export RGBA to a TIFF file without compression.

We add the corresponding options to gltf_viewer and
AutomationEngine.

The default export format for both gltf_viewer and AutomationEngine
is now TIFF.
2025-02-27 18:54:37 +00:00
Ben Doherty
863b1346e1 Rename IOS define to FILAMENT_IOS (#8340) 2025-01-08 13:11:39 -08:00
Powei Feng
0803987df3 samples: clean-up automation objects in gltf-viewer (#8285) 2024-11-19 15:38:28 -08:00
Mathias Agopian
d16fc01cfe Add support for exr files in gltf_Vvewer 2024-09-15 23:08:58 -07:00
Powei Feng
0fd2436cd1 sample: fix two IBL loading crashes
- Both Scene and IBL are holding on to a skybox reference. We
   need to make sure the order they are destroyed in right order.
 - Reloading IBL should trigger resetting the indrect light in
   gltf_viewer.
2024-09-13 17:02:02 -07:00
Mathias Agopian
2202b5ab8c Add support for depth clamp and use it for shadows
vk, metal and desktop gl all support depth clamp, GLES/android also does
with ANGLE. Add support for it in the backends.

use depth clamp to improve directional shadow quality; this allows
to render everything that's behind the camera at the same "zero" depth,
so we can reduce the depth range we need.

Fixes #6293
2024-08-30 10:56:31 -07:00
Sungun Park
a7317e7a99 Revert two depth relevant changes (#8083)
This reverts commits
- b70aa43727 "depth clamp cannot work with VSM"
- 6c0bd360b3 "Add support for depth clamp and use it for shadows"
2024-08-26 23:30:15 +00:00
Mathias Agopian
1c2ffc9ed4 new screenshot debug option in gltf_viewer
screenshots are saved in the current directory as 
"screenshotXX.ppm" with XX increasing after each
screenshot.
2024-08-20 22:41:49 -07:00
Mathias Agopian
6c0bd360b3 Add support for depth clamp and use it for shadows
vk, metal and desktop gl all support depth clamp, GLES/android also does
with ANGLE. Add support for it in the backends.

use depth clamp to improve directional shadow quality; this allows
to render everything that's behind the camera at the same "zero" depth,
so we can reduce the depth range we need.

Fixes #6293
2024-08-19 17:13:30 -07:00
Mathias Agopian
5966b5dd8f fix shadow cascade computations
shadow cascades where not calculated properly because part of the 
calculation took the cascade near/far into account, while another
part didn't. This resulted in cascades being too large. It didn't
create wrong shadows, but reduced (and in some case canceled) the
usefulness of the cascade.

We fix the problem by always  using the projection matrix only for
describing the cascade's frustum, as opposed to just passing the
near/far plane distances.

Now the calculation of each cascade is completely self contained and
identical.


We also improve the orientation of the light frustum:
We can rotate the light frustum around the light direction axis, so
it aligns with the view direction, this generally result in smaller
light frustums. This cannot be used in stable mode.
2024-08-19 16:30:16 -07:00
Sungun Park
56ac7ab902 IBL drag & drop support for desktop gltf_viewer (#7947)
Users now can drag and drop IBL files for desktop gltf_viewer.

It attempts to load gltf files first then tries to load IBL files.
2024-06-27 23:14:13 +00:00
Sungun Park
db9183a105 Fix memory leak of asset loading for gltf_viewer (#7933)
When a user drags and drops a gltf file to the gltf_viewer window, it
loads the new asset.

While this happens, the function `checkAsset` tries parsing the gltf
file, but it doesn't free it. Fix this.
2024-06-21 10:37:01 -07:00
Mathias Agopian
682150ceec add debug option to disable sub-passes 2024-06-10 13:18:59 -07:00
Powei Feng
a9f3971989 Refactor stereo build flags and configs (#7857)
- Add option to build.sh to build for paritcular stereo
   techniques (default to NONE). Only applies to samples.
 - Consoldiate viewer checkbox for debugging stereo rendering
 - Add DriverConfig flag for stereoscopic type so that it can
   be used to determine availability of the feature and
   (to be completed) enable corresponding GPU features.

Co-authored-by: Mathias Agopian <mathias@google.com>
2024-05-16 17:37:27 +00:00
Sungun Park
0f7cffc407 Connect multiview components together (#7671)
Plumb through multiview configurations to the pipeline so that the
engine draws scenes using multiview extension. Users need to prepare
shaders compiled with the `multiview` param and set the
`stereoscopicType` flag to MULTIVIEW in the Engine::Config to enable
multiview feature.

In this change, postprocessings for multiview are not yet supported. So
we all disable them until they're supported.

The debug option `combineMultiviewImages` combines layers as one image,
which allows us to check the final result.
2024-03-15 22:01:38 +00:00
Mathias Agopian
59b59cf6be add missing includes in libutils public headers 2024-01-26 10:58:00 -08:00
Mathias Agopian
130825422e Shadowmap texture vizualizer
The vizualizer is implemented inside filament itself and activated
using the debug registry. This intended for filament development use.
2024-01-24 11:28:11 -08:00
Ben Doherty
7d31a7f7ea Move stereoscopic debug options to Settings framework (#7347) 2023-11-15 10:51:58 -08:00
Mathias Agopian
a900bc69fb don't precompile variants in gltfio
we recently added calls to Material::compile in gltfio to precompile
materials are they are discovered. that wasn't a good call, because 
this should be the responsibility of the app, not of gltfio, at least
not without an option.

This is now done in gltf_viewer. We need something similar for 
Android.

Bugs #7318, #7336
2023-11-10 15:30:44 -08:00
Ben Doherty
06e8b1d689 Support up to 4 side-by-side stereoscopic eyes (#7328) 2023-11-09 15:34:50 -08:00
Mathias Agopian
7d694ee85e repair gltf_viewer drag&drop
Drag and dropping a gltf folder was broken:
- the handle didn't find the gltf file on drag&drop
- the ResourceLoader cached the asset path
- don't exit(1) when drag&dropping an invalid file
2023-11-02 06:00:45 -07:00
Mathias Agopian
0f9a2dd6af Froxel visualization debug option
The setting can be changed at runtime using a debug property.
2023-10-23 10:02:52 -07:00
Mathias Agopian
6498cf5b64 dynamic shadowmap visualization (#7274)
* debugging PCF mode

This mode always uses a hard PCF and takes a 
slightly slower code path.

* dynamic shadowmap visualization

The directional shadowmap visualizer is implemented behind a 
specialization constant. Add the DebugRegistry infrastructure to be
able to update the spec-constant at runtime and have a subset of 
all materials invalidated.

This allows to toggle the visualization at runtime using a debug
property.

This is also a proof of concept that we can update spec-constants
at runtime; we could probably leverage this work for engine-wide
shader configurations.

* Update main.fs

* Update filament/src/details/Material.cpp

Co-authored-by: Powei Feng <powei@google.com>

---------

Co-authored-by: Powei Feng <powei@google.com>
2023-10-19 12:18:00 -07:00
Mathias Agopian
1b0db0fca2 fix a couple shadow stability bugs
- shadows are now stable (in stable mode) when an IBL rotation is
  used.

- fix the shadow transform option which didn't work when an IBL rotation
  was used

- also use the x-axis as a reference for the "up" direction when
  computing the light space matrix so that we don't fall into the
  degenerate case when the light points straight down, which is a
  common case

FIXES=[299310624]
2023-10-17 12:26:43 -07:00
Mathias Agopian
da73f89a23 improve/simplify "Focus on shadow casters" algorithm
Functionally this shouldn't be too different, but we have some
improvements:
- better detection of "no shadows" cases
- more computations done in light-space, which should result in
  better light frustum.
- spit the code into several static functions
2023-09-19 14:15:52 -07:00
Mathias Agopian
1ff0a2dd6d Improvements to shadowing
- use the geometric normal to apply the shadow bias. This affects
  cascades > 0 and spot/point lights.

- use the scene's origin as a reference point for stabilizing the
  shadowmap, this is more robust.

- clamp directional shadowmap correctly to the 1-texel border, which
  needs to be reachable, as it is a valid value.

- don't snap the shadowmap to texel boundaries if stable mode is not
  active (before we only didn't do it based on lispsm). Stable mode can
  make the shadow unstable when both the camera and the scene move 
  together, so it's better to have a more predictable API where
  "stable" mode means that the snapping occurs and doesn't otherwise.

- add "far origin" distance slider to the debug ui

FIXES=[299310624]
2023-09-12 10:14:21 -07:00
Ben Doherty
6bb29f6e01 Implement preliminary support for instanced stereo (#6967) 2023-08-15 17:08:11 -07:00
Powei Feng
d43c632e55 vulkan: add option to choose gpu in platform (#6864) 2023-06-06 17:18:57 -07:00
Mathias Agopian
a8afa91b7d add support for custom fog color in gltf_viewer
this is implemented by here by using the skybox texture and blurring it
with the irradiance filter + mipmapping. This only creates a subtle
anisotropic phase-function effect.
2023-05-24 16:37:10 -07:00
Mathias Agopian
f6c8ce1fd1 New API to apply a transform to the large-scale fog.
This works by making the fog an entity which can be used to create
a TransformManager component an participate to the transform hierarchy.

This feature can be used as more advanced way to set the fog's floor,
which now can have an orientation (essentially be a plane).
This is useful for coordinate systems that are not y-up.
2023-05-16 12:42:59 -07:00
Mathias Agopian
6eb4c5e356 gltf_viewer: debug option to move the origin far away 2023-03-31 14:47:54 -07:00
Mathias Agopian
96acc6900d gltf_viewer now respects FILAMENT_DISABLE_MATOPT
debug builds are unchanged, release builds will now optimize shaders and
either build can be overridden with OPTIMIZE_MATERIALS.
2023-03-24 09:23:10 -07:00
Powei Feng
9fed30af55 gltf-viewer: update API/backend usage description (#6638) 2023-03-13 23:22:30 -07:00
Mathias Agopian
94f121f37d Add a camera near/far setting in gltf_viewer 2023-02-17 11:16:42 -08:00
Mathias Agopian
032ace2051 Add output color space to ColorGrading settings 2023-01-31 09:46:22 -08:00
daemyung danny jang
c7c184d952 Make a small optimization on drop event at filament app (#6424) 2023-01-05 08:38:28 -08:00
Mathias Agopian
1d387d04fd add a debug option for Renderer's buffer padding 2022-12-12 11:18:17 -08:00
Philip Rideout
9fa6dc4131 gltfio API change part 1: move all MaterialInstance methods to FilamentInstance 2022-09-29 16:28:50 -07:00
Mathias Agopian
0dc0bbd4f3 LiSPSM is now a user settable option 2022-09-22 09:35:45 -07:00
Mathias Agopian
8dc16494a7 introduce "feature level 3"
This is because most android devices only support 16 texture in the
shaders (94.4%), so we can't realistically have feature level 2 demand
that.

Instead feature level 2 enables compute/ES3.1 features.
2022-09-14 16:53:43 -07:00
Mathias Agopian
58401e0b6e Fix FilamentApp multiview mode in gltf_viewer
- fix View::setVisibleLayers to match code. By default only layer 0
  is active, despite the documentation stating otherwise.

- add a helper to enable/disable layers more easily

- don't use layer 0,1,2 for the overdraw function as they were used by
  FilamentApp in "multi view" mode.
2022-09-12 15:55:16 -07:00
Mathias Agopian
25990ecd37 FilamentApp sets the feature level to highest allowed
There is also a new option to override the default with a lower
feature level. This is used in gltf_viewer only at the moment.
2022-09-07 15:32:58 -07:00
Mathias Agopian
ead5a97871 make AutomationEngine feature level aware
this basically just adds an Engine* parameter too all applySettings
methods
2022-09-07 15:32:58 -07:00