Files
filament/libs/iblprefilter
Mathias Agopian 2709533fb1 Fix texture coordinate calculations in post-process materials
The most important change here is that we no longer apply the
backend (e.g. Metal/Vulkan) UV transformation before calling the
user's vertex shader. This is an API change for post-process materials
(but they're not public).
Now the user is responsible for using uvToRenderTargetUV() in their
shaders (either in the fragment or vertex as appropriate).

This makes it easier to handle offsets/transforms with all APIs.

Conceptually, the only thing that is needed is to call 
uvToRenderTargetUV() just before making a texture call.


This fixes a couple of issues:
- some image shifting in metal/vk
- flare in metal/vk was upside down

We also simplify the DoF code quite a bit now that we can rely on the
rendertargets begin multiple of 16.

We also "fix" SSAO that was working by accident on  metal/vk. The UV
correction was applied 3 times 2 of which were canceling each other.
2022-05-12 13:42:13 -07:00
..
2021-04-26 12:17:42 -07:00

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);