Commit Graph

2159 Commits

Author SHA1 Message Date
Mathias Agopian
4c91d48ed3 Revert "use fmin/fmax for floating-point"
This reverts commit a032190b24.
2025-09-04 00:08:30 -07:00
Mathias Agopian
a032190b24 use fmin/fmax for floating-point
On ARM this generates the fmin/fmax instruction, which avoids
branches.
2025-09-03 22:30:09 -07:00
Mathias Agopian
639cdc3e5c add option to disable perfetto on android
The new cmake FILAMENT_ENABLE_PERFETTO must be set to enable 
perfetto traces on Android. It is disabled by default on release
builds, enabled otherwise.

The reason for this is that the perfetto SDK adds about 800K of code
to the library. The text section goes from 2.2 to 1.4 MB
2025-09-03 16:16:46 -07:00
Sungun Park
b0f8e1be7a Add getEyeFromViewMatrix() for vertex shader (#9175)
This new method, intended for the vertex shader, returns a matrix that
transforms vertices from view space (also known as head space) to the
current eye space.

BUGS=[441127971]
2025-09-03 18:05:34 +00:00
Ben Doherty
3bd6412780 Remove the setDebugTag API in favor of tagged create API (#9011) 2025-09-03 11:14:33 -04:00
Mathias Agopian
d3ff60af21 remove all uses of std::string in filament
- libbackend (except webgpu)
- libfilament
- libutils

std::string generates a lot of code bloat, we use CString instead.

We also update CString to be more compatible with std::string's api.
2025-09-02 11:47:58 -07:00
Powei Feng
19e1287392 Fix minor typo and styling issues (#9172) 2025-09-02 18:11:09 +00:00
Mathias Agopian
05a6198443 froxelization optimizations
- by limiting the maximum number of point light to 255 instead of 256,
  we can simplify some loops.

- hint the compiler that certain loop counters are multiple of 16 and 
non 0, which helps vectorizing.
2025-08-29 14:46:14 -07:00
Mathias Agopian
88fa99d782 The Record buffer is now dynamically sized.
The record buffer is were we store the light indices, its maximum
size is 65536 entries, but is often limited to 16384 on about 30%
of Android devices because of the 16KB UBO limit.

This PR makes the record buffer use up to 64K entries when allowed
but the h/w.

The record buffer can be a limiting factor when many lights are used
with many froxels. With the minimum of 4096 froxels and a 16KB record 
buffer we get an average of 4 lights per froxel. With our maximum of
8192 froxels and a 64KB record buffer we get 8 lights in average per
froxel.
2025-08-29 14:46:14 -07:00
Juan Caldas
74ba3eb00c webgpu: Support skinning on WebGPU (#9137)
BUGS = [436886048]
2025-08-29 00:24:14 +00:00
Powei Feng
088900e6e0 Fix bones indices and weights sampler + descriptor set (#9154)
In some places, this sampler was incorrectly assumed to be
sampler2darray, but it should be just a sampler2d.  Additionally,
sampling from it should produce unfiltered values - this has been
changed accordingly.
2025-08-28 14:05:16 -07:00
Doris Wu
ff394f7c1b feat: Add Visibility Bitmask method for GTAO (#9101)
* Quick test

* Fix incorrect logic and add some comments

* Set thickness parameter

* refactoring

* Update

* Generated files

* Some comments

* Update

* Update generated files

* Update

* Update

* Add comments
2025-08-26 23:27:02 +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
cea178a40c froxel vizualization can now be turned on/off per view
Before this change once the froxel vizualizaition was enabled via
the Engine debug framework, it applied to all views. This adds a
debug API on View to control whether the view will display this
vizualization.
2025-08-22 15:55:46 -07:00
Mathias Agopian
f34bb3d775 ViewerGui: hide stereo options when stereo is not enabled 2025-08-22 15:37:06 -07:00
Mathias Agopian
9aaa1bf413 FilamentApp: fix projection matrix
For some reason we were not setting the aspect-ratio to 1 and scaling 
the clip-space instead. This could lead to lighting and clipping
issues.
2025-08-22 15:37:06 -07:00
Doris Wu
e3384feee0 Clamp before assign to uint (#9132) (b/440220363) 2025-08-22 03:51:11 +00:00
Powei Feng
60bdbb3d1f matdbg: fix matinfo no variants bug (#9127)
matinfo -w doesn't show the variants for any backend other than
metal.  The reason is that the code for updating the variant
list wasn't being triggered on currentBackend changes.
2025-08-21 11:04:59 -07:00
Mathias Agopian
96b26b85cc add a --workarounds option to matc
Currently the only values possible are 'none' and 'all'. 'all' is the
default. This option will be used to control code generation
workarounds individually. Currently 'all' disable the
MergeReturn and Simplification passes, which have causes issues in
the past on some older Android devices.
2025-08-19 22:10:46 -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
Sungun Park
bcea4ef75d Update MATERIAL_VERSION to 64 2025-08-18 09:45:08 -07:00
Sungun Park
0ef7507464 mat: Store matc parameters in material packages (#9070)
This commit enhances the material compilation process by embedding the
`matc` command-line parameters directly into the compiled material file.
This feature is valuable for debugging, as it allows developers to
inspect the exact compilation settings used for a given material.

A key consideration is the potential for personally identifiable
information (PII) in the command-line arguments (e.g., file paths). To
address this, a `toPIISafeString` method has been implemented to filter
out PII-sensitive options before they are stored in the material.

With this change, the matc command below
    /path/to/matc -a opengl --api vulkan -p desktop -g -o /path/to/my.filamat /path/to/my.mat

is stored to the package as below. (veryfied by running `matinfo my.filamat`)
    Compilation Parameters:         -a opengl --api vulkan -p desktop -g
2025-08-17 19:25:37 +00:00
Mathias Agopian
39268a6ad0 correctly handle UTF8 strings in materials 2025-08-16 22:50:57 -07:00
Mathias Agopian
bbf0754183 add a material parameter to control shadow far attenuation
FIXES=[436680157]
2025-08-13 20:22:45 -07:00
Juan Caldas
687577b0a7 Update webgpu with new Dawn changes 2025-08-13 18:08:41 -05:00
Mathias Agopian
d27bd7909d Unit test for LineDictionary and fix subtle bugs
- add conveniences function to make LineDictionary look like a vector
- a pattern must start on a word boundary but "_" wasn't treated as one
- getIndices() must return the empty vector when any of the substring
  is not found
2025-08-13 12:48:25 -07:00
Mathias Agopian
f5c0fabb10 matc: improvements to LineDictionary compression (#9078)
We can significantly improve the effectiveness of the line dictionary
by splitting lines strategically. spirv optimization tends to create
new variable names (e.g. _1234) that are not always stable between
variants, hereby preventing lines from being duplicated. By simply
splitting lines around these patterns, we improve the effectiveness
of the compression.

The decompression is almost unchanged. To make the code easier, we 
now keep the '\n' at the end of lines in the dictionary. That's the
only change to the decompression side.

On certain materials like aiDefault.mat the compression ratio is
improved from 2.8x to 15x.


This also fixes a small but where the line dictionary relied on the
last line of the input to be a newline.
2025-08-12 12:58:35 -07:00
Powei Feng
af0f395884 Filament targets c++20 by default (#9080) 2025-08-12 05:59:21 +00:00
Powei Feng
f91ba0867e filamat: remove webgpu workaround for opt passes 2025-08-11 15:47:59 -07:00
Mathias Agopian
f85955f77b canonicalize id pass must always run last 2025-08-11 15:45:23 -07:00
Ben Doherty
6630aa5f36 matp: Remove accidental switch fallthrough (#9082) 2025-08-11 17:26:46 -04:00
Mathias Agopian
93caca7245 fig materialparser assert when shader is not present 2025-08-11 11:11:42 -07:00
yein
95128d5f55 Follow up of material parser PR (#9029)
- Fix CMakeLists to correctly include src files in matp test
- Replace std::string to std::string_view
- Also update the test_includer.cpp
2025-08-11 18:05:10 +00:00
Sungun Park
05003ea358 mat: Add CRC32 validation for material packages (#9053)
This commit introduces a CRC32 checksum to material packages to ensure
data integrity.

When a material is loaded, this checksum is verified. If the check
fails, an error is logged, and the material fails to load. For older
material packages without a CRC32 checksum, a warning is logged and
proceed.

BUGS=[373396840]
2025-08-09 00:03:56 +00:00
Juan Caldas
5cd7de7318 Change fogReserved 2025-08-08 10:44:54 -07:00
Ben Doherty
84661777e7 Materials: add useDefaultDepthVariant flag (#9020) 2025-08-07 22:49:05 +00:00
Powei Feng
c8ab2f335e Fix places where generateMipmaps is called without proper usage (#9054) 2025-08-07 22:24:40 +00:00
Powei Feng
5c371089f2 Add GEN_MIPMAPPABLE TextureUsage (#9042)
This will allow for more backend-specific usage mapping then before - where BLIT_SRC and BLIT_DST are assumed for textures whose mipmaps will be generated.

These mappings have been introduced in metal, vulkan, webgpu.
2025-08-07 18:14:49 +00:00
Mathias Agopian
b92af357f7 add a material option to use linear fog calculations (#9030)
The new `linearFog` material property, when set to `true` enables a
simplified fog calculation. The fog equation becomes linear which is
unrealistic, but more efficient to compute. In some situations with
a shallow fog range, it doesn't make a huge difference visually.

In this mode, height falloff and in-scattering are ignored.

The linear equation slope is calculated from the regular parameters to
match the slope of the real equation at a camera height. If 
`heightFalloff` is disabled, set to 0, the `density` parameter 
exactly corresponds to the slope of the equation in [1/m] units.
2025-08-07 01:33:36 -07:00
Mathias Agopian
f2a1051df9 add CanonicalizePass optimization
this makes all spirv IDs much more stable which greatly improve the
utilization of the line dictionary.
2025-08-07 01:32:31 -07:00
Mathias Agopian
7f18c7fd43 fix -d (matdbg) build option
There was two problems:
- tint was needed regardless of webgpu support
- libfilamat wasn't built on the android side
  (I don't know how it ever worked)
2025-08-06 17:29:51 -07:00
Powei Feng
9c1a252ba5 Fix two compilation errors (#9041)
- Include <limits> in bitset.h
- The type could not be inferred for Scene.cpp's `SharedState`
  line.  The failure came from clang version 1:14.0-55~exp2
2025-08-06 22:22:40 +00:00
Andy Hovingh
455545f024 wgpu: fix ssao bent normals 2025-08-05 16:35:25 -05:00
Powei Feng
4242bc43fd utils: add precond/postcond macro guarded by feature flags
We link the behavior of certain precondition/postcondition checks to feature flag states.

- If provided *flag* is true, then this macro will assert when the *condition* is false.
- If provided *flag* is fase, then this macro will output a warning when the condition is false.
- If the condition is true, then neither of the above will happen

These two macros will enable us to provide less restrictive behavior for certain correctness assertions, allowing clients to modify their before enabling these assertions by default.
2025-08-05 20:48:13 +00:00
Powei Feng
79551eacb2 Update MATERIAL_VERSION to 63 2025-08-03 22:56:09 -07:00
Yein Jo
eeb4fe219b Restore test files and moved to matp 2025-08-01 15:57:23 -07:00
Yein Jo
7d227630fc fix max line 2025-08-01 15:57:23 -07:00
Yein Jo
3a75dc6d2d Move some classes to private 2025-08-01 15:57:23 -07:00
Yein Jo
66b67849af Extract material parse logic to filament-matp 2025-08-01 15:57:23 -07:00
Doris Wu
433fded025 Workaround the skybox issue on webgl build (#8974) (BUGS=419664914)
* duplicate the material instance in webgl

* Use default instance

* Update comments

* Update

* Address the comments

* Update the naming
2025-07-31 01:56:07 +00:00