Commit Graph

69 Commits

Author SHA1 Message Date
Mathias Agopian
07bb62490b Add an option to turn dithering on/off 2019-03-12 13:32:28 -07:00
Ben Doherty
1aa4eff190 Fix post processing issue for Metal (#906) 2019-03-01 12:46:53 -08:00
Romain Guy
705c1969b2 Add clearCoatIorChange property to materials (#890)
This property can be used to control the darkening of the base layer
due to a change in index of refraction when going through the clear
coat layer.
2019-02-27 10:30:46 -08:00
Pixelflinger
8a6de4cff1 Fix fxaa offset (#868)
vertex shader interpolants are interpolated at pixel centers by the GPU,
but we were doing our own "pixel-center" adjustment, so we ended-up with
"vertex_uv" at a pixel corner instead of center.

with this change, the vertex shader always compute vertex_uv in
fractional texels and the conversion to texture coordinates is done
in the fxaa code.

The half-pixel adjustment is removed.

This leads to sharper looking images because in addition to shifting
everything by 0.5 pixels, this was essentially applying a box-filter
to the whole picture -- kind of like taking 1 mip level down.
2019-02-25 13:22:14 -08:00
Romain Guy
4738e93b83 Replace Cloth DFG approximation with DFG LUT
By removing the Fresnel term (often ommitted from fabric/cloth BRDFs)
we can store the DG term for the cloth BRDF in the 3rd channel of the
existing DFG LUT.
2019-02-21 11:44:52 -08:00
Romain Guy
5b7ad2511e Rename specularIrradiance function in shaders 2019-02-15 10:10:55 +00:00
Ben Doherty
7099682204 Metal driver implementation (#795) 2019-02-14 16:04:28 -08:00
Romain Guy
4327612159 Remove unnecessary function parameter
Our visibility terms don't make use of roughness, only of
roughness^2. This change simplifies the shaders, which will
help for specular AA.
2019-02-06 10:14:05 +09:00
Ben Doherty
a827f4528a Install filamat and dependencies as single static library (#775) 2019-02-04 11:08:45 -08:00
Philip Rideout
69de626ead Rename built-in shader inputs to "inputs" instead of "variables".
In the public docs and materials API, Filament "variables" are custom
interpolants (outputs of VS, inputs of FS). However we internally used
"variables" to also refer to built-in VS inputs.

CodeGenerator had a generateVariable method and a generateVariables
method, which did something completely different. :)
2019-02-01 13:20:13 -08:00
Philip Rideout
c3d957671d Work around FXAA issue with Vulkan Adreno drivers.
Fixes #732.
2019-01-24 11:48:02 -08:00
prideout
91c946cfbd Add workaround for depth invariance on NVIDIA.
Fixes #645.
2019-01-18 13:59:22 -08:00
Romain Guy
f3752a42c8 Document UV flipping behavior and add control attribute (#720)
Materials can disbale this behavior by setting flipUV: false
in the header section of the material definition.

Fixes #672
2019-01-17 11:12:16 -08:00
Romain Guy
8029ad5cc3 Add missing getWorldFromClip() API (#692)
Fixes #671
2019-01-10 16:35:00 -08:00
Ben Doherty
045274bbdb Use glslminifier to minifiy shaders for Release builds (#690) 2019-01-10 10:23:23 -08:00
shartte
cd2786a2ef Fixes #653: Skin normals/tangents before applying world space transform (#656) 2018-12-24 08:50:29 +01:00
Romain Guy
4901f6f72a Fix FXAA computations in mediump (#643)
* Fix FXAA computations in mediump

UV coordinates computed in highp should be passed to the FXAA function
in highp as well. This change also fixes a potential division by 0 which
was causing dir1 to have components set to inifinity, thus breaking the
texture sampling calls below. We fix this with an early exit when a
potential division by 0 is detected. The original code contained a bias
to try to avoid this problem but that bias was not always enough. It
was frequent in mediump to cancel out the bias.

* Update shaders/src/fxaa.fs

Co-Authored-By: romainguy <romainguy@curious-creature.com>
2018-12-14 22:48:26 -08:00
Ben Doherty
b5eb00bdb1 Fix shaders compilation with VS (#641) 2018-12-14 14:03:35 -08:00
Philip Rideout
b375d029d2 Work around CMake issue on win32 with asm-only libs. 2018-12-11 11:23:33 -08:00
Mathias Agopian
ab3dddeb78 add missing @public-api comment 2018-12-10 21:36:20 -08:00
Mathias Agopian
cd00c4bbe8 Add getUserTimeModulo() to materials
This calculates the modulo of the user time by a given value, using
the high precision user time. This is useful for animations without
having to worry about resetting the time.
2018-12-10 21:36:20 -08:00
Mathias Agopian
76b15e895a [MATERIALS BREAK] higher period clock
THIS CHANGE BREAKS MATERIALS.

This adds getUserTime() in shaders/materials, which returns the time
in second since Renderer::resetUserTime() was called.
Two values are provided, the time in second encoded as a float and
the difference between that and the double value, which together allows
to perform high precision time computation when needed.

This change allows longer running animations in materials. Using only
the float value, give millisecond resolution for more than 4h.
2018-12-10 16:28:07 -08:00
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