Commit Graph

40 Commits

Author SHA1 Message Date
rafadevai
9da29e3ab7 Add new public API to query a sampler transform name field. (#9320)
* Add new public API to query a sampler transform name field.

This new API will let filament users query a Material object
the value of the `transformName` field of a specified sampler
parameter.

The transformName is an optional field, so if its not defined
by the user, it will return a nullptr value.

- A new test was added to test_filamat to validate the serialization.
- A new parameter was added to the test sandboxLit material to
validate the parsing a material with the new field.

* Addressing review comments

- Add java and js bindings for the new API
- Tests for querying the getParameterTransformName

* Use utils::ImmutableCString for transformName

* Updating release notes

* Review comments

* Addressing more review comments

- Fix comments
- For the java binding return an empty string when the
transform is not present.
2025-10-21 23:55:25 +00:00
Sungun Park
09545690bf Revert "materials: introduce mutable spec constants (#8795)"
This reverts commit 8a1a0b0fd2.
2025-06-13 15:02:55 -07:00
Eliza
8a1a0b0fd2 materials: introduce mutable spec constants (#8795)
* materials: introduce mutable spec constants

Rationale & design of this feature has been discussed internally.

The current implementation uses a `FixedCapacityVector` to store the new program
handles, but I wouldn't object to replacing it with a hasmap as discussed
offline.

I have compiled but not tested this yet on Android, so I'm not certain that the
API bindings are correctly wired up.

* materials: mutable spec constant feedback

* materials: address mutable spec constant comments
2025-06-06 03:52:20 +00:00
Sungun Park
37c615e249 Support multi-layered render target (#8108)
Clients can create a multi-layered render target that consists of array
textures, and use it as a custom render target.

A new sample app "hellostereo" demonstrates how to use this feature.
2024-09-09 20:27:58 +00:00
Eliza Velasquez
56355231bd Allow explicitly initializing at feature level 0
This change does three main things. First, it adds an option to the Engine
Builder to pick the feature level at which to instantiate Filament. The only
real practical purpose of allowing this is to be able to instantiate at feature
level 0. Secondly, it allows feature level 0 to properly work on non-ES2
devices. Thirdly, it changes both Android and desktop hellotriangle samples to
explicitly opt-in to feature level 0.

Unfortunately, feature levels are used in two different, somewhat contradictory
ways presently in Filament, which can make reasoning about this change a bit
confusing. From a client perspective, feature levels refer to buckets of
capabilities which are guaranteed to be supported. Internally, there is a
separate "feature level" stored internally at the Driver subclass level which
generally corresponds to the maximum supported feature level, but is also
referenced when activating workarounds for limited devices. For example, Uniform
Buffer Objects are not supported in ES2, however, Filament supports emulating
them such that the client does not need to care at all; a supported feature is a
supported feature. But internally, Filament uses this "Driver" feature level to
determine whether or not a given workaround is needed. There were several cases
where the "active feature level" was being examined in order to activate these
workarounds rather than the "driver feature level", which was incorrect.

Why should non-ES2-only devices want to activate feature level 0? Allowing this
behavior 1. makes feature level 0 more consistent with the behavior of other
feature levels and 2. allows clients a layer of validation that their software
will work on all devices supported by Filament if they explicitly opt into it.

Consistency: Filament guarantees that any given device which supports a given
feature level will also support running on every feature level below, except for
feature level 0. This change removes that exception.

Validation: It's not perfect, and there will likely be bugs and unexpected
differences in behavior between ES2 and non-ES2 devices that crop up in the
future between two devices running on the same feature level. However, it's at
least a basic high level layer of validation that enables more rapid testing
workflows directly via desktop versions of Filament rather than having to fiddle
with something like ANGLE to get perfect GLES 2.0 compliance. Additionally, it
expands options for automated testing (with the same caveats).

This change has been tested on both the desktop and Android versions of
hellotriangle.
2023-10-26 22:20:57 +00:00
Ben Doherty
4e15b7abc2 Add overdraw visualization to gltf_viewer (#6018) 2022-09-02 12:33:26 -04:00
Romain Guy
719427764c Fix image_viewer (#5571)
Many EXR files may contain negative values, we don't want to output
those to our color buffer.
2022-05-17 19:59:41 -07:00
Romain Guy
4d88ff116c Improve image_viewer compatibility (#4459)
- Images with an alpha channel are now properly supported. Blending is implemented directly in the image material by blending against the known opaque background color.
- Non-EXR/HDR images were not applying the proper transfer function and were therefore displayed incorrectly.
2021-08-05 16:27:19 -07:00
Romain Guy
505cb39e1c Improvements to image_viewer (#4305)
Image loading errors are handled more gracefully by showing a
background color.

Added UI to set the background color.

Replaced fragment discards with solid background color.
2021-07-13 11:24:13 -07:00
Romain Guy
127dd8f675 Add new sample app: image_viewer (#4301)
* Add new sample app: image_viewer

This app shows how to load and visualize images. It's also useful to work
on color grading and other post-processing effects by just loading an HDR
or EXR image as a reference.

This change also adds a new exposure setting to the color grading LUT.

* Fix comments and build

* Fix Metal

* Use high precision for the UV coordinates

* Fix refactoring issue
2021-07-13 10:07:42 -07:00
Philip Rideout
0e27f0c162 RenderTarget demo now disables post-processing in offscreen view.
The color now match up perfectly.  Woops.

(#3402)
2021-02-05 11:21:06 -08:00
Philip Rideout
2d57a82b49 Add simple RenderTarget demo (planar reflection)
When we removed the old "ghetto bloom" demo, we ceased to have any
samples demonstrating the RenderTarget API. This demo is a fairly simple
demonstration of planar reflection.
2021-01-14 16:27:18 -08:00
Romain Guy
2895530e09 Add support for sheenColor and sheenRoughness (#3358)
* Add support for sheenColor and sheenRoughness

This work is necessary to support the glTF extension KHR_materials_sheen.
This change effectively adds the specular lobe from the cloth material
model to the base material model. The cloth model remains useful for
its extra subsurface color feature but also because it's cheaper.

* Add support for KHR_materials_sheen to gltfio

* Update documentation

* Document default shading values
2020-12-12 11:07:40 -08:00
Romain Guy
97e8035b40 Give materials unique names 2020-07-14 15:57:56 -07:00
Philip Rideout
37e2f46e10 Move FilamentApp into libs/filamentapp.
This will make it easier to migrate gltf_viewer into tools.

This is not a rewrite of FilamentApp, just a baby step.
2020-04-03 16:28:38 -07:00
Romain Guy
00629bac48 Add camera controls to gltf_viewer (#2188)
Exposure: shutter speed, aperture and ISO
Focal length

The shadow plane can now be toggled  at runtime.
2020-02-28 23:46:17 -08:00
Romain Guy
108dae11e9 Add ground shadow option to gltf_viewer (#2174)
* Add ground shadow option to gltf_viewer

The shadow is always positioned at the bottom of the loaded object's
bounding box to ground it perfectly.

* Remove unused include
2020-02-26 17:09:31 -08:00
Romain Guy
88dd32b1a7 Add emissive to material_sandbox 2020-02-06 16:20:22 -08:00
Mathias Agopian
f290742f1b Screen-space refraction
With this PR screen-space refraction is functional.

Caveats:

The blur passes for supporting rough refractive materials is quite
heavy and increases with the resolution.

SSR uses a gaussian approximation for the brdf and therefore doesn’t
match perfectly cubemap-based refraction and IBL.

The use of MSAA with screen-space effects, while working, is going
to incur a large cost, especially on tilers.
2020-01-29 10:17:08 -08:00
Ben Doherty
8dbb4c6b7e Add new heightfield sample (#2004) 2020-01-08 11:55:28 -08:00
Romain Guy
3fa0c2d18b Add refraction to material_sandbox 2019-12-10 09:51:54 -08:00
Romain Guy
ec403f8940 Fix material_sandbox 2019-12-09 13:37:09 -08:00
Mathias Agopian
cbb5d2b423 fix typos and rename refraction to refractionMode 2019-12-08 22:18:18 -08:00
Mathias Agopian
4790cb5009 Allow materials to override the IOR
Normally the IOR is deduced from the reflectance, but now we allow to
specify the IOR instead or in addition to the reflectance.
In the later case, it's possible to create physically impossible
materials, but this can be useful for artistic reasons.
2019-12-08 22:18:18 -08:00
Mathias Agopian
f670472e55 implement thin layers 2019-12-08 22:18:18 -08:00
Mathias Agopian
179bf03caf implement absorption 2019-12-08 22:18:18 -08:00
Pixelflinger
0371a805ed basic refraction 2019-12-08 22:18:18 -08:00
Philip Rideout
41e5bb4f78 Add demo for point sprites and custom attribs. 2019-07-11 14:59:16 -07:00
Philip Rideout
ce4a3edf7b gltf_baker: visualizers now use fp32 textures.
This allows us to skip the CPU-side vector-to-color conversion that
occured at the end, and makes the real-time visualization consistent
with the final visualization.
2019-06-03 13:03:14 -07:00
Philip Rideout
78ec315b69 Overhaul the gltf_baker UI.
As per the design doc, this makes the app somewhat usable by eliminating
hardcoded filenames, the hidden state machine, etc.
2019-06-03 08:32:48 -07:00
Romain Guy
0a5c068cb6 Switch specular AA to Tokuyoshi and Kaplanyan (#1218)
This replaces the previous "curvature to roughness" method. Both are related
and rely on the screen space variance of geometric normals but this new
solution offers more control (the screen space variance and the clamping
threshold can be controlled).
2019-05-23 12:56:26 -07:00
Philip Rideout
3291fb6a1b Introduce gltf_baker tool. 2019-05-13 10:25:12 -07:00
Philip Rideout
90c5af3b0e Add specular-glossiness to material_sandbox. (#1095) 2019-04-12 09:40:03 -07:00
Romain Guy
ab12d1d1bb Add postLightingColor property to materials (#1057)
* Add postLightingColor property to materials

This property can be used to modify the color computed in the lighting
passes of the materials. That color is blended with the computed color
according to the postLightingBlending option (add, transparent or opaque).

* Remove test

* Update docs

* Address code review comment

* Switch postLightingColor default blend mode to transparent
2019-03-29 10:02:07 -07:00
magicwhale
b902a90285 Changed MeshAssimp to dynamically generate materials with filamat (#563) 2018-12-03 10:15:47 -08:00
magicwhale
fc0d587b40 Added support for more features in gltf_viewer sample 2018-11-19 09:27:08 -08:00
magicwhale
bc38c8a773 Edited MeshAssimp and added gltf_viewer sample code 2018-11-19 09:27:08 -08:00
Ben Doherty
f965b02b1b Fix, normal must be set prior to prepareMaterial (#273) 2018-09-19 13:37:24 -07:00
Philip Rideout
db2e1426e9 Introduce two WebGL samples: triangle and suzanne. (#170)
* Introduce two WebGL samples: triangle and suzanne.

This commit has no effect on mobile / desktop builds, it only adds new
targets to the `-p webgl` build.

We will eventually expose a proper JavaScript API, but for now these
samples use a (somewhat under-engineered) `filaweb` framework whereby
the WebAssembly module exposes a small number of C entry points: launch,
render, and resize.

Each sample has two source files: a cpp file and an html file. The cpp
file generates js / wasm pair.  The generated js is simply a loader for
the wasm.

The CMake script creates a pristine "public" folder which contains the
minimal set of files needed to serve the web application using a simple
static file server. The public folder like this:

    /suzanne.js         built by em++ from suzanne.cpp
    /suzanne.wasm       built by em++ from suzanne.cpp
    /suzanne.html       copied from REPO/samples/web
    /filaweb.js         copied from REPO/samples/web
    /favicon.png        copied from REPO/samples/web
    /monkey/*.png       copied from REPO/assets/models
    /monkey/*.filamesh  built by filamesh
    /desert/*           built by cmgen

To decode PNG textures, we use the somewhat unusual approach of using
JavaScript to draw them into a hidden 2D canvas, then reading back the
pixels. This allows us to avoid fattening up the wasm file with a PNG
decoder. An alternative idea would be to pass a DOM Image directly into
glTexImage2D, but this would require some #ifdefing and/or JS injection
in Filament's OpenGL backend.

* Optimize the suzanne material.
2018-08-28 11:09:06 -07:00
Romain Guy
b3d758f3b3 Initial commit 2018-08-03 10:38:22 -07:00