Commit Graph

47 Commits

Author SHA1 Message Date
Ben Doherty
f05b2f47a8 Fix use of UV0 and UV1 coordinates (#576)
* Fix use of UV1

* Add a test case

* Spelling
2018-12-04 13:23:01 -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
97d5f0f52c Fix libshader build for Windows. 2018-11-29 07:37:56 -08:00
Philip Rideout
239317ee10 Use resgen for libshaders. 2018-11-29 07:37:56 -08:00
Romain Guy
0938051579 Fix docs 2018-11-15 16:57:16 -08:00
Philip Rideout
a5cdb89107 Handle Vulkan ClipSpace in GLSL rather than C++.
Recall that Vulkan has a right-handed NDC system. Currently, our Vulkan
backend is not handling VERTEX_DOMAIN_DEVICE correctly, but we didn't
notice because the culling mode is not honored yet (a separate PR is on
the way for that).

To fix this, we considered adding a shader-based fixup only for the
device domain and keeping our Vulkanish projection matrix as-is.
However, this would cause the skybox shader to compute an incorrect
wrong eye vector due to in the inconsistent definition of clip space.

After discussion with Mathias and Ben, we decided that the most elegant
fix is for Filament to have only one canonical clip space, which for
now is the clip space that OpenGL requires.

Ben pointed out that spirv-cross has a flag for injecting shader-based
fixups. However we don't invoke spirv-cross for the Vulkan target, and
it's easy just to do this on our own.
2018-11-15 08:08:16 -08:00
Philip Rideout
9e7b589d0a Fix FXAA pixel alignment.
Fixes #397.
2018-10-19 16:42:01 -07:00
Mathias Agopian
1cde20d822 Avoid a normalize() in the vertex shader
This is achieved by pre-scaling the normals 
transform so that the resulting normal doesn't have
any large component allowing to do the normalize()
in the fragment shader in mediump.

This must be done for skinning too.
2018-10-18 17:37:06 -07:00
Romain Guy
920cc7a84a Normalize normals and tangents in the vertex shader (#388)
This avoids breaking bitangents when a scale value is set in the
transform matrix
2018-10-16 17:12:54 -07:00
Mathias Agopian
b374340ebb skinning allows 256 bones again, but disallow skews. 2018-10-16 15:56:30 -07:00
Romain Guy
3a0f9791cc Remove outdated comment 2018-10-12 18:37:34 -07:00
Mathias Agopian
b4c77166b7 fix normals when skinning with non-uniform scales 2018-10-11 18:46:42 -07:00
Mathias Agopian
920113b076 fix a typo that caused skinning to just not work 2018-10-11 16:50:52 -07:00
Mathias Agopian
7485cc5fd0 Skinning now supports non-rigid transforms
A full 3x3 + translate matrix is supported.
2018-10-09 18:17:44 -07:00
Romain Guy
c2ce7f8ffd Ensure the base layer is never glossier than the clear coat layer (#355)
* Ensure the base layer is never glossier than the clear coat layer

* Fix typo
2018-10-09 02:37:04 +02: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
Mathias Agopian
86b8a97389 clamp .st when reading shadow map to avoid overflow
because the shadow map can be “focused”, its
texture coordinates can end-up very large, which
in turn can cause overflows in the calculation of
the PCF positions. Unfortunately some GPUs
abort in that situation, which causes artifacts.


Fix Bug 111455153
2018-09-26 18:52:32 -07:00
Mathias Agopian
c8e822b402 use mipmaps when doing importance sampling 2018-09-24 16:15:49 -07:00
Mathias Agopian
4c822533da MATERIAL BREAKAGE: Allow any froxel layout in the shader. 2018-09-19 15:26:17 -07:00
Mathias Agopian
aa7c62c0f4 MATERIAL BREAKAGE: enable non-square froxels option 2018-09-19 15:25:56 -07:00
Romain Guy
0d37989157 Make the procedural UV grid HDR (#265) 2018-09-18 18:28:56 -07:00
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
Romain Guy
a785bab26c Use the fast approximation on mobile instead of desktop 2018-09-14 23:11:45 -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
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
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
f550fbaa44 Skip lighting and shadowing computations when possible (#210) 2018-09-05 16:04:38 -07:00
Romain Guy
2eac290161 Make shadowMultiplier objets transparent when not lit (#209) 2018-09-05 15:17:31 -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
Romain Guy
711d8877bf Add comment explaining an odd choice 2018-08-23 14:19:21 -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
Romain Guy
128ab657df Switch cloth model from Ashikhmin NDF to "Charlie" NDF (#53)
* Add new Cloth NDF

Based on the work by Estevez and Kulla, also known as the "Charlie" sheen.

* Restore DFG computation to GGX

* New proposed approximation for Cloth DFG

* Add "Charlie" cloth DFG approximation to cmgen

* Switch to "Charlie" sheen for cloth shading

* Document the new cloth NDF and DFG approximation
2018-08-08 17:22:41 -07:00
Romain Guy
bb75923b79 Fix post-process shader when not in Vulkan (#41)
* Fix post-process shader when not in Vulkan

The post-process shader must not flip the source texture when we compile for OpenGL. This happens because we use SPIR-V/Vulkan as an intermediate format.

* Fix the Android build

We need to output a location when targeting SPIR-V for mobile.
2018-08-07 18:46:30 -07:00
Ben Doherty
46228e9610 Fix shader compilation on Windows 2018-08-07 17:10:03 -07:00
Romain Guy
da03ef2378 Compile shaders in a separate static library (#34)
* Update build instructions

* Compile shaders in a separate static library

Each shader string is now part of a separate .o file, which should make recompiling filamat/matc a tad more enjoyable.

* Shaders.h belongs to filamat, not filament
2018-08-07 12:47:52 -07:00
Tact Yoshida
ad49986245 Remove execute permissions 2018-08-06 10:36:54 -07:00
Romain Guy
55476e97f0 Fix clear coat attenuation for direct lighting
The diffuse term was erroneously multiplied by (1-Fc)^2 after a previous refactoring. The documentation was correct.
2018-08-05 00:10:04 -07:00
Romain Guy
b3d758f3b3 Initial commit 2018-08-03 10:38:22 -07:00