Commit Graph

130 Commits

Author SHA1 Message Date
Philip Rideout
6f601e6021 Update KTX files and allow glFormat = LUMINANCE 2018-12-06 10:33:49 -08:00
Sebastian Hartte
aaf2909194 Correctly set glTypeSize in the tools, and use sized formats for internalFormat 2018-12-06 10:33:49 -08:00
Philip Rideout
beaf751604 filamesh: Compress attributes individually.
This further reduces compressed suzanne from 333489 bytes to 272761.

Tested with vk_hellopbr and tutorial_suzanne.html

Issue #558
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
Philip Rideout
b4b12914a1 Add bitcast to utils. 2018-12-04 17:56:37 -08:00
Philip Rideout
ff2da6e3b4 Add zeux/meshoptimizer to third_party.
This also adds it as a dependency to filameshio. This does not seem to
increase the size of the WebGL build even though filameshio is a
dependency, perhaps because we are not using it yet.
2018-12-04 16:36:56 -08:00
Philip Rideout
a7d6af8d22 filamesh: Add support for TEXCOORD_SNORM16. 2018-12-03 14:18:12 -08:00
Philip Rideout
0af274fe0e filamesh: introduce MeshWriter class.
This simplifies main.cpp so that it only does assimp stuff.
2018-12-03 14:18:12 -08:00
Philip Rideout
edda436405 Documentation for new filamesh flags, etc. 2018-12-02 16:46:31 -08:00
Philip Rideout
61992f556c Add unit test for filamesh.
The motivation behind a new regression test is the fact that we will
soon be adding compression features to filamesh.
2018-12-02 16:46:31 -08:00
Philip Rideout
aa3a7085cc Factor out common filamesh / meshio code.
This creates a filamesh namespace and removes several duplicated
classes, including Box and filamesh::Header.
2018-12-02 16:46:31 -08:00
Philip Rideout
eb814a9ff2 Repair test_cmgen. 2018-11-30 18:02:00 -08:00
Philip Rideout
5abd60fca5 Mipgen now creates the out dir if needed. 2018-11-30 13:16:47 -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
da7dbbc04b Filamesh now creates the out dir if needed. 2018-11-29 16:41:09 -08:00
Philip Rideout
239317ee10 Use resgen for libshaders. 2018-11-29 07:37:56 -08:00
Philip Rideout
12754fd7eb Minor resgen improvements.
This adds a couple optional features:

1) Preserve file extensions when generating symbols.
   This is useful to distinguish foo.vs from foo.fs

2) Append null characters to data blobs.
   Useful when treating FOO_DATA as a C string.
