* validate MaterialInstance references when destroyed With this change we now enforce two things: - All MaterialInstance of a Material must be destroyed when destroying said Material. This has always been a documented requirement of the public API, but wasn't enforced (only a warning was printed). This new assertion is unconditional. - A MaterialInstance, when destroyed is no longer in use by any Renderable. So before destroying a MaterialInstance, the user of API needs to ensure that either all Renderable using that MaterialInstance in one of their Render Primitives are destroyed, or, that these Renderable using that MaterialInstance are reset to another one or to null. There is a new RenderableManager::clearMaterialInstanceAt() that can be used to clear a MaterialInstance on a Render Primitive. Additionally, a Render Primitive with a null MaterialInstance is now silently skipped during rendering, instead of a null-dereference. Finally, that second assert is protected by a new feature flag: "features.engine.debug.assert_material_instance_in_use". This flag is enabled on DEBUG builds and disabled on RELEASE builds by default. The flag can be changed at any time using `Engine::setFeatureFlag()`. BUGS=[333907416] * Update filament/src/components/RenderableManager.cpp Co-authored-by: Powei Feng <powei@google.com> --------- Co-authored-by: Powei Feng <powei@google.com>
IBL Prefilter
This library can be used to generate the reflections texture used by filament's IndirectLight
class. It is similar to the cmgen tool except that all computations are performed on the GPU and
are therefore significantly faster. cmgen however offers more functionalities.
IBL Prefilter is designed entirely as a client of filament, that is, it only uses filament
public APIs.
Library and headers
The library is called libfilament-iblprefilter.a and its public headers can be found in
<filament-iblprefilter/*.h>.
Performance
Expect a total processing time of about 100ms to 300ms for a 5-levels 256 x 256 cubemap with 1024 samples.
Example
#include <filament/Engine.h>
#include <filament-iblprefilter/IBLPrefilterContext.h>
using namespace filament;
Engine* engine = Engine::create();
// create an IBLPrefilterContext, keep it around if several cubemap will be processed.
IBLPrefilterContext context(engine);
// create the specular (reflections) filter. This operation generates the kernel, so it's important
// to keep it around if it will be reused for several cubemaps.
IBLPrefilterContext::SpecularFilter filter(context);
// launch the heaver computation. Expect 100-100ms on the GPU.
Texture* texture = filter(environment_cubemap);
IndirectLight* indirectLight = IndirectLight::Builder()
.reflections(texture)
.build(engine);