The VSM variant bit was overloaded, it meant two different things
depending on the DEP bit (depth).
For standard variants (DEP = 0), it decides the type of the shadow
sampler used (PCF or 2D).
For depth variants (DEP = 1), it decides what is written during the
shadow pass (nothing, i.e. depth only, or EVSM depth moments).
We now clearly separate the two bits throughout the code.
This change should be purely source-cosmetic, there shouldn't be any
behavior changes.
Co-authored-by: Powei Feng <powei@google.com>
The previous code used the max of the texel's width or height footprint
in world space to compute the offset; this could both overestimate or
underestimate the bias causing some peter panning or acne.
The new code replaces a sqrt with a dot, but is otherwise similar.
* fixbug:"debug error, reason: The material 'Material_MR' has not been compiled to include the required GLSL or SPIR-V chunks for the vertex shader (variant=5, filtered=5)",Because the member variable mVariantFilter is not initialized, random values will appear on Windows 10 or others platform, which eventually causes some variants to be filtered out by this mVariantFilter.
* fix:Fix morph target loading for accessors without buffer_view
Morph targets were not working because ResourceLoader skipped all
accessors without buffer_view. For morph targets, the data can be
accessed directly via cgltf_accessor_unpack_floats().
This fix properly unpacks and uploads morph target vertex data to the
GPU, enabling blendshapes and facial deformation to work correctly.
Steps to Reproduce
1、In Unity (2022.3.11): Create a Prefab with Blend Shapes (Morph Targets) and an Animator to control them (e.g., an animation clip that makes the eyes squint).
2、Export: Use the UnityGLTF tool to export the model as a .glb file (including the Animator and Morph Target tracks).
3、In Filament: Load and play the animation.
4、Result: The skeletal animation (bone-based) may play, but the Morph Target effect (squinting) is missing or static.
- This is an initial implementation, not yet complete
- Goal of this sample is to run a series of offscreen single
frame captures, and capmre the result against a set of golden
images
- Uses existing scene description in libs/viewer and
test/renderdiff
- Uses existing image difference description/implementation in
libs/imagediff
- Add imagediff API to filament-utils-android
Enables the multiview implementation as the default for stereoscopic
rendering. Now all STE variants use the multiview path.
This change removes all CMake configurations, build scripts, and C++
preprocessors previously used for selecting stereoscopic rendering
modes. And, all shaders are now compiled for multiview.
The instanced rendering implementation is going to be removed. Note that
this commit only handles switching the default. The actual removal of
instanced rendering code will be submitted as a separate follow-up
commit.
BUGS=[470198472]
A preliminary commit to add a websocket server to the DebugServer.
This will enable us to transfer large data (like images) across
to the frontend.
This is part of the work to enable viewing intermediate
render buffers in fgviewer.
Instead of computing the fog "inline", in the forward pass, we can
instead compute it as post-process pass that is applied with a
simple fullscreen quad blending. On tilers, the operation entirely
stays in the tile, on desktop GPU it is a blending operation.
This works only for opaque materials.
The benefit is that fog will become immune to overdraw, and the forward
pass shader will be simplified, hopefully leading to less register
pressure. Overall performance should be improved.
Another benefit is that it will allow us to free the "fog" texture
slot from all opaque materials.
Transparent materials are unchanged.
This feature is currently DISABLED, and still work in progress; but it
should be mostly functional.
To test it:
```
env material.enable_fog_as_postprocess=true ./out/samples/gltf_viewer
```
This change refactor the fog code, but shouldn't have any impact on the
current behavior.
- Add new library to do tiff import/export. This library is
different from imageio in that it doesn't pull in additional
3p libraries. This reduces binary size and reduces
complexity in maintaining the android build (which depends
on libs/viewer).
- The encode() code has been moved from libs/viewer to
libs/imageio-lite
- encode/decode only handles the simplest case of uncompressed
rgba.
* engine: add program cache
This is another chunky change.
The core of this change is to cache programs in MaterialCache according to a
"specialization" (ProgramSpecialization) which is defined as the program cache
ID (the same key used for the OpenGL binary blob cache), the variant, and the
set of spec constants.
As part of this change, a lot of the implementation details of shader
compilation were refactored from Material to MaterialDefinition. The resulting
flow is a lot cleaner and easier to reason about, since shader compilation is
now a pure function of the MaterialDefinition + ProgramSpecialization.
Since the global cache program lookups might take a bit of time to compute
hashes, etc, I left the set of cached programs in Material as well, which kind
of acts like an L1 cache. The effect is that prepareProgram() and getProgram()
should be no slower than HEAD, even with the more complex caching requirements.
I'm planning on writing a document about this (and all changes up until this
point), but I'm being asked to work on higher priority things and I wanted to
have this PR out for review in the meantime so it doesn't bitrot.
* engine: fix unit tests
* engine: fix spec constants intern pool memory leak
* engine: address program cache comments
* engine: address more program cache comments
* engine: matdbg support for program cache
* engine: reinstate descriptorLayout calls
* engine: address bitrot
* engine: add feature flag to disable program cache
* engine: use material CRC32 for program cache
The "cache ID" of a material is supposed to uniquely identify a shader program
and all its variants. This is true to a certain extent, but does not account for
the code generation that happens at runtime. Two materials may have "identical"
shader programs, but due to each material's differing unique metadata, the final
compiled programs may end up very different. Unfortunately, this means we cannot
rely on the "cache ID" alone to determine a shader program's reusability.
Ideally, we should hash this "cache ID" with the exact set of changes to each
shader program so that we could reuse programs across materials. Instead, as a
stopgap solution, use the material's CRC32 instead.
* engine: fix double-free in program cache
* engine: address comments
* engine: assert_invariant empty material cache
- Extended Settings to include properties for Camera, Animation, Lights,
and Render options.
- Moved camera options from Viewer options to Camera options
- Implemented generic JSON parsing for these new settings in Settings.cpp.
- Updated AutomationEngine to apply these settings, including dynamic
creation of lights.
- Fixed a JSON parsing bug in AutomationSpec that failed on nested objects.
- Updated gltf_viewer to use the new settings and correctly initialize
AutomationEngine context.
- Add test for new json changes
- Add README to libs/viewer
- Link libs/viewer/README.md to official doc
- Remove unused libs/viewer/schemas
- Updated remote web assets (because the viewer/settings json needs to
match)
PerformanceHint manager needs a java thread during initialization,
so we need to attach a jvm to the thread that's going to be used.
That thread is the filament backend thread, not necessarily the thread
the platform is created on.
So we make sure to do that from the backend thread.
FIXES=[427945768]
- Add plumbing to add more information about rendertargets
(including discard flags and pass id) to the fgviewer pass
struct.
- Add UI to display information about a selected pass
- Highlight a selected resource or pass
The new tone mapper, dubbed "GT7" in the code, is based on
the Gran Turismo 7 tone mapper, as described in the SIGGRAPH
2025 presentation called "Driving Toward Reality: Physically
Based Tone Mapping and Perceptual Fidelity in Gran Turismo 7".
This tone mapper exhibits fewer hue skews than the other tone
mappers, at the exception of PBR Neutral. The GT7 tone mapper
is however better at preserving the perception of high
dynamic range.
The tone mapper, as implemented, targets an SDR paper white
of 250 nits, using 100 cd/m^2 as the reference luminance (for
values of 1.0 in the linear HDR framebuffer). This can result
in an overall darker image compared to the other tone mappers
but this can be controlled through camera settings, post-
processing exposure, or lighting intensity.
The GT7 tone mapper also allows to target HDR output, and
could be made customizable via APIs if desired. The current
implementation offers a fixed aesthetic solution.
- Add documentation for specgen along with proper math rendering
- Adjust the heading size, capitalization of various READMEs.
- Add backend test README to the doc
- Rename the CI related tests to have prefix "CI:"
- Pick a default view when database is filled.
- Fix d3, d3-graphviz depdency.
- reduce the size into a smaller table (to avoid scrolling)
- slant the pass items to allow smaller cells for the table.
- make subresource rendering the same as regular resource
rendering with a color hint.
- Use color-only to indicate resource/pass interaction (read,
write, read-write, no-access)
- add tooltip to indicate resource action
* feat(engine): Add automatic frame skipping to manage CPU/GPU latency
Introduces a new feature, disabled by default, that allows the engine to automatically skip frames when the CPU gets too far ahead of the display's refresh rate. This helps to reduce overall latency by preventing a backlog of frames from building up in the driver queue.
The feature can be enabled with the "engine.skip_frame_when_cpu_ahead_of_display" property.
To implement this, the compositor timing mechanism has been refactored. Instead of reporting an absolute `expectedPresentTime`, the backend now provides an `expectedPresentLatency` relative to vsync. This is more robust against synchronization issues with platform callbacks (like Android's Choreographer), as the latency is generally a constant value.
BUGS=[474599530]
This commit clarifies and corrects documentation in several public header
files. The changes include fixing typos, improving wording, and adding
missing details to make the API easier to understand and use.
No functional changes are included in this commit.
* split FeatureFlagManager out of FEngine
- Separate the Feature flags management from FEngine.
- Make FeatureFlagManager available to backends through DriverConfig
- add a way to override a feature flag value at runtime using
environment variables or system properties (on Android).
e.g.:
```
env "feature.name=true" gltf_viewer
```
or
```
adb shell setprop debug.feature.name true
```
Co-authored-by: Powei Feng <powei@google.com>
This commit introduces a significant rework of the Temporal Anti-Aliasing (TAA) system, focusing on improving reconstruction quality, robustness, and introducing flexible upscaling.
Core TAA Algorithm improvements:
- Replaced the Catmull-Rom filter with a more efficient 5-tap Lanczos filter for history sampling, which includes deringing to reduce artifacts.
- The input color buffer is now properly "unjittered" using a Lanczos reconstruction filter.
- Improved the history rejection algorithm by skipping the expensive accurate clipping when the history sample is already within the neighborhood's color gamut.
- Added a new `hdr` option to properly handle HDR content by tonemapping colors before blending and untonemapping the result.
- Removed the ineffective `VARIANCE` only history rejection method.
- Added protection against negative numbers in `sqrt()` for increased stability.
TAA Upscaling:
- Replaced the boolean `upscaling` flag with a float factor, allowing for variable upscaling ratios (e.g., 1.5x, 2x).
- Upscaling now correctly adjusts viewport and projection settings.
- The TAA shader now receives viewport and resolution information to correctly handle upscaled rendering.
API and Configuration Changes:
- Deprecated the `filterWidth` TAA option as it no longer has an effect.
- Introduced the `upscaling` float property to `TemporalAntiAliasingOptions`.
- Added the `hdr` boolean property to `TemporalAntiAliasingOptions`.
Other Changes:
- Updated UI elements in the viewer and material sandbox to reflect the new TAA options.
- Updated Javascript bindings and TypeScript definitions for the new TAA settings.
- Refactored shader code for clarity and performance.
Since the struct refers to descriptors as opposed to specifically
bindings (although they do contain binding information as well), this
name is more appropriate.
Api level is now enforced when generating code by appending #defines of client requested and unstable apis.
This ensures that the client can only use unstable apis when they explicitly add `apiLevel` in their .mat file.
FIXES=468340631
This commit introduces async methods and functions across both the
public and backend APIs, enabling non-blocking creation and updates for
Texture, VertexBuffer, and IndexBuffer resources.
Asynchronous resource management is disabled by default. Users should
enable this to use the feature.
Java bindings and a C++ code sample will follow in subsequent PRs.
BUGS=[442921995]