Commit Graph

45 Commits

Author SHA1 Message Date
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
Philip Rideout
edec94bb08 Suzanne fixup: create entities for point lights. (#206)
This was causing an assert with debug builds.
2018-09-05 11:59:26 -07:00
Romain Guy
a6722c1f12 Add new Android sample app (#190)
This sample app shows a lit, rotating cube
2018-08-31 14:20:57 -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
prideout
a6caacba77 Add missing semicolon. 2018-08-28 17:00:53 -07:00
prideout
86e7afecea Minor code cleanup to filaweb. 2018-08-28 16:58:02 -07:00
Philip Rideout
fa9f597ca4 CMake improvements for samples/web. (#179)
This uses "foreach" in order to create proper dependencies for each
cubemap face and miplevel.

It also adds a custom command for the mesh and envmap assets, similar to
how we already handle materials. This seems to work properly and
rebuilds the assets only when upstream dependencies have been dirtied,
or when downstream dependencies have been deleted.
2018-08-28 16:07:48 -07:00
Philip Rideout
557dd53233 Add filamesh to HOST_TOOLS. (#178) 2018-08-28 14:39:13 -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
Romain Guy
a779e92b99 Fix clang-tidy warnings (#158) 2018-08-27 14:30:12 -07:00
Romain Guy
39ca6d146f Fix ambiguities with translate() and scale() (#154)
These two functions expect a vector of the same size as the
matrix's storage vectors (float4 for a mat4f for instance) which
has two major issues:

- The vector must end with 1 for homogeneous coordinates to work
- Passing a single scalar (mat4f::scale(0.5)) creates a matrix
  whose diagonal is set to that scalar, thus breaking homogeneous
  coordinates

With this change scale and translate expect a vector who dimensionality
is 1 less that of the matrix's underlying storage vectors. i.e. a float3
for mat4f.
2018-08-27 10:21:13 -07:00
prideout
3a7d80f29b Restore "Add single-threaded config to Filament. (#130)"
This reverts commit 24022010f9.
2018-08-27 08:51:46 -07:00
Philip Rideout
24022010f9 Revert "Add single-threaded config to Filament. (#130)" (#152)
This reverts commit e3457aa0a7.
2018-08-26 18:40:49 -07:00
Philip Rideout
1dbe386268 Add WebAssembly to the build. (#145)
This does not add any samples or continuous integration, but it at least
allows developers to do a "-p webgl" and check if an actual wasm file
for the core Filament library can be succesfully built.
2018-08-24 17:18:12 -07:00
Philip Rideout
e3457aa0a7 Add single-threaded config to Filament. (#130)
* Add single-threaded config to Filament.

This adds a tick method to Engine and disables a couple components
in Renderer (FrameSkipper and FrameInfoManager).

This will make it easier to support WebGL, and will allow us to remove
some of the command buffer debugging stuff that we added for Vulkan.

* tick => execute, and other review feedback

* Restore the ASSERT for FFence::wait.
2018-08-24 16:37:12 -07:00
Romain Guy
4585b8f896 Add clearCoatNormal property (#131)
* Add clear coat normal map support

This change allows to set a separate normal map for the clear coat layer of a material.

* Document the new clearCoatNormal property

* Fix typo
2018-08-24 08:56:44 -07:00
Mathias Agopian
7a14aadb28 sample clean-up and new sphere object (#134)
* Add missing method to query the type of a light

* IcoSphere now generates front facing triangles

* Add a fairly generic sphere object to use in samples

it provides an ico sphere with normal, and reuses
the same vertex/index buffer for each new instance.
Each instance can have its own material, size and
position.

currently it’s not possible to change the # of
subdivisions.

* FilamentApp now provides a “default” pbr material

this makes it easier to create renderables for
testing.

* clean-up lightbulb and add spheres for each light

lightbulb now has less hardcoded things and it
spawns a small sphere for each light.
2018-08-23 21:12:46 -07:00
Philip Rideout
099738e545 Try to clean up asset folders for sample apps. (#128)
* Try to clean up asset folders for sample apps.

This removes the build step where we copy a subset of assets, and makes
it so that FilamentApp hands out a "root path" for assets. For now this
is determined based on the location of the executable. This allows
developers to launch samples from any CWD.

Closes #11

* Restore asset copy to build.
2018-08-23 12:46:45 -07:00
Mathias Agopian
38de58007c checkpoint: ground work for calculating binary light trees
computeLightTree() takes a list of light as
a bitfield and produces a depth-first 
binary tree array that can be used to efficiently
check which lights volumes contain a given z
coordinate in screen space.

Currently computeLightTree() produces the array
locally on the stack, which isn’t useful, but
before we can make use of it, a lot of other
things have to happen.
2018-08-22 14:55:17 -07:00
Philip Rideout
044387308a Migrate imageio to LinearImage. (#111) 2018-08-17 11:22:05 -07:00
Romain Guy
8c9c49e2b9 Fix potential null pointer crash
Passing `-y` without specifying an IBL on the command line would lead to a crash.
2018-08-16 16:32:15 -07:00
Romain Guy
e439c779a2 Don't use $CMAKE_SOURCE_DIR, let's use $FILAMENT instead
See pull request #103
2018-08-16 09:08:57 -07:00
Philip Rideout
6d9668ccf6 Add unit test for cross cube images. (#101) 2018-08-15 15:36:17 -07:00
Romain Guy
7547cd9ee5 Update images for the documentation 2018-08-15 13:57:48 -07:00
Romain Guy
65a42a518c Add material_testbed application (#97)
* Add material_testbed application

This application can be used to automatically vary material parameters over multiple frames and capture each frame as a PNG file. This makes it easier to test/compare/etc. It's also useful to generate documentation examples.

* Rename material_testbed to frame_generator
2018-08-14 18:01:31 -07:00
shartte
e6d5a85ec8 clang-cl warning fixes (#83)
* Disable certain MSVC-specific deprecation warnings

* clang-cl.exe warning fixes
2018-08-14 12:55:04 -07:00
Romain Guy
c429af310e Cleanup sample code 2018-08-13 17:01:04 -07:00
Romain Guy
42e319e074 Add white furnace IBL (#89)
Useful to test BRDFs and energy conservation
2018-08-13 15:51:44 -07:00
Philip Rideout
f9e1d58772 Add prefix to experimental Vulkan demos. 2018-08-06 17:01:41 -07:00
Romain Guy
b3d758f3b3 Initial commit 2018-08-03 10:38:22 -07:00