Commit Graph

79 Commits

Author SHA1 Message Date
Philip Rideout
b3dce967eb Rollback MeshAssimp enhancements.
This caused regressions with some of our samples like vk_hellopbr:

- For the new 1x1 textures, RGB isn't accepted by Vulkan and Metal.
  Currently these platforms require RGBA, although we plan on adding
  reshaping functionality for the future.
- Too many texture samplers in a single shader, this causes a run time
  error. This could be alleviated by creating an atlas.
- vk_hellopbr assumes that all materials have a "metallic" param.

Going forward, we plan on creating a new library that avoids MeshAssimp,
so for now let's just disable gltf_viewer.
2018-11-19 14:18:12 -08:00
Philip Rideout
1413b4d622 Fix path in vk_texturedquad 2018-11-19 14:17:13 -08:00
magicwhale
fc0d587b40 Added support for more features in gltf_viewer sample 2018-11-19 09:27:08 -08:00
magicwhale
1d392d38bd updated assimp 2018-11-19 09:27:08 -08:00
magicwhale
bc38c8a773 Edited MeshAssimp and added gltf_viewer sample code 2018-11-19 09:27:08 -08:00
Philip Rideout
a42dcd2291 JavaScript code re-org (#443)
This removes the old CPP-based web samples in favor of the new JS API.

The `web/samples` folder will be added in a subsequent commit.
2018-11-01 17:05:30 -07:00
Philip Rideout
9e5f44bd34 Consolidate two filamesh readers into a lib. 2018-10-16 13:31:16 -07:00
Philip Rideout
2a10f8122d Remove STB from web samples.
Every texture now uses KTX, so there is no need to fatten the WASM with
a PNG decoder.
2018-10-11 11:34:05 -07:00
Philip Rideout
182d95c6ce Use filamat file instead of inc in a web sample.
For test coverage, ensure that one of our C++ based web samples
uses a filamat file instead of inc, because this is how the JS based
web samples will work.

This makes pre-zipped triangle wasm go from 747 KB to 741 KB.
2018-10-11 10:22:48 -07:00
Philip Rideout
ed76aa04ca Shrink WASM files 30% by excluding VK materials. 2018-10-11 09:43:21 -07:00
Philip Rideout
10a3addf1a Filaweb now uses compression for the IBL.
The web build now invokes cmgen three times for each IBL: uncompressed,
S3TC (desktop), and ETC (mobile). Alternatively, we could enhance cmgen
to accept multiple compression strings, but per discussion with Mathias
we decided to keep it simple.

I decided not to use compression for the skybox in our web demos because
the quality is too poor (see PR image). I did not try playing with
compression settings, might be worth revisiting in the future.
2018-10-10 12:09:25 -07:00
Philip Rideout
c6cef9ff9c NEW API: add RGBM flag to Texture.
This change will allow the skybox use a compressed texture format.

For now, the old internal format "RGBM" is still honored, but in a
forthcoming change we will replace the enum with UNUSED.
2018-10-08 11:33:06 -07:00
Mathias Agopian
2c4ecebf11 Minor importance sampling tweaks and code clean-up (#342)
* cleanup importance sampling code

* Add VNDF importance sampling -- work in progress.

* minor code cleanup
2018-10-04 15:21:34 -07:00
Philip Rideout
551fe7ef8b Suzanne now uses LINEAR_MIPMAP_LINEAR. 2018-10-04 08:02:53 -07:00
Philip Rideout
37a42ee854 Enable ETC for Suzanne normal map.
Due to an assertion in etc2comp, this unfortunately uses RGB8 instead of
RG11 but it still helps quite a bit (3.3 MB savings in the unzipped KTX
size).
2018-10-03 12:35:34 -07:00
Philip Rideout
cc61e4649b Add ETC support to mipgen / imageio / suzanne.
This shrinks file size as follows, although it seems to darken the
rendered result.

```
  1398209 Oct  2 16:22 ao.ktx
   699172 Oct  2 16:20 ao_etc.ktx
  1398209 Oct  2 16:22 metallic.ktx
   699172 Oct  2 16:19 metallic_etc.ktx
  1398209 Oct  2 16:22 roughness.ktx
   699172 Oct  2 16:20 roughness_etc.ktx
```
2018-10-02 21:57:22 -07:00
Philip Rideout
3ad0574878 Add ASTC support to Suzanne. 2018-10-02 07:46:51 -07:00
Philip Rideout
3185d0f237 Add S3TC support to imageio and Suzanne.
At build time, mipgen now creates several compressed and non-compressed
variants for albedo.

For ASTC we use the ARM encoder, for S3TC we use the STB encoder. The
latter is somewhat limited so we may wish to investigate other libraries
in the future (e.g., AMD Compressenator).

At run time, we detect which of these variants to download, based on
available WebGL extensions. In practice, this means that desktop
browsers will use the S3TC variant and mobile browsers will use the ASTC
variant.

The makes unzipped albedo go from ~4 MB to 682 KB using S3TC.

Mobile support (ASTC and ETC2) is coming in a future PR, stay tuned.
2018-10-01 14:34:21 -07:00
prideout
6f2455e7e3 Simplify KTX metadata. 2018-09-25 15:37:49 -07:00
Philip Rideout
6f09389d2f web / cmgen: use KTX metadata for sh coefficients. 2018-09-25 15:37:49 -07:00
Ben Doherty
804c974819 Fix, Vulkan samples not compiling on Windows (#306) 2018-09-25 13:28:32 -07:00
Philip Rideout
c454a835d1 Web: allow arbitrary file extensions for KTX files.
Sometimes you want your KTX file to end in an extension other than
".ktx".  For example, GitHub Pages applies gzip encoding to bmp files
but not to ktx files (which I think is consistent with nginx defaults).

This change makes it so that a deploy script can rename the files and
apply a simple string transformation to the HTML.
2018-09-21 15:55:00 -07:00
Philip Rideout
c6ac562ca9 Rotate WebGL samples IBL by 180.
This is being done simply to maintain the rough alignment between
the light source and the env map. See 09830cd for more information.
2018-09-21 13:13:48 -07:00
Philip Rideout
665ff2cd8f Refactor filaweb::Asset. 2018-09-21 11:54:03 -07:00
prideout
63f2fe4ebc Use KTX for envmaps in WebGL demos.
For each envmap/skybox pair, this reduces the number of downloads
from 61 files to 3 files.
2018-09-21 11:54:03 -07:00
prideout
b396b85818 Refactor filaweb to prep for KTX envmaps. 2018-09-21 11:54:03 -07:00
Philip Rideout
d3e7103ee5 Fix three bugs that caused bad normals with Suzanne.
(1) Suzanne's normal map is actually linear but we were telling GL that
it is SRGB, so the shader was not reading (0.5,0.5,1.0) from a perfectly
flat normal map.

(2) --linear in mipgen was not honored when consuming PNG files.

(3) The build was not passing --linear to mipgen for the normal map.
2018-09-20 10:01:43 -07:00
Philip Rideout
44b4cee4b1 Minor filaweb cleanup. 2018-09-19 17:18:44 -07:00
Philip Rideout
695543154b Fix filaweb bug with detecting PNG vs KTX.
To determine PNG vs KTX, we were looking at the file extension of the
asset name rather than the actual file path (which is a URL).

Also, le singe était trop sombre, so I added a call to setIntensity.
2018-09-19 17:17:17 -07:00
Philip Rideout
f392ba629d Suzanne demo now uses KTX for some textures.
In Chrome, this reduces texture load time from 620 ms to 150 ms because
it removes the PNG decoding work for the surface textures. We are still
using PNG for the envmap, I'll fix that soon.

Many web servers, including GitHub Pages, automatically use gzip
encoding for these files. Over the wire these files actually are not
much bigger than the PNG, even though they contain miplevels.

Stay tuned for compressed textures, which should make this better.
2018-09-19 13:59:05 -07:00
Ben Doherty
f965b02b1b Fix, normal must be set prior to prepareMaterial (#273) 2018-09-19 13:37:24 -07:00
Mathias Agopian
c1d8cc0d7a fix normals of the shadow plane.
They ended-up pointing down.
2018-09-18 19:08:50 -07:00
Philip Rideout
fd8b1851a9 Add --grayscale option to mipgen.
By using single-component images instead of RGB, we are greatly reducing
the size of KTX files for roughness, metallic, and ambient occlusion.
2018-09-18 16:46:38 -07:00
prideout
52ee8e570d mipgen can now generate KTX files.
I tested the validity of the resulting KTX files by using macOS Preview,
which can read some types of KTX files. (!)

This CL also adds mipgen to the WebGL build, although its outputs are
not yet used by the sample apps.
2018-09-18 12:42:47 -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
Philip Rideout
12d3b06622 High-to-Low includes, per our style guidelines. 2018-09-12 10:43:41 -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
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
Philip Rideout
c8948be59e Hook up mouse events for web. (#227) 2018-09-07 19:15:52 -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
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
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
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
Philip Rideout
6767258805 Make debug builds of WebGL usable. (#208) 2018-09-05 13:02:56 -07:00