Commit Graph

1371 Commits

Author SHA1 Message Date
Philip Rideout
5bdbf63ff6 gltf_baker now has an export modal. 2019-05-24 14:59:10 -07:00
Mathias Agopian
d3753ca463 fix framegraph test 2019-05-24 11:10:18 -07:00
Mathias Agopian
ca20ae3851 handle levels of textures in the framegraph
- it's now possible to use a level of a texture as an attachment of
  a rendertarget in the framegraph, by simply setting the desired level
  when specifying an attachment.

- for now, removed the (never used) feature where the framegraph could
  resize a resource under-the-hood.

- when requesting the physical renderder target by calling
  getRenderTarget(), we now must specify the same level that was used
  when the rendertarget was created. This is not ideal, and we hope
  to fix that in the future, but it'll require some serious internal
  changes (and maybe API changes)
2019-05-24 10:22:23 -07:00
Mathias Agopian
ea6d8dd212 Simplify useRenderTarget() helper and update accesses
- useRenderTarget() has a helper for simple cases, make it even more
easy to use. It assumes a single color attachment w/ WRITE access,
which is a common case.

- update all useRenderTarget() access flags
2019-05-24 10:22:23 -07:00
Mathias Agopian
92dfeb63dc Fix wrong assert in createRenderTarget()
- we were not taking the attachment's level into account.
2019-05-24 10:22:23 -07:00
Ben Doherty
68d6b5718e Unbind textures / sampler groups in Metal backend when destroyed, add SSAO workaround (#1222) 2019-05-24 09:14:25 -07:00
Philip Rideout
8f1d4ffa4d gltf_baker now parameterizes in a background thread. 2019-05-23 22:06:43 -07:00
Philip Rideout
3b2d75e129 gltf_baker now has adjustable resolution. 2019-05-23 22:06:43 -07:00
Mathias Agopian
2d2be0a214 update min/max LOD when using a texture as attachment
This fixes a problem where the min lod of a texture would be set
incorrectly when first drawing into the base level (common case) and
then creating a mipmap chain from it using blits.
Because drawing into the texture doesn't set the base level, after the
blit, the min level would be set to 1 instead of 0.

In fact, there was no way to set the level of a texture by drawing into
it, the only ways were by blitting or uploading data.


This change updates the min/max LOD when a texture level is attached to 
a rendertarget, regardless of whether we read or write -- assuming that
we will write to it. The problem is that at that stage we don't know
if we will read or write. That said, if the user attaches an uninitialized
level to read from it, who cares what really happens
2019-05-23 21:47:05 -07:00
Mathias Agopian
1716f9e7cd fix our ostream << hex << char
Even when hex modifier is used, 'char' should be printed as characters,
this is particularly relevant with 0.
e.g. out << (char)0, should write a nul terminator, not "0".
2019-05-23 21:46:28 -07:00
Mathias Agopian
da0d94caf2 promote uint8_t (i.e. uchar) to printable ints
An easy way to do this is to prepend a "+" to the variable.
2019-05-23 21:46:03 -07:00
Pixelflinger
1b41ef78cd Use depth culling when computing SSAO
Since we have a depth buffer, we might as well use it for depth-culling,
this automatically discards the skybox's fragments -- which we can
assume won't participate in SSAO.
2019-05-23 16:35:16 -07:00
Mathias Agopian
83c523256d fix debug builds 2019-05-23 13:09:11 -07:00
Pixelflinger
507aeb1e34 ssao is now done in quarter resolution
- this means that we cannot share the depth pass between ssao and color
passes, so all this code is removed, which simplify things a lot.

- the depth pass code is moved into the ssao codepath since they're now
intimately linked.

- and finals ssao shader can't rely on frameUniform which is set up with
the main buffer's size (instead of 1/4 res).
2019-05-23 12:59:22 -07:00
Romain Guy
43115e1f3b Update release notes 2019-05-23 12:56:56 -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
Ben Doherty
af559a1344 Use correct iPhone SDK availability flag, remove iOS OpenGL warnings (#1214) 2019-05-23 10:48:43 -07:00
Pixelflinger
0f69dbb0cf FrameGraph RenderTarget can now control how they're accessed
It's now possible to set if a render target's attachment is accessed
for read and/or write -- instead of always being hardcoded to both.

We just add an "access" field to Attachment, which is still set to
RW by default, but can be set in useRenderTarget(). 

The access mode only affects building the graph -- in the end it's just
a regular render target.
2019-05-22 18:40:52 -07:00
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