Commit Graph

98 Commits

Author SHA1 Message Date
Philip Rideout
6f601e6021 Update KTX files and allow glFormat = LUMINANCE 2018-12-06 10:33:49 -08:00
Philip Rideout
8bb68b3c55 Rename MeshIO class to MeshReader.
This makes the name symmetrical with MeshWriter.
2018-12-05 17:15:52 -08:00
Philip Rideout
6c55b3b989 filamesh: Add support for COMPRESSION.
Note that the WebGL build uses filameshio, but Android does not. Our
Android samples therefore do not yet understand the compressed format.
For web, I measured the before / after:

```
BEFORE: filament.wasm = 505796, suzanne.filamesh = 521476
 AFTER: filament.wasm = 510915, suzanne.filamesh = 333489
```

Issue #558
2018-12-05 13:20:55 -08:00
magicwhale
27f8dbef21 Added support to gltf_viewer for multiple UV coordinates (#578)
gltf_viewer can now display models that use both UV0 and UV1 coordinates for textures.
2018-12-05 12:35:26 -08:00
magicwhale
b902a90285 Changed MeshAssimp to dynamically generate materials with filamat (#563) 2018-12-03 10:15:47 -08:00
Philip Rideout
9192280339 KTX-ify some of our sample environments.
- Nuke office and desert
- Add pillars and venetian_crossroads
- Regenerate white_furnace
- Keep the diagnostic environments (uv2, uv8, and uv128) as-is
2018-11-30 17:15:10 -08:00
Philip Rideout
af799e734a FilamentApp can now use KTX environments.
When cmgen creates ktx files, it creates a pair: one with an _ibl suffix
and one with _skybox. This convention is now honored by FilamentApp.

Note that we already have several KTX environments in the repo, so you
can clone a fresh repo and do:

  gltf_viewer --ibl={FILAMENT}/docs/webgl/pillars_2k DamagedHelmet.gltf

Note that we have several hundred files in samples/envs, we should
consider replacing those or copying the environments in docs/webgl
(which git would internally de-dup, due to content hashing).
2018-11-30 14:09:04 -08:00
Romain Guy
533e260804 Remove obsolete samples (#559) 2018-11-29 17:40:05 -08:00
Philip Rideout
20680e8170 Improve resgen speed and avoid using static.
(1)
Generating the C file (only used for WebAssembly) causes slowness in the
build so this makes it into an option. Also, we were flushing too often,
which made it even slower.

(2)
Using "static" in a header was causing symbol duplication.
2018-11-29 17:21:27 -08:00
Philip Rideout
4278e1bd59 Remove assimp usage from some sample apps.
This shows how resgen can be used for mesh data. It also removes the
MeshAssimp dependency from samples that were meant to be small and
self-contained.
2018-11-28 19:46:37 -08:00
Philip Rideout
0b84425bd0 Fix up tangents in MeshAssimp to help with #528.
We started to write our own implementation of mikktspace, but it
required an unindexed mesh for input. This was awkward because assimp is
already applying a pipeline of operations that includes tangent
generation and indexing. It felt reduandant to add our own pipeline on
top of that (unindexing => tangentgen => reindexing).

Since assimp's CalcTangentsProcess method is already producing
tangents that follow the orientation implied by texture coordinates,
this simply needs to be tweaked to match glTF. (flip the bitangent)

Also fixed a bug for the case where models have neither UV's nor
tangents, where we were calling norm instead of normalize. :)
2018-11-28 15:46:04 -08:00
Ben Doherty
b759074c8f Deprecate set method on MaterialBuilder (#545)
* Remove the defines entry in material definitions

* Deprecate set function

* Remove some getter methods from MaterilaBuilder

* Fix tests, add to CI
2018-11-28 15:35:19 -08:00
magicwhale
2a5e978f2e Changed MeshAssimp to use constants defined in assimp header files 2018-11-28 12:15:24 -08:00
Philip Rideout
91abaf575b Add tangents utility to fix #532.
I tested this by writing a quick-and-dirty Sphere demo.
2018-11-28 11:27:37 -08:00
magicwhale
ad1f3cf133 Added support for different min and mag filter samplers in gltf_viewer (#539)
Modified MeshAssimp.cpp to support different min and mag filter types for gltf files.
2018-11-28 10:03:07 -08:00
Philip Rideout
0011b1bba3 Use resgen in samples and MeshAssimp. 2018-11-28 08:35:44 -08:00
Romain Guy
588ce8fe3f More code style cleanup 2018-11-26 14:07:07 -08:00
Romain Guy
44c4362edb Code style cleanups 2018-11-26 14:04:43 -08:00
Romain Guy
20ffb52dc2 Re-enable glTF support (#505)
* Revert "Rollback MeshAssimp enhancements."

This reverts commit b3dce967eb.

* Re-enable glTF support

* Start looking for texture ids at 1, not 0

* Detect if the importer is glTF

* glTF and regular materials both work
2018-11-26 13:14:28 -08:00
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