Commit Graph

2140 Commits

Author SHA1 Message Date
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
Ben Doherty
ce5c6e3aec Fix incorrect buffer size and memory free issue with prefilter mipmap (#9009) 2025-07-30 10:31:41 -07:00
Ben Doherty
c25ac68a3a Better set default shader stages for samplers (#8992) 2025-07-29 10:01:36 -07:00
Powei Feng
0f572f797d utils: add method for index of first set bit in bitset (#9006) 2025-07-28 19:58:40 +00:00
Powei Feng
e4aeca28ec matdbg: update monaco dep (#8997)
- Update the monaco editor to the latest available version
   (0.52.2)
- Disable formatting for webgpu since it's already formatted
2025-07-26 00:07:47 +00:00
chenriji
7048a9847a fixbug: 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. (#9000)
2025-07-25 11:07:02 -07:00
Mathias Agopian
2abacaa030 the ssr-history texture is not an array
the descriptor used for SSR is different depending on the pass. In
the color pass, it's used as the source of the SSRs buffers and is an
array (refraction & reflection). In the SSR pass it's the history
buffer and is just a 2D texture.
2025-07-22 10:08:22 -07:00
Powei Feng
9640f2656f Make sure structure textures are unfilterable 2025-07-21 21:22:47 -07:00
Powei Feng
e89363751d docs: various updates and improvements (#8971)
- Add github link to page
 - Fix link in contributing.md
 - Small update to docs_src/README.md
 - Remove logo in the core docs
 - Move branching.md and release_guide.md to /docs_src
 - Add "under construction" warning for the web samples
 - Update matdbg README.md
2025-07-18 21:00:25 +00:00
Powei Feng
329ca04248 Change unfilterable to filterable (#8932) 2025-07-16 23:46:20 +00:00
Mathias Agopian
4e50e64888 new generatePrefilterMipmap.a library 2025-07-07 14:16:16 -07:00
Sungun Park
954d1021c7 Add #include <cstdlib> to avoid compilation error (#8922) 2025-07-02 18:54:03 +00:00
Powei Feng
b6d7ed2b35 Bump Material Version to 62 2025-06-29 22:34:35 -07:00
Ben Doherty
67288d483f materials: Add VARIANT_DEPTH define for depth shader variants (#8905) 2025-06-27 14:23:37 -04:00
Ben Doherty
1f8cacdd70 matinfo: Report if a material has custom depth (#8904) 2025-06-26 17:30:01 -04:00
Powei Feng
42a0a41be0 webgpu: remove float filterable requirement (#8895)
This will enable webgpu for devices such as pixel 4, which does
not support this feature.
2025-06-26 18:15:41 +00:00
Ben Doherty
573a51c430 Fix segfault in matinfo (#8896) 2025-06-25 12:25:19 -07:00
Powei Feng
f096c4d8de Add unfilterable to Material sampler definition (#8873)
`unfiterable : true` indicates that the sampling of the texture
will not apply filtering.

This is mainly to satisfy the webgpu requirement for
bindGroupLayouts.

 - Documentation has been updated for both `unfilterable` and
   `multisample`.
 - Internal materials have been updated where necessary (depth
   samplers have to be marked as `unfilterable`.)
 - webgpu code has been changed appropriately.

BUGS=420745987
2025-06-18 21:14:42 +00:00
Sungun Park
a3922ac3a9 Bump MATERIAL_VERSION to 61 2025-06-13 15:39:09 -07:00
Sungun Park
09545690bf Revert "materials: introduce mutable spec constants (#8795)"
This reverts commit 8a1a0b0fd2.
2025-06-13 15:02:55 -07:00