There are now only 2 main commandTypeFlags, COLOR and DEPTH,
indicating if we need to generate respectively COLOR and DEPTH commands.
The command generation code, only has 3 implementations: DEPTH, COLOR and
DEPTH + COLOR.
We also add "options" flags that get passed along, used to control what
goes into the the depth pass -- this because sometimes we don't want
translucent or alpha masked objects. e.g. when rendering the shadow pass,
we want the DEPTH + shadow casters regardless of if they're translucent.
With this, we can fix a SSAO problem where alpha-masked objects where
not participating when the depth pre-pass was used. Now, we add those
objects to the DEPTH if SSAO is active and MSAA is not.
This adds some new functions to libimage for computing distance fields
and coordinate fields. This runs on the CPU but uses an efficient
algorithm. This will initially be leveraged by the baking pipeline to
dilate charts, but could be useful in other applications.
Filament references a few classes from native code and by reflections,
so when proguarding binaries we typically had to add an exception for
filament to make it run:
-keep class com.google.android.filament.** {*;}
In a compiled .dex file, the filament namespace takes about 120kb
(before compression), even if the classes aren't used.
To enable proguarding and stripping out unused filament classes,
introduce a UsedByNative and UsedByReflection annotation to explicitly
mark classes that need to be kept in the dex, so that the rest can be
potentially stripped out.
In my testing, this reduces the filament namespace in the .dex from
120kb->40kb, which translates to about 30kb apk size savings after
compression.
If A and B are equal keys, then hash(A) and hash(B) should be equal, but
xatlas was violating this constraint.
This bug was not present in Thekla's original code, it was introduced
later by the xatlas project.
Both SSAO and SAO are available, but currently only
SSAO can be used.
SAO is more correct and produces less "halos", but
SSAO is sometimes more pleasant.
Note that this doesn't implement all the SAO optimizations
yet.
* Add micro-shadowing based on ambient occlusion
* Prevent crash when IBL is turned off
* Apply micro-shadows to baked AO only
* Remove debug code
* Add opacity control
* Fix opacity term
* Switch to micro-shadowing from Chan 2018
The AO baking procedure consists of the following steps:
1. Flatten the glTF hierarchy.
2. Generate a single 2D parameterization for the entire scene.
3. Embree Pass 1: Create G-Buffer using the above UVs as vert positions.
4. Embree Pass 2: Cast rays from the positions embedded in the G-Buffer.
The `gltf_baker` tool is not ready for general use but already
produces reasonable results for certain well-formed models.
Normals reconstructed from derivatives at an edge are invalid and
Cause dark spots in the final AO. We try to detect this case and
Assume no AO, which could be wrong too, but looks better more often.
I don’t think it’ll have an impact on performance because the normals
for the whole quad should be wrong together.
AssetPipeline now has a path tracer and optionally uses embree. For now,
the path tracer only sends out visibility rays and generates a simple
hit-or-miss monochrome bitmap. It splits the render target into tiles
and invokes a JobSystem task for each tile.
Filament developers can optionally install embree using homebrew or a
debian package. This avoids bloating third_party and increasing our
build time. If embree is not installed, a friendly run-time error will
occur when attempting to invoke the rendering functionality in
AssetPipeline.
The AO code is not yet implemented, but this PR sets up the
infrastructure, API, and camera rays.
This feature consumes a flattened glTF asset and produces a glTF asset
with new topology and an additional set of UV coordinates suitable for
baking light maps.
I verified with a couple glTF models that the generated assets are
visually equivalent to the source assets, even though the topology and
scene hierarchy is different.
The actual light baking is not yet implemented, but this is a major step
towards that goal.