Commit Graph
1353 Commits
Author SHA1 Message Date
Philip Rideout d7778e29b0 Light maps are now dilated to remove seams. 2019-05-22 12:33:07 -07:00
Mathias Agopian 9388aab32e fix ssao issue and rework RenderPass commandTypeFlags
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.
2019-05-22 09:54:13 -07:00
Ben Doherty 6d3cbb8d32 Accept MSAA render targets in MetalBlitter (#1194) 2019-05-22 09:05:06 -07:00
Ben Doherty dd0e0840b8 Fix Metal error when sampler has not been bound (#1210) 2019-05-22 08:56:09 -07:00
Philip Rideout 5a5b6720b0 Add distance field generator to libimage.
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.
2019-05-21 20:21:41 -07:00
Romain Guy a4a26ef528 Update RELEASE_NOTES 2019-05-21 19:27:58 -07:00
Jeff McGlynn 9fe60a6368 Add proguard annotations for code used by native/reflection (#1207)
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.
2019-05-20 21:02:54 -07:00
Philip Rideout e2c3dfd341 xatlas: do not remove small faces 2019-05-20 19:37:37 -07:00
Philip Rideout 2687bf99d6 xatlas: fix crash caused by faulty spatial hash.
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.
2019-05-20 19:37:37 -07:00
Romain Guy 3d39f64c0d Move comment 2019-05-20 14:56:00 -07:00
Romain Guy 60bc860e76 Move IOR code to common_lighting 2019-05-20 14:54:44 -07:00
Romain Guy 2377287890 Fix curvatureToRoughnes 2019-05-20 14:50:44 -07:00
Romain Guy cabdc255f5 Shader code cleanup
roughness is now called perceptualRoughness and linearRoughness
is now called roughness. It better matches papers, etc.
2019-05-20 14:45:26 -07:00
Philip Rideout ac11e2b79a cgltf_writer: fix inconsistent buffer size.
`extension_flags` was uninitialized, which caused intermittent junk in
the output.
2019-05-20 13:23:47 -07:00
Philip Rideout 8f0fcc4efd xatlas: fix read-from-freed.
This fix has also been been submitted to the upstream repo.
2019-05-20 13:23:47 -07:00
Ben Doherty 399f7c24ac Fix flaky sstream test (#1205) 2019-05-20 13:09:03 -06:00
Philip Rideout fdefa16cae jsbindings: add setColor4Parameter and rename setColorParam.
JavaScript does not have overloading so we generally use a numeric
suffix to distinguish overloads.

Fixes #1202
2019-05-20 10:43:38 -07:00
Mathias Agopian 95b4cdf819 Fix SSAO and SAO on Mobile devices
The fragment shader didn't work because of the default mediump
precision for floats on mobile.
We had the highp precision qualifier where needed.
2019-05-19 23:25:28 -07:00
Mathias Agopian 517bfc54c5 Use SAO style ambient occlusion
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.
2019-05-19 23:25:28 -07:00
Pixelflinger e840e72755 improve depth test usage and tracking
We now disable the depth test entirely when possible. this should save
a few gl calls.
2019-05-19 23:24:45 -07:00
Philip Rideout 992e27c4e0 Update cgltf to fix unlit materials. 2019-05-18 20:43:31 -07:00
Philip Rideout cfb6a1c917 gltf_baker: add diagnostics. 2019-05-18 20:43:31 -07:00
Romain Guy 0347fb0441 Add new material properties: specular/multiBounceAmbientOcclusion (#1198) 2019-05-18 14:30:08 -07:00
Philip Rideout 24a77023bd Add AssetPipeline::bakeAllOutputs for diagnostic purposes. 2019-05-17 10:01:26 -07:00
Philip Rideout 07be9d1721 PathTracer: add bent normals and diagnostic targets. 2019-05-17 10:01:26 -07:00
Ben Doherty 88f6f4827c Allow creating and using MSAA textures as render targets (#1186) 2019-05-16 16:44:38 -07:00
Philip Rideout 9a72831a33 AssetPipeline can now preview baked texture. 2019-05-16 15:53:20 -07:00
Philip Rideout 59f929c7d3 Fix "already freed" bug in gltf_baker. 2019-05-16 15:53:20 -07:00
Romain Guy f0aab6e46a Add micro-shadowing feature (#1188)
* 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
2019-05-16 12:24:16 -07:00
Romain Guy 8d7d10ae81 Use 64x64 DFG LUT on mobile targets (#1191)
The size of the LUT is now configurable at build-time with
-DDFG_LUT_SIZE=XX. It is 128x128 on desktop, 64x64 on Android,
WebGL and iOS.
2019-05-16 11:35:49 -07:00
Philip Rideout c112b3ce40 Introduce AssetPipeline::SCALE_TO_UNIT to boost bake quality. 2019-05-15 16:44:33 -07:00
Philip Rideout affc947ce0 gltf_baker: improve error reporting. 2019-05-15 16:44:33 -07:00
Philip Rideout cbfb364c41 Introduce libs/rays and implement AO baking.
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.
2019-05-15 13:10:56 -07:00
Philip Rideout c84c60112e Implement the bake button, uses a "UV camera" to cast primary rays. 2019-05-15 13:10:56 -07:00
Romain Guy a9ef45dc9a Remember the high intensity for directional lights (#1184)
Fixes #1183
2019-05-14 09:02:09 -07:00
Romain Guy bdd3e343ba Add multi-bounce AO based on GTAO (#1180) 2019-05-14 08:58:49 -07:00
Philip Rideout cd364b029c gltf_baker: fix needless reload for rendering. 2019-05-13 18:55:56 -07:00
Philip Rideout 3e1ed97187 Add QUIET to find_package with embree, etc. 2019-05-13 18:55:37 -07:00
Ben Doherty daddc25de8 Remove std::sstream from filamat (#1176) 2019-05-13 13:56:15 -07:00
Philip Rideout 4237ff42c9 PathTracer now generates ambient occlusion.
For now this uses the geometric normals provided by embree rather than
the smooth normals that ship with the model, I will fix this next.
2019-05-13 10:25:12 -07:00
Philip Rideout 3291fb6a1b Introduce gltf_baker tool. 2019-05-13 10:25:12 -07:00
Philip Rideout f5b47dc95e PathTracer should not exceed MAX_JOB_COUNT. 2019-05-10 14:40:17 -07:00
Mathias Agopian 4f6d15d849 Try to handle “bad” normals
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.
2019-05-10 13:58:00 -07:00
Ben Doherty c35c1b6426 Fix Metal warnings (#1175) 2019-05-10 09:33:47 -07:00
Philip Rideout 80f6f18e54 Introduce gltfio::PathTracer and baking API.
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.
2019-05-10 08:04:09 -07:00
Romain Guy ac8f55099d Indent SSAO options 2019-05-09 17:18:37 -07:00
Adrian Perez 3987da830c Fix -Wconversion issue in public header (#1172) 2019-05-09 17:00:34 -07:00
Mathias Agopian cbae6120e1 Ambient Occlusion APIs are more descriptive
Use “AmbientOcclusion” instead of SSAO in all APIs.
2019-05-09 16:36:18 -07:00
Mathias Agopian 011daa952e Add API for controlling SSAO 2019-05-09 16:36:18 -07:00
Philip Rideout cb98b75400 Implement AssetPipeline::parameterize() using xatlas. (#1167)
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.
2019-05-09 14:09:27 -07:00