Commit Graph

710 Commits

Author SHA1 Message Date
Mathias Agopian
094453dad8 clarify the LOD -> linear_roughness remapping
This remapping can be confused with roughness, because

linear_roughness = roughness*roughness and 
lod = sqrt(linear_roughness)

so the value of lod is roughness, but conceptually
it’s not.
2018-09-17 20:18:57 -07:00
Mathias Agopian
66d97bc9c0 Fix importance sampling for OpenGLES targets 2018-09-17 19:41:05 -07:00
Ben Doherty
cc77160cb4 Tungsten: fix a couple view-related bugs (#255)
* Fix bug when dragging non-selected node

* Fix bug when dragging nodes
2018-09-17 16:16:15 -06:00
prideout
cc6ee64e05 Add "strip alpha" feature to mipgen.
Sometimes the source image might have a useless 1-bit alpha channel
which our image-processing pipeline expands into a proper alpha channel.
This consumes memory and breaks an assertion in our encoder.

I ran into this while testing mipgen with the Suzanne textures.
2018-09-17 15:08:09 -07:00
prideout
3f751f3850 cmgen and mipgen should return an error code upon failure.
These tools can be used in an asset pipeline; build scripts should not
be required to parse stdout in order to determine success.
2018-09-17 14:51:29 -07:00
prideout
ee47255c83 Improve the build instructions for WebAssembly and Linux.
Fixes #249
2018-09-17 11:14:15 -07:00
Romain Guy
4ca4df0f6c Inlude missing headers (#252) 2018-09-17 09:31:10 -07:00
Mathias Agopian
71fed25775 When prefiltering the IBL we were wrongly assuming
f90=0, which is nonsensical.

We now assume f0=f90=1, meaning the fresnel term
always evaluates to 1.

Thankfully this didn’t impact the prefilter too much.


IBLs MUST BE REGENERATED
2018-09-16 17:40:11 -07:00
Romain Guy
a785bab26c Use the fast approximation on mobile instead of desktop 2018-09-14 23:11:45 -07:00
Philip Rideout
21906a1096 Simplify KtxBundle by using unique_ptr. 2018-09-14 16:55:05 -07:00
Philip Rideout
e4b60e47cb Introduce KtxBundle to libimage and add unit test.
KtxBundle is basically an in-memory representation of a KTX file.
Our primary motivation for introducing this class is to have a
structured container for block-compressed textures.

Note that this class is defined in libimage rather than libimageio.
There are several reasons for this:

1. The texel data in a KtxBundle is not meant to be decoded by the CPU.
2. It has no dependendencies on any libraries (stb_image tinyexr etc).
3. We wish to use it with WebGL, which needs to avoid using imageio.
2018-09-14 16:55:05 -07:00
Romain Guy
c1793b09bc Use slightly optimized Schlick on mobile 2018-09-14 09:50:18 -07:00
Romain Guy
96d3846571 Fix Schlick Fresnel when f90 < 1 2018-09-14 09:44:34 -07:00
Romain Guy
41d70cb30a Fix anisotropy BRDF on mobile (#245)
mediump computations are not enough for certain roughness values.
2018-09-13 18:31:08 -07:00
Ben Doherty
3e6f1a2c39 Tungsten: add orbit cam manipulator (#244)
* Add orbit cam to Tungsten

* Add kotlin-math library

* Flip mouse wheel event sign if coming from a physical wheel
2018-09-13 17:30:33 -07:00
Mathias Agopian
ea91002412 improve cmgen comments about IBL (#243)
* better comments on calculating the DFG lookup tables

* add comments about computing the “LD” term

* add comments about computing IBL diffuse pre-integration

* be clearer about the determinant of the jacobian
2018-09-13 15:12:45 -07:00
Ben Doherty
a2b304def9 Update comment in Variant.h (#242)
Update comment so the labels match the description
2018-09-13 11:11:52 -07:00
Philip Rideout
4694a9a160 Invoke find_library for Vulkan only on macOS. 2018-09-13 08:07:55 -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
Ben Doherty
6ab36e9365 Fix, flip components not working (#239) 2018-09-12 17:29:40 -07:00
Romain Guy
735d7fedf7 Cleanup comments 2018-09-12 13:49:31 -07:00
Mathias Agopian
01a4f563e7 more important sampling fixes
- compute dot(n,l) correctly
- don’t rely on the provided tangent space for
  now because some meshes have a broken TBN
2018-09-12 13:30:34 -07:00
Mathias Agopian
cd058d36f3 use LoH instead of VoH (they’re equal) 2018-09-12 13:30:34 -07:00
Mathias Agopian
fd8c2b1874 compute the clear coat layer with importance sampling 2018-09-12 13:30:34 -07:00
Mathias Agopian
b0f6cf037d address more comments
- pass the tangent space to the importance sampling
- reorder parameters
2018-09-12 13:30:34 -07:00
Pixelflinger
b9bcf41e74 fix most romain@ comments 2018-09-12 13:30:34 -07:00
Mathias Agopian
5f1bdb0677 importance sampling option for IBL
This will be useful for testing and can be
enabled at compile time by setting
IBL_INTEGRATION to IBL_INTEGRATION_IMPORTANCE_SAMPLING
in *both* indirectLight.cpp and light_indirect.fs

BUGS: clearcoat and subsurface won’t
work well when this is enabled since the prefiltered
cubemap is not available and, we don’t evaluate
those lobes with importance sampling (yet).
Additionally, anisotropy can’t work with our
prefiltered importance sampling, so it still uses
the emulation by bending the normal.
2018-09-12 13:30:34 -07:00
Philip Rideout
12d3b06622 High-to-Low includes, per our style guidelines. 2018-09-12 10:43:41 -07:00
Ben Doherty
d0be29fb34 Tungsten: introduce texture sample node (#230)
* Tungsten: introduce texture sample node

* Add uv input to texture sample node

* Only flip components if specified in reverse order
2018-09-12 10:37:03 -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
Pixelflinger
1db1426260 fix cmgen unit test 2018-09-11 01:09:22 -07:00
Mathias Agopian
4475cbaf2e fold the lambert brdf into the SH coefs
this saves one multiply in the shader, but most
importantly makes the first SH coefficient a
color and reduces its range

ALL IBLs NEED TO BE REGENERATED using cmgen
2018-09-10 21:09:11 -07:00
Romain Guy
7ada9b6470 Kotlinify our Kotlin code (#233) 2018-09-10 18:33:14 -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
Romain Guy
cc102be69f Fix docs typo
Closes #228
2018-09-10 10:19:16 -07:00
Philip Rideout
c8948be59e Hook up mouse events for web. (#227) 2018-09-07 19:15:52 -07:00
Romain Guy
e0de488a0e Update Windows build instructions 2018-09-07 16:02:08 -07:00
Mathias Agopian
abae178ddc cmgen: option to generate the diffuse irradiance
-—ibl-irradiance generates the diffuse irradiance as
a cubemap using importance sampling. 
It can be used in place of the SH version (—-sh-irradiance)
which sometimes presents some ringing artifacts.
2018-09-07 14:31:44 -07:00
Mathias Agopian
f75f19edd0 save debug files in .HDR format instead of .PNG 2018-09-07 14:31:44 -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
Mathias Agopian
d3a470319c fix #201 Division by zero in FScene::computeLightRanges (#217)
SIMD code is accessing uninitialized elements,
so make sure they are initialized enough to avoid
divide-by-zero.

We were also processing the directional light in
computeLightRanges(), which always has a zero
radius.
2018-09-06 20:43:00 -07:00
Mathias Agopian
ad18b6ea39 fix divide-by-zero in cmgen (#201) (#218)
We were doing a divide-by-zero in a case where
the result wasn’t used.
2018-09-06 20:42:45 -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
Ben Doherty
069b4d1180 Tungsten: improvements to shader node (#216)
* Add StringValue and Choice

* Add editorFactory to nodes

* Update graph model when compiling

* Extract compileNode function

* Change inputs based on shadingModel

* Allow nodes to set shading model

* Fix float literals with dimension 1

* Adjust node height for slots

* Improvements to shader node

* Don't ever set a default value

* Add anisotropy and anisotropyDirection
2018-09-06 17:20:55 -07:00