Commit Graph

102 Commits

Author SHA1 Message Date
Powei Feng
8233ab1cda Revert "[automated] Updating /docs due to commit 60df8ac"
This reverts commit 656a4b6f32.
2025-09-18 14:40:07 -07:00
Filament Bot
656a4b6f32 [automated] Updating /docs due to commit 60df8ac
Full commit hash is 60df8ac6b8

DOCS_ALLOW_DIRECT_EDITS
2025-09-18 21:32:03 +00:00
Filament Bot
220119d855 [automated] Updating /docs due to commit 81a51ae
Full commit hash is 81a51ae7e7

DOCS_ALLOW_DIRECT_EDITS
2025-09-08 06:53:30 +00:00
Filament Bot
12c3de228f [automated] Updating /docs due to commit bbf0754
Full commit hash is bbf0754183

DOCS_ALLOW_DIRECT_EDITS
2025-08-14 03:25:42 +00:00
Filament Bot
652d973ad8 [automated] Updating /docs due to commit 8466177
Full commit hash is 84661777e7

DOCS_ALLOW_DIRECT_EDITS
2025-08-07 22:52:23 +00:00
Filament Bot
3961989aca [automated] Updating /docs due to commit b92af35
Full commit hash is b92af357f7

DOCS_ALLOW_DIRECT_EDITS
2025-08-07 08:36:16 +00:00
Filament Bot
1b145310f8 [automated] Updating /docs due to commit f3d0741
Full commit hash is f3d0741853

DOCS_ALLOW_DIRECT_EDITS
2025-07-18 17:26:56 +00:00
Filament Bot
8ef7755628 [automated] Updating /docs due to commit 06b0d52
Full commit hash is 06b0d5229a

DOCS_ALLOW_DIRECT_EDITS
2025-07-17 18:00:34 +00: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
Mathias Agopian
8f58743405 support up to five custom varyings
Five custom variables (varyings) are now available on the condition that
the `color` attribute is not requested.

