Commit Graph

8 Commits

Author SHA1 Message Date
Philip Rideout
12d3b06622 High-to-Low includes, per our style guidelines. 2018-09-12 10:43:41 -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
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
Romain Guy
4002498438 Add new HDR environment maps in third_party (#182)
These are much better than the ones we had in assets/
2018-08-29 14:22:58 -07:00
Philip Rideout
db2e1426e9 Introduce two WebGL samples: triangle and suzanne. (#170)
* Introduce two WebGL samples: triangle and suzanne.

This commit has no effect on mobile / desktop builds, it only adds new
targets to the `-p webgl` build.

We will eventually expose a proper JavaScript API, but for now these
samples use a (somewhat under-engineered) `filaweb` framework whereby
the WebAssembly module exposes a small number of C entry points: launch,
render, and resize.

Each sample has two source files: a cpp file and an html file. The cpp
file generates js / wasm pair.  The generated js is simply a loader for
the wasm.

The CMake script creates a pristine "public" folder which contains the
minimal set of files needed to serve the web application using a simple
static file server. The public folder like this:

    /suzanne.js         built by em++ from suzanne.cpp
    /suzanne.wasm       built by em++ from suzanne.cpp
    /suzanne.html       copied from REPO/samples/web
    /filaweb.js         copied from REPO/samples/web
    /favicon.png        copied from REPO/samples/web
    /monkey/*.png       copied from REPO/assets/models
    /monkey/*.filamesh  built by filamesh
    /desert/*           built by cmgen

To decode PNG textures, we use the somewhat unusual approach of using
JavaScript to draw them into a hidden 2D canvas, then reading back the
pixels. This allows us to avoid fattening up the wasm file with a PNG
decoder. An alternative idea would be to pass a DOM Image directly into
glTexImage2D, but this would require some #ifdefing and/or JS injection
in Filament's OpenGL backend.

* Optimize the suzanne material.
2018-08-28 11:09:06 -07:00