Commit Graph

300 Commits

Author SHA1 Message Date
Philip Rideout
e4b60e47cb Introduce KtxBundle to libimage and add unit test.
KtxBundle is basically an in-memory representation of a KTX file.
Our primary motivation for introducing this class is to have a
structured container for block-compressed textures.

Note that this class is defined in libimage rather than libimageio.
There are several reasons for this:

1. The texel data in a KtxBundle is not meant to be decoded by the CPU.
2. It has no dependendencies on any libraries (stb_image tinyexr etc).
3. We wish to use it with WebGL, which needs to avoid using imageio.
2018-09-14 16:55:05 -07:00
Romain Guy
c1793b09bc Use slightly optimized Schlick on mobile 2018-09-14 09:50:18 -07:00
Romain Guy
96d3846571 Fix Schlick Fresnel when f90 < 1 2018-09-14 09:44:34 -07:00
Romain Guy
41d70cb30a Fix anisotropy BRDF on mobile (#245)
mediump computations are not enough for certain roughness values.
2018-09-13 18:31:08 -07:00
Ben Doherty
3e6f1a2c39 Tungsten: add orbit cam manipulator (#244)
* Add orbit cam to Tungsten

* Add kotlin-math library

* Flip mouse wheel event sign if coming from a physical wheel
2018-09-13 17:30:33 -07:00
Mathias Agopian
ea91002412 improve cmgen comments about IBL (#243)
* better comments on calculating the DFG lookup tables

* add comments about computing the “LD” term

* add comments about computing IBL diffuse pre-integration

* be clearer about the determinant of the jacobian
2018-09-13 15:12:45 -07:00
Ben Doherty
a2b304def9 Update comment in Variant.h (#242)
Update comment so the labels match the description
2018-09-13 11:11:52 -07:00
Philip Rideout
4694a9a160 Invoke find_library for Vulkan only on macOS. 2018-09-13 08:07:55 -07:00
Philip Rideout
0ff40948dc Allow macOS developers to optionally use an SDK version of Vulkan.
This looks for VULKAN_SDK at build time, and if present it tells
Filament to use the `libvulkan.1.dylib` that's located there. Otherwise
it falls back to our old loading strategy, which uses a bundled version
of MoltenVK that allows us to avoid requiring installation of the
LunarG SDK.

I tried this out an it works for me...

Closes issue #238.
2018-09-13 08:07:55 -07:00
Ben Doherty
6ab36e9365 Fix, flip components not working (#239) 2018-09-12 17:29:40 -07:00
Romain Guy
735d7fedf7 Cleanup comments 2018-09-12 13:49:31 -07:00
Mathias Agopian
01a4f563e7 more important sampling fixes
- compute dot(n,l) correctly
- don’t rely on the provided tangent space for
  now because some meshes have a broken TBN
2018-09-12 13:30:34 -07:00
Mathias Agopian
cd058d36f3 use LoH instead of VoH (they’re equal) 2018-09-12 13:30:34 -07:00
Mathias Agopian
fd8c2b1874 compute the clear coat layer with importance sampling 2018-09-12 13:30:34 -07:00
Mathias Agopian
b0f6cf037d address more comments
- pass the tangent space to the importance sampling
- reorder parameters
2018-09-12 13:30:34 -07:00
Pixelflinger
b9bcf41e74 fix most romain@ comments 2018-09-12 13:30:34 -07:00
Mathias Agopian
5f1bdb0677 importance sampling option for IBL
This will be useful for testing and can be
enabled at compile time by setting
IBL_INTEGRATION to IBL_INTEGRATION_IMPORTANCE_SAMPLING
in *both* indirectLight.cpp and light_indirect.fs

BUGS: clearcoat and subsurface won’t
work well when this is enabled since the prefiltered
cubemap is not available and, we don’t evaluate
those lobes with importance sampling (yet).
Additionally, anisotropy can’t work with our
prefiltered importance sampling, so it still uses
the emulation by bending the normal.
2018-09-12 13:30:34 -07:00
Philip Rideout
12d3b06622 High-to-Low includes, per our style guidelines. 2018-09-12 10:43:41 -07:00
Ben Doherty
d0be29fb34 Tungsten: introduce texture sample node (#230)
* Tungsten: introduce texture sample node

* Add uv input to texture sample node

* Only flip components if specified in reverse order
2018-09-12 10:37:03 -07:00
Philip Rideout
ef134f5304 Users can now spin the model in web sandbox. 2018-09-11 13:58:38 -07:00
Philip Rideout
31a3044d51 Fix minor HTML build issue. 2018-09-11 13:57:09 -07:00
Philip Rideout
f84d74378f Ignore non-primary touch events. 2018-09-11 13:25:05 -07:00
Philip Rideout
750b15830f Add new demo for WebGL called "sandbox".
This adds a new demo that leverages ImGui. It looks very similar to the
existing material_sandbox demo we have for desktop, with a few
differences:

    1. Does not use FilamentApp.
    2. Does not draw a shadow plane.
    3. Does not use a TrueType font in ImGui. (improves load time)
    4. Does not allow the user to spin the model. (will fix soon)

We now have a triumvirate of web demos with a progression in complexity:

    1. triangle
    2. suzanne
    3. sandbox

This is a sufficient set of WebGL samples for now, at least until we
finish creating a proper JavaScript API.

This CL factors out some of the common code with the native sandbox
demo, but keeps the UI definition separate since the web demo has some
minor differences (e.g., there is no shadow plane yet).

Note that using viewport units for height was wrong; it caused a bad
aspect ratio on Android while the URL bar was visible. This is explained
in an article:

https://developers.google.com/web/updates/2016/12/url-bar-resizing
2018-09-11 13:25:05 -07:00
Pixelflinger
1db1426260 fix cmgen unit test 2018-09-11 01:09:22 -07:00
Mathias Agopian
4475cbaf2e fold the lambert brdf into the SH coefs
this saves one multiply in the shader, but most
importantly makes the first SH coefficient a
color and reduces its range

ALL IBLs NEED TO BE REGENERATED using cmgen
2018-09-10 21:09:11 -07:00
Romain Guy
7ada9b6470 Kotlinify our Kotlin code (#233) 2018-09-10 18:33:14 -07:00
Philip Rideout
bd8ddbc0df Reflection maps must be 256x256.
This makes the web samples comply with the size requirement in
`filament/src/IndirectLight.cpp`.
2018-09-10 15:53:10 -07:00
Philip Rideout
6aaa1dc628 WebGL: support touch screens. (#229) 2018-09-10 11:35:20 -07:00
Romain Guy
cc102be69f Fix docs typo
Closes #228
2018-09-10 10:19:16 -07:00
Philip Rideout
c8948be59e Hook up mouse events for web. (#227) 2018-09-07 19:15:52 -07:00
Romain Guy
e0de488a0e Update Windows build instructions 2018-09-07 16:02:08 -07:00
Mathias Agopian
abae178ddc cmgen: option to generate the diffuse irradiance
-—ibl-irradiance generates the diffuse irradiance as
a cubemap using importance sampling. 
It can be used in place of the SH version (—-sh-irradiance)
which sometimes presents some ringing artifacts.
2018-09-07 14:31:44 -07:00
Mathias Agopian
f75f19edd0 save debug files in .HDR format instead of .PNG 2018-09-07 14:31:44 -07:00
Philip Rideout
d4cb898dfe Prep for using imgui with WebGL. (#225) 2018-09-07 13:19:35 -07:00
Philip Rideout
e22b82e4e0 WebGL samples should pass free callback to BufferDescriptor. (#224)
Unfortunately the trick of passing the address to stdlib "free" causes
a crash in WebGL, so we need to wrap these in lambda.
2018-09-07 10:33:13 -07:00
Philip Rideout
d9dd791561 Huge speed up for WebGL debug builds. (#223)
The WebGL build invokes cmgen for samples, which takes several minutes
in debug configuration. Let's use a release build for the host tools,
regardless of the build configuration for the target architecture.
2018-09-07 10:12:34 -07:00
Mathias Agopian
d3a470319c fix #201 Division by zero in FScene::computeLightRanges (#217)
SIMD code is accessing uninitialized elements,
so make sure they are initialized enough to avoid
divide-by-zero.

We were also processing the directional light in
computeLightRanges(), which always has a zero
radius.
2018-09-06 20:43:00 -07:00
Mathias Agopian
ad18b6ea39 fix divide-by-zero in cmgen (#201) (#218)
We were doing a divide-by-zero in a case where
the result wasn’t used.
2018-09-06 20:42:45 -07:00
Philip Rideout
90790d233b Fix bad skybox color in web demo. (#221)
In a previous CL today, I changed the skybox to RGBM but forgot to
change the format. Thanks Romain for catching this.
2018-09-06 19:45:46 -07:00
Ben Doherty
069b4d1180 Tungsten: improvements to shader node (#216)
* Add StringValue and Choice

* Add editorFactory to nodes

* Update graph model when compiling

* Extract compileNode function

* Change inputs based on shadingModel

* Allow nodes to set shading model

* Fix float literals with dimension 1

* Adjust node height for slots

* Improvements to shader node

* Don't ever set a default value

* Add anisotropy and anisotropyDirection
2018-09-06 17:20:55 -07:00
Romain Guy
71a88228e2 Update web badge 2018-09-06 16:12:03 -07:00
Romain Guy
193cfb0fdd Change web badge icon 2018-09-06 16:06:53 -07:00
Romain Guy
d31076e558 Add Web build badge 2018-09-06 15:56:54 -07:00
Philip Rideout
3dc75c09f1 Fix continuous web builds by skipping unit tests. (#219)
We do not build unit tests for the web build, so we should skip them.
2018-09-06 15:50:47 -07:00
Philip Rideout
837e01e5a9 Prep for WebGL on Kokoro. (#215)
This adds an archive step to `build.sh` and adds `build/web`.

The archive is a tgz that contains the contents of `public`, which only consists of the files needed for a simple static web server.

The files in `build/web` are almost identical to the mac build, except that they use the `/web/` path and install the emscripten SDK.
2018-09-06 14:30:25 -07:00
Philip Rideout
7b36ed4638 WebGL demos now decode PNG in C. (#214)
This removes the trick of drawing to a 2D canvas. It was corrupting the
alpha in RGBM images, which caused subtle banding in the Suzanne
reflection. Moreover it added complexity to the demo code.

This commit will increase the pre-zipped WASM size by 17k, but I think
it's worth it.

This also removes one of the cmgen passes in the WebGL build; we were
using PNG instead of RGBM for the skybox to work around the banding
issue that this fixes.
2018-09-06 13:48:22 -07:00
Philip Rideout
db79bc9729 Fix !! typo. (#213) 2018-09-06 11:04:39 -07:00
Philip Rideout
f1324adc7a Work around Firefox by avoiding InvalidateFramebuffer. (#212) 2018-09-06 09:17:20 -07:00
Philip Rideout
9b17472d67 WebGL: use an opaque canvas and legal HTML. (#211)
Some browsers complain about missing charset metadata etc, so this makes
our HTML samples a bit more legit.

Also, using an opaque canvas improves performance and makes it easier to
diagnose bugs.
2018-09-05 17:18:41 -07:00
Romain Guy
f550fbaa44 Skip lighting and shadowing computations when possible (#210) 2018-09-05 16:04:38 -07:00