2018-11-28 16:58:41 -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
Ben Doherty
a1ed3b81a3 Move static code analysis into filamat (#534)
* Handle static code analysis automatically

* Fix matc test cases

* Only call InitializeProcess once per process
2018-11-27 14:11:27 -08:00
Philip Rideout
30092dc12b Add style guidelines for strings.
This also adds the std:: qualifier to resgen (see also PR #356)
2018-11-27 09:05:57 -08:00
Ben Doherty
6d158bbc80 Remove codeGenTargetApi (#511) 2018-11-26 10:51:34 -08:00
Philip Rideout
0807cfbaaa Fix Windows build. 2018-11-21 22:14:22 -08:00
Philip Rideout
e90b53fdce Introduce resgen tool for embedding binary blobs.
This tool can be used to replace inc files for built-in materials. The
inc files are unfriendly to IDE's and do not extend to non-material
resource types such as baked texture data.

The tool aggregates a sequence of binary blobs, each of which becomes a
"resource" whose id is the basename of the input file. It produces the
following set of files:

    resources.h ......... declares sizes and offsets for each resource
    resources.S ......... small assembly file with incbin directive
    resources.apple.S ... ditto but with different rodata name
    resources.bin ....... the aggregated binary blob
    resources.c ......... large xxd-style array (only for WASM)

We did an experiment to test the incbin directive on a variety of
platforms in PR #510.
2018-11-21 17:18:21 -08:00
Mathias Agopian
5bcc4cfff1 Improve the slow-path of creating a program
This removes a lot of heap allocations/deallocations, and reduces
code size. Most improvements come from using CString and
StaticString instead of std::string and better using move
semantics.
2018-11-21 13:46:07 -08:00
Ben Doherty
b5fa822e86 Move GLSLPostProcessor and dependencies into filamat (#500)
* Move GLSLPostProcessor into filamat
2018-11-20 12:30:26 -08:00
Philip Rideout
55eaad9450 Add smol-v to third_party.
Since we use this for decoding, this adds a dependency to the core
filament renderer which in practice is only used for Vulkan. However
this is a tiny library, so it's simplest just to always include it.

The next PR will add the actual compression / decompression code to
filaflat and filamat. Here are the preliminary results.

   102K =>  29K  aiDefaultMat.filamat
   102K =>  29K  aiDefaultTrans.filamat
    21K => 5.0K  bakedColor.filamat
    22K => 5.2K  bakedTexture.filamat
    21K => 5.0K  depthVisualizer.filamat
    40K =>  10K  groundShadow.filamat
   102K =>  29K  sandboxCloth.filamat
   125K =>  36K  sandboxLit.filamat
   126K =>  36K  sandboxLitFade.filamat
   126K =>  36K  sandboxLitTransparent.filamat
   109K =>  31K  sandboxSubsurface.filamat
    21K => 4.9K  sandboxUnlit.filamat
    21K => 4.9K  transparentColor.filamat

Both the "before" and "after" numbers are excluding non-Vulkan targets,
and I also changed our CMakeLists to build filamat instead of inc.
2018-11-15 16:55:40 -08:00
Romain Guy
f1c2c39a3d Cleanup matc a little bit (#488) 2018-11-14 11:58:06 -08:00
Mathias Agopian
f8f24f492f minor typo / spelling / clang-tidy fixes (#468)
* Minor clean-ups

- fix a couple usage of std::function
- fix a couple usage of std::string
- remove ALIGN_LOOP, which didn't work
- fix a couple explicit/noexcept
- virtual -> override

* Fix spelling typos and other minor clang-tidy
2018-11-08 11:50:00 -08:00
Mathias Agopian
912b301790 Try to bring some sanity to our UBO structures
- move UBO declarations in UibGenerator, i.e. next
  to their Uniform Interface Block definition.
  This should help forgetting to update one but
  not the other.

- move UniformInterfaceBlock.h and SamplerInferfaceBlock.h under
  private/filament/.

- do the same things for samplers
2018-10-24 15:11:54 -07:00
Ben Doherty
0d709b6074 Add a few new nodes to Tungsten (#326) 2018-10-15 12:02:05 -07:00
Adrian Perez
6c66bc26e7 remove another instance of using namespace std (#354) 2018-10-09 01:51:41 +02:00
Adrian Perez
27a2d05c8a Remove 'using namespace std' (#352) 2018-10-08 20:41:08 +02: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
Philip Rideout
06fc8e2f4c Add compression support to cmgen. 2018-10-08 09:25:09 -07:00
Philip Rideout
da698f2e36 Add high level compression API to prep for cmgen integration. 2018-10-05 10:11:48 -07:00
Philip Rideout
23efe17380 mipgen: fix dark miplevels in normal maps.
When using GAUSSIAN_NORMALS, image::resampleImage automatically unitizes
its output. This means that clients (e.g. mipgen) need to ensure that
the source image is in [-1,+1] rather than [0,+1].
2018-10-04 14:28:44 -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
70a4c4f887 Add etc2comp to third_party. 2018-10-02 12:32:23 -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
Mathias Agopian
1748724826 Use “cubemap” instead of “faces”. Fixes #320. 2018-10-01 11:55:53 -07:00
Mathias Agopian
741b1a412d experimental: add octahedron output support
Octahedron output support for cmgen. use —type=octahedron.

This is still fairly experimental.
2018-10-01 11:49:29 -07:00
Philip Rideout
33e0e34aa4 Remove STB dependency from astcenc.
We give the encoder raw RGB data, so there's no reason to use its STB
functionality. This shrinks the lib footprint by a small amount.
2018-09-28 16:33:41 -07:00
Philip Rideout
395b3a398d Fix mipgen windows build. 2018-09-28 16:33:41 -07:00
Philip Rideout
b25e693f6b Add stb to mipgen license list. 2018-09-28 16:33:41 -07:00
Philip Rideout
6ed331d74c Add compression to mipgen and change bitrate to block size.
The compression API now takes block size instead of bit rate. Otherwise
it is quite possible for the encoder to generate a block size that is
not one of the valid block sizes that graphics API's can actually
consume.
2018-09-28 16:33:41 -07:00
Pixelflinger
fae92f2750 Equirectangular export support
this adds a new --type (-t) parameter that is
used to specify cmgen’s output.

faces: outputs cube maps separate faces (default
       and current behavior)
equirect: outputs an equirectangular image
ktx: outputs a ktx file


--format=ktx now implies —type=ktx
2018-09-28 14:37:48 -07:00
Philip Rideout
ec31a55094 Add astcenc from ARM to third_party.
This was designed as a standalone tool rather than a library, so we are
renaming their "main" function to "standalone_main", which is described
in the tnt README.

We'll also be adding a wrapper to our imageio library.
2018-09-28 09:42:09 -07:00
Mathias Agopian
13e70f7afa fix typos that caused bilinear filtering in corners to be wrong 2018-09-27 21:45:21 -07:00
Mathias Agopian
cb34ab217b fix typo that could cause a crash 2018-09-27 20:11:27 -07:00