FIXES=[404930099]
2025-03-24 09:38:31 -07:00
Mathias Agopian
6b91f30389 Materials can now specify a shadow attenuation factor (#8540)
* Materials can now specify a shadow strength factor

Materials have a new property: shadowStrength that can be used to
attenuate all shadows received by this material. e.g.:

```
void material(inout MaterialInputs material) {
  prepareMaterial(material);
  material. shadowStrength = 0.1;
}
```

FIXES=[391663042]

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

---------

Co-authored-by: Powei Feng <powei@google.com>
2025-03-20 14:03:52 -07:00
Ajmal Kunnummal
02223dcaab Add a way to specify an additional uniform name along with a sampler param for the associated transform matrix (#8490)
BUGS=[399959254]
2025-03-06 18:42:24 +00:00
Mathias Agopian
5e7106b521 custom variables can now have their precision specified
e.g.:

    variables : [
        {
            name : vertex,
            precision : medium,
         }
    ],
2024-08-22 13:08:48 -07:00
Ben Doherty
af92a1f21b Add getEyeIndex vertex API (#7822) 2024-05-03 14:22:24 -07:00
Mathias Agopian
1c55ad49ee add support for custom blend functions
BUGS=[331610785]
2024-04-01 13:40:34 -07:00
Ben Doherty
6bb29f6e01 Implement preliminary support for instanced stereo (#6967) 2023-08-15 17:08:11 -07:00
Mathias Agopian
153dc08aa7 Support for custom fog-color texture
Fix 282968398
2023-05-23 15:52:01 -07:00
Mathias Agopian
5cb3b16f36 correctly account for user samplers in matc and document it
The number of usable sampler in materials is now documented and properly
accounted for in matc.
2023-05-22 09:59:12 -07:00
Mathias Agopian
899c15f023 very basic API for materials to have global variables (#6764)
A material global is a variable seen by all materials. There are 4 such 
variable which are all vec4 and they can be set on a per-view basis.

All materials used during Renderer::render() will see the same value.

These variable can be accessed in the materials by using 
getMaterialGloabal{0|1|2|3}.
2023-04-25 17:20:43 -07:00
Ben Doherty
6cab8d2cd4 Expose specialization constants to materials as constant parameters (#6652) 2023-04-11 11:09:53 -07:00
Andi Smithers
7914372707 Update Materials.md.html (#6646)
Fixed typo in the source documentation : getUserTimeMode(float m) which should be getUserTimeMod(float m)
2023-03-17 12:36:39 -07:00
Mathias Agopian
e2e5f7cee9 Add way to retrieve the user world-space in materials (#6607)
* Add way to retrieve the user world-space in materials

added `getUserWorldFromWorldMatrix()` and `getUserWorldPosition()` to
retrieve the API-level (user) world position in materials.
Deprecated `getWorldOffset()`

`getWorldOffset` didn't work when an IBL rotation was applied.

* fix large scenes with an ibl rotation

Rotate the IBL around the camera instead of the world so that the camera 
is always at the origin regardless of the rotation.
2023-03-03 21:34:17 -08:00
Romain Guy
5a75fb9b53 Add new alphaToCoverage material property (#6606)
* Add new alphaToCoverage material property

The alphaToCoverage property lets you enable or disable alpha to coverage
in a material. More importantly it lets you overrides the behavior of
blending: masked which automatically enables alphaToCoverage.

* Update release notes
2023-03-02 12:40:55 -08:00
Mathias Agopian
0d72a0904b getNormalizedViewportCoord() now returns the logical viewport coords
This is a better user-facing API because materials don't need to know
about the physical viewport.
2022-12-13 16:37:49 -08:00
Mathias Agopian
61ee11ae6c fix the doubleSided property documentation (#6228)
* fix the `doubleSided` property documentation

* Update Materials.md.html

Co-authored-by: Romain Guy <romainguy@curious-creature.com>
2022-10-26 12:28:03 -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
b2ec57776d new feature level API for backends (#5784)
* new feature level API for backends

backend can now return a "feature level", each level corresponds to a
"bundle" of features.
Level1: ES3.0 capabilities
Level2: ES3.1 capabilities + 31 textures + cubemap arrays

Currently metal always returns level 1, GL and Vulkan return level 2
if 31 textures or more are supported.

* Add public APIs for feature levels

* Add infrastructure to check feature levels in materials

* validate material feature level on use

The validation is done when creating a renderable. If the engine doesn't
support the material's feature level, an exception is thrown (or assert
if exceptions are not enabled).

* material documentation

* activate ESSL 3.10 for feature level 2

also generate #defines to identify available feature levels

* support for cubemap arrays in the public API


if feature level 2 is supported, cubemap arrays can be used from the
public API.

* add release notes
2022-08-17 10:14:26 -07:00
Mathias Agopian
c6502054e9 Fix guard bands and TAA with VERTEX_DOMAIN_DEVICE
With VERTEX_DOMAIN_DEVICE the vertex shader doesn't apply the 
projection (since the vertices are already in clip space), however,
both TAA and guard bands need to jitter/offset the clip space, and
it is done at the projection level.

We now store the clip space offset separately so that it can be applied
to VERTEX_DOMAIN_DEVICE vertices.

We also introduce a new material parameter, vertexDomainDeviceJittered,
a boolean that controls whether clip space offset (above) is applied.
This is because a VERTEX_DOMAIN_DEVICE material that uses the built-in
projection matrices generally ends-up with the jitter already applied,
this is the case with the Skybox for instance.

Fixes #5917
2022-08-16 15:32:33 -07:00
Romain Guy
59e9f36e25 Update docs for sampler2D arrays 2022-08-03 16:08:28 -07:00
Mathias Agopian
61e117beaa Added a new instanced material parameter
This boolean parameter is used with materials that need to access 
`getInstanceIndex()` (filament's equivalent to `gl_InstanceIndex`).
It is false by default, and getInstanceIndex() is not accessible.
This is intended to be used in concert with
`RenderableManager::Builder::instances()`.
2022-06-08 17:10:38 -07:00
Romain Guy
f78d131015 Updates docs 2022-05-10 08:31:58 -07:00
Mathias Agopian
657c251463 Ensure we always have 4 "safe" mip levels
A "safe" mip-level is one that has exactly half the dimensions of
the current level. In other words, we guarantee that we can halve the
dimensions 4 times without loss (i.e. odd dimension).

This is achieved by effectively padding the viewport (i.e. making the
viewport's dimensions multiple of 16). The post-processing passes
eventually take care of cropping the extra padding so the final
image is unchanged.

This is a more generic solution to dynamic resolution padding, helps
with memory allocations and helps all the algorithms that depend on
mipmaping (e.g. DoF, SSAO, Bloom).


One important improvement brought by this change is that all "final"
post-processing effects are now able to handle a sub-region of the
source, including: color-gradding, fxaa and upscaling.
2022-04-29 12:05:08 -07:00
Philip Rideout
6da46b3b62 Repair A2C for opaque views, add field to FrameUniforms. 2022-03-17 10:01:27 -07:00
Philip Rideout
e8d8080928 New behavior for BlendingMode::MASKED.
The existing behavior was surprising for users who draw opaque objects
into a semitransparent views, and this was especially evident with
the labels in `TextureLinearInterpolationTest`.

We now disable blending for MASKED, which is what our existing materials
documentation already says. We also now set the fragment alpha to 1 when
the fragment is not discarded, which prevents the "punch through"
effect. This is consistent with ThreeJS.

Fixes #4576.
2022-03-17 10:01:27 -07:00
Mathias Agopian
3f6188edff Enable rough reflections
This works by first generating a reflection buffer which gets blurred,
then the color pass samples from this buffer according to the roughness
of the surface being rendered.

A lot of the changes here involve utilizing "reserved" variants for
the new "SSR" pass and all the fallout from that.
2022-02-13 22:53:47 -08:00
Romain Guy
700b4d5d38 Update docs and readmes 2022-01-18 16:54:31 -08:00
Romain Guy
de1281dd9f Be more specific about anisotropyDirection 2021-12-06 15:37:41 -08:00
Romain Guy
91b5cc4bea Fix inverse tone mapping issues (#4437)
Bring color grading back into the Rec.709 color space to match
previous behaviors. This change also implements an exact inverse
tone map function for the "Filmic" operator.
2021-08-02 18:53:35 -07:00
Romain Guy
5c0da86e04 Fade specular AO from bent normals at grazing angles (#4411)
This helps prevent over-darkening but it's an artistic hack.
We need to check how we compute the bent normals as it seems we
find occlusion where there is no occlusion. The effect is
particularly visible on clear coat materials like a car's body.
2021-07-30 16:02:12 -07:00
Philip Rideout
0a2fa36d5a API CHANGE: honor user-defined precision, rename SamplerPrecision. (#4287)
* API CHANGE: honor user-defined precision, rename SamplerPrecision.

matc now honors 'precision' on non-samplers in mat files, and
the filamat API now allows clients to specify precision for
non-samplers.

This involved flattening a union that is internal to filamat.

* MaterialBuilder: Add Java bindings for precision.
2021-07-09 17:32:08 -07:00
Romain Guy
5a61d28eee Add Java bindings for transparent shadow (#4272)
* Add Java bindings for transparent shadow

* Fix JNI binding typo

* Fix typo
2021-07-08 12:50:18 -07:00
Romain Guy
9bd3684893 Add support for transparent shadows (#3298)
* Add support for transparent shadows

This solution uses an 8x8 Bayer matrix. We could find a better
noise. We also need better filtering of the shadow maps. A PCF
is barely enough and VSM fails without blurring.

* Use a fixed Bayer matrix, fix pre-caching of depth shaders

* Use gradient noise instead of fixed bayer pattern

* Update docs
2021-07-08 10:31:52 -07:00
Romain Guy
04ada346b0 Materials can now provide custom lighting/shading (#4142)
* Materials can now provide custom lighting/shading

When a material uses the "lit" shading model, customSurfaceShading can
be enabled to replace Filament's lighting implementation. When this
feature is enabled, the material *must* provide the following function
in the fragment shader block:

    vec3 surfaceShading(
            const MaterialInputs materialInputs,
            const ShadingData shadingData,
            const LightData lightData
    ) {
        return vec3(1.0); // custom lighting here
    }

Please refer to the docs in Materials.html for more information about
this feature and the different values provided by the data structures
passed to the function.

* Update docs

* Update docs/Materials.md.html

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

Co-authored-by: Philip Rideout <philiprideout@gmail.com>
2021-06-16 09:53:58 -07:00
Romain Guy
94ff2ea6b1 Add support for KHR_materials_specular to glTF (#4046)
* Add support for KHR_materials_specular to glTF

* Add support for IOR to ubershaders

* Update release notes

* Remove unused variable, fix comment
2021-05-27 17:33:24 -07:00
Mathias Agopian
036bfa9b20 Materials now have a quality property.
We used to have that before, but it was hardcoded and depended on
mobile vs. desktop.
With this change, users can set the quality on the material itself.
The default match the current settings. There are 3 quality levels:

low: enables optimization that might not be 100% correct 
     (e.g. abs(x) instead of sqrt(x*x))

normal: like low, but doesn't sacrifices correctness.

high: could be improved upsampling, etc...
2021-04-27 14:20:50 -07:00
Ben Doherty
03d74f1313 Update web docs, add note about shadowMultiplier (#3855) 2021-04-26 12:05:25 -07:00
Mathias Agopian
9914eb84a4 Fix documentation for getNormalizedViewportCoord
Fixes #3821
2021-04-23 22:39:01 -07:00
Romain Guy
4ad947f0ad Update docs 2021-02-12 10:54:54 -08:00
Romain Guy
9da69dac46 Update documentation 2021-02-09 10:43:49 -08:00
Ben Doherty
07ddd52dcf Add getVertexIndex API for vertex shaders (#3493) 2021-02-04 12:40:21 -08:00