Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7685736d6c | ||
|
|
b8a3a7f221 | ||
|
|
a157546d82 | ||
|
|
3ec704b91c | ||
|
|
331af7bf35 | ||
|
|
473aff9093 | ||
|
|
6ff08f2ac1 | ||
|
|
3db7f6675e | ||
|
|
e501a15ef2 | ||
|
|
4e8974bcd9 | ||
|
|
7914372707 | ||
|
|
3c794247c3 | ||
|
|
ae12e3a51c | ||
|
|
fdc2ab30c0 | ||
|
|
122541eedc |
@@ -124,11 +124,16 @@ if (LINUX)
|
||||
add_definitions(-DFILAMENT_SUPPORTS_XCB)
|
||||
endif()
|
||||
|
||||
# Default Swiftshader build does not enable the xlib extension
|
||||
if (FILAMENT_SUPPORTS_XLIB AND FILAMENT_USE_SWIFTSHADER)
|
||||
set(FILAMENT_SUPPORTS_XLIB OFF)
|
||||
endif()
|
||||
|
||||
if (FILAMENT_SUPPORTS_XLIB)
|
||||
add_definitions(-DFILAMENT_SUPPORTS_XLIB)
|
||||
endif()
|
||||
|
||||
if (FILAMENT_SUPPORTS_XCB OR FILAMENT_SUPORTS_XLIB)
|
||||
if (FILAMENT_SUPPORTS_XCB OR FILAMENT_SUPPORTS_XLIB)
|
||||
add_definitions(-DFILAMENT_SUPPORTS_X11)
|
||||
set(FILAMENT_SUPPORTS_X11 TRUE)
|
||||
endif()
|
||||
|
||||
@@ -7,3 +7,4 @@ for next branch cut* header.
|
||||
appropriate header in [RELEASE_NOTES.md](./RELEASE_NOTES.md).
|
||||
|
||||
## Release notes for next branch cut
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.google.android.filament:filament-android:1.32.1'
|
||||
implementation 'com.google.android.filament:filament-android:1.32.2'
|
||||
}
|
||||
```
|
||||
|
||||
@@ -51,7 +51,7 @@ Here are all the libraries available in the group `com.google.android.filament`:
|
||||
iOS projects can use CocoaPods to install the latest release:
|
||||
|
||||
```
|
||||
pod 'Filament', '~> 1.32.1'
|
||||
pod 'Filament', '~> 1.32.2'
|
||||
```
|
||||
|
||||
### Snapshots
|
||||
|
||||
@@ -7,6 +7,11 @@ A new header is inserted each time a *tag* is created.
|
||||
Instead, if you are authoring a PR for the main branch, add your release note to
|
||||
[NEW_RELEASE_NOTES.md](./NEW_RELEASE_NOTES.md).
|
||||
|
||||
## v1.32.2
|
||||
|
||||
- lighting: the sun disc was computed in low/medium quality instead of high quality. This will
|
||||
provide performance improvements to mobile devices [⚠️ **Recompile Materials**]
|
||||
|
||||
## v1.32.1
|
||||
|
||||
## v1.32.0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
GROUP=com.google.android.filament
|
||||
VERSION_NAME=1.32.1
|
||||
VERSION_NAME=1.32.2
|
||||
|
||||
POM_DESCRIPTION=Real-time physically based rendering engine for Android.
|
||||
|
||||
|
||||
@@ -5776,7 +5776,7 @@ Since \(\left< cos \theta \right>\) does not depend on \(\phi\) (azimuthal
|
||||
|
||||
$$\begin{align*}
|
||||
C^0_l &= 2\pi \int_0^{\pi} \left< cos \theta \right> y^0_l(\theta) sin \theta d\theta \\
|
||||
C^0_l &= 2\pi K^)_l \int_0^{\frac{\pi}{2}} P^0_l(cos \theta) cos \theta sin \theta d\theta \\
|
||||
C^0_l &= 2\pi K^m_l \int_0^{\frac{\pi}{2}} P^0_l(cos \theta) cos \theta sin \theta d\theta \\
|
||||
C^m_l &= 0, m != 0
|
||||
\end{align*}$$
|
||||
|
||||
|
||||
@@ -109,16 +109,17 @@ counter-increment: h6;margin-right:10px}
|
||||
<a href="#materialdefinitions/materialblock/rasterization:depthwrite" class="level3"><span class="tocNumber">4.2.22 </span>Rasterization: depthWrite</a><br>
|
||||
<a href="#materialdefinitions/materialblock/rasterization:depthculling" class="level3"><span class="tocNumber">4.2.23 </span>Rasterization: depthCulling</a><br>
|
||||
<a href="#materialdefinitions/materialblock/rasterization:doublesided" class="level3"><span class="tocNumber">4.2.24 </span>Rasterization: doubleSided</a><br>
|
||||
<a href="#materialdefinitions/materialblock/lighting:reflections" class="level3"><span class="tocNumber">4.2.25 </span>Lighting: reflections</a><br>
|
||||
<a href="#materialdefinitions/materialblock/lighting:shadowmultiplier" class="level3"><span class="tocNumber">4.2.26 </span>Lighting: shadowMultiplier</a><br>
|
||||
<a href="#materialdefinitions/materialblock/lighting:transparentshadow" class="level3"><span class="tocNumber">4.2.27 </span>Lighting: transparentShadow</a><br>
|
||||
<a href="#materialdefinitions/materialblock/lighting:clearcoatiorchange" class="level3"><span class="tocNumber">4.2.28 </span>Lighting: clearCoatIorChange</a><br>
|
||||
<a href="#materialdefinitions/materialblock/lighting:multibounceambientocclusion" class="level3"><span class="tocNumber">4.2.29 </span>Lighting: multiBounceAmbientOcclusion</a><br>
|
||||
<a href="#materialdefinitions/materialblock/lighting:specularambientocclusion" class="level3"><span class="tocNumber">4.2.30 </span>Lighting: specularAmbientOcclusion</a><br>
|
||||
<a href="#materialdefinitions/materialblock/anti-aliasing:specularantialiasing" class="level3"><span class="tocNumber">4.2.31 </span>Anti-aliasing: specularAntiAliasing</a><br>
|
||||
<a href="#materialdefinitions/materialblock/anti-aliasing:specularantialiasingvariance" class="level3"><span class="tocNumber">4.2.32 </span>Anti-aliasing: specularAntiAliasingVariance</a><br>
|
||||
<a href="#materialdefinitions/materialblock/anti-aliasing:specularantialiasingthreshold" class="level3"><span class="tocNumber">4.2.33 </span>Anti-aliasing: specularAntiAliasingThreshold</a><br>
|
||||
<a href="#materialdefinitions/materialblock/shading:customsurfaceshading" class="level3"><span class="tocNumber">4.2.34 </span>Shading: customSurfaceShading</a><br>
|
||||
<a href="#materialdefinitions/materialblock/rasterization:alphatocoverage" class="level3"><span class="tocNumber">4.2.25 </span>Rasterization: alphaToCoverage</a><br>
|
||||
<a href="#materialdefinitions/materialblock/lighting:reflections" class="level3"><span class="tocNumber">4.2.26 </span>Lighting: reflections</a><br>
|
||||
<a href="#materialdefinitions/materialblock/lighting:shadowmultiplier" class="level3"><span class="tocNumber">4.2.27 </span>Lighting: shadowMultiplier</a><br>
|
||||
<a href="#materialdefinitions/materialblock/lighting:transparentshadow" class="level3"><span class="tocNumber">4.2.28 </span>Lighting: transparentShadow</a><br>
|
||||
<a href="#materialdefinitions/materialblock/lighting:clearcoatiorchange" class="level3"><span class="tocNumber">4.2.29 </span>Lighting: clearCoatIorChange</a><br>
|
||||
<a href="#materialdefinitions/materialblock/lighting:multibounceambientocclusion" class="level3"><span class="tocNumber">4.2.30 </span>Lighting: multiBounceAmbientOcclusion</a><br>
|
||||
<a href="#materialdefinitions/materialblock/lighting:specularambientocclusion" class="level3"><span class="tocNumber">4.2.31 </span>Lighting: specularAmbientOcclusion</a><br>
|
||||
<a href="#materialdefinitions/materialblock/anti-aliasing:specularantialiasing" class="level3"><span class="tocNumber">4.2.32 </span>Anti-aliasing: specularAntiAliasing</a><br>
|
||||
<a href="#materialdefinitions/materialblock/anti-aliasing:specularantialiasingvariance" class="level3"><span class="tocNumber">4.2.33 </span>Anti-aliasing: specularAntiAliasingVariance</a><br>
|
||||
<a href="#materialdefinitions/materialblock/anti-aliasing:specularantialiasingthreshold" class="level3"><span class="tocNumber">4.2.34 </span>Anti-aliasing: specularAntiAliasingThreshold</a><br>
|
||||
<a href="#materialdefinitions/materialblock/shading:customsurfaceshading" class="level3"><span class="tocNumber">4.2.35 </span>Shading: customSurfaceShading</a><br>
|
||||
<a href="#materialdefinitions/vertexblock" class="level2"><span class="tocNumber">4.3 </span>Vertex block</a><br>
|
||||
<a href="#materialdefinitions/vertexblock/materialvertexinputs" class="level3"><span class="tocNumber">4.3.1 </span>Material vertex inputs</a><br>
|
||||
<a href="#materialdefinitions/vertexblock/customvertexattributes" class="level3"><span class="tocNumber">4.3.2 </span>Custom vertex attributes</a><br>
|
||||
@@ -778,7 +779,7 @@ and with (right)</span></center></div></center>
|
||||
|
||||
The <code>bentNormal</code> property defines the average unoccluded direction at a point on the surface. It is
|
||||
used to improve the accuracy of indirect lighting. Bent normals can also improve the quality of
|
||||
specular ambient occlusion (see section <a href="#toc4.2.30">4.2.30</a> about
|
||||
specular ambient occlusion (see section <a href="#toc4.2.31">4.2.31</a> about
|
||||
<code>specularAmbientOcclusion</code>).
|
||||
|
||||
</p><p>
|
||||
@@ -1838,7 +1839,11 @@ non-shader data.
|
||||
ALPHA_TO_COVERAGE is enabled for non-translucent views. See the maskThreshold section for more
|
||||
information.</li></ul>
|
||||
|
||||
<p></p></dd></dl><p></p><pre class="listing tilde"><code><span class="line">material {</span>
|
||||
<p></p></dd></dl><div class="admonition note">When <code>blending</code> is set to <code>masked</code>, alpha to coverage is automatically enabled for the material.
|
||||
If this behavior is undesirable, refer to the <a href="#rasterization:alphatocoverage">Rasterization: alphaToCoverage</a> section to turn
|
||||
alpha to coverage off using the <code>alphaToCoverage</code> property.</div>
|
||||
|
||||
<p></p><pre class="listing tilde"><code><span class="line">material {</span>
|
||||
<span class="line"> blending : transparent</span>
|
||||
<span class="line">}</span></code></pre>
|
||||
<a class="target" name="blendingandtransparency:postlightingblending"> </a><a class="target" name="materialdefinitions/materialblock/blendingandtransparency:postlightingblending"> </a><a class="target" name="toc4.2.15"> </a><h3>Blending and transparency: postLightingBlending</h3>
|
||||
@@ -2054,7 +2059,34 @@ and sorting issues are minimized or eliminated</span></center></div></center>
|
||||
<span class="line"> material.baseColor = materialParams.albedo;</span>
|
||||
<span class="line"> }</span>
|
||||
<span class="line">}</span></code></pre>
|
||||
<a class="target" name="lighting:reflections"> </a><a class="target" name="materialdefinitions/materialblock/lighting:reflections"> </a><a class="target" name="toc4.2.25"> </a><h3>Lighting: reflections</h3>
|
||||
<a class="target" name="rasterization:alphatocoverage"> </a><a class="target" name="materialdefinitions/materialblock/rasterization:alphatocoverage"> </a><a class="target" name="toc4.2.25"> </a><h3>Rasterization: alphaToCoverage</h3>
|
||||
<p>
|
||||
|
||||
|
||||
</p><dl><dt>Type</dt><dd><p> <code>boolean</code>
|
||||
|
||||
</p></dd><dt>Value</dt><dd><p> <code>true</code> or <code>false</code>. Defaults to <code>false</code>.
|
||||
|
||||
</p></dd><dt>Description</dt><dd><p> Enables or disables alpha to coverage. When alpha to coverage is enabled, the coverage of
|
||||
fragment is derived from its alpha. This property is only meaningful when MSAA is enabled.
|
||||
Note: setting <code>blending</code> to <code>masked</code> automatically enables alpha to coverage. If this is not
|
||||
desired, you can override this behavior by setting alpha to coverage to false as in the
|
||||
example below.
|
||||
|
||||
</p></dd></dl><p></p><pre class="listing tilde"><code><span class="line">material {</span>
|
||||
<span class="line"> name : <span class="hljs-string">"Alpha to coverage"</span>,</span>
|
||||
<span class="line"> shadingModel : lit,</span>
|
||||
<span class="line"> blending : masked,</span>
|
||||
<span class="line"> alphaToCoverage : <span class="hljs-literal">false</span></span>
|
||||
<span class="line">}</span>
|
||||
<span class="line"></span>
|
||||
<span class="line">fragment {</span>
|
||||
<span class="line"> void material(inout MaterialInputs material) {</span>
|
||||
<span class="line"> prepareMaterial(material);</span>
|
||||
<span class="line"> material.baseColor = materialParams.albedo;</span>
|
||||
<span class="line"> }</span>
|
||||
<span class="line">}</span></code></pre>
|
||||
<a class="target" name="lighting:reflections"> </a><a class="target" name="materialdefinitions/materialblock/lighting:reflections"> </a><a class="target" name="toc4.2.26"> </a><h3>Lighting: reflections</h3>
|
||||
<p>
|
||||
|
||||
|
||||
@@ -2071,7 +2103,7 @@ and sorting issues are minimized or eliminated</span></center></div></center>
|
||||
<span class="line"> name : <span class="hljs-string">"Glossy metal"</span>,</span>
|
||||
<span class="line"> reflections : screenspace</span>
|
||||
<span class="line">}</span></code></pre>
|
||||
<a class="target" name="lighting:shadowmultiplier"> </a><a class="target" name="materialdefinitions/materialblock/lighting:shadowmultiplier"> </a><a class="target" name="toc4.2.26"> </a><h3>Lighting: shadowMultiplier</h3>
|
||||
<a class="target" name="lighting:shadowmultiplier"> </a><a class="target" name="materialdefinitions/materialblock/lighting:shadowmultiplier"> </a><a class="target" name="toc4.2.27"> </a><h3>Lighting: shadowMultiplier</h3>
|
||||
<p>
|
||||
|
||||
|
||||
@@ -2098,7 +2130,7 @@ and sorting issues are minimized or eliminated</span></center></div></center>
|
||||
<span class="line"> material.baseColor = vec4(0.0, 0.0, 0.0, 0.7);</span>
|
||||
<span class="line"> }</span>
|
||||
<span class="line">}</span></code></pre>
|
||||
<a class="target" name="lighting:transparentshadow"> </a><a class="target" name="materialdefinitions/materialblock/lighting:transparentshadow"> </a><a class="target" name="toc4.2.27"> </a><h3>Lighting: transparentShadow</h3>
|
||||
<a class="target" name="lighting:transparentshadow"> </a><a class="target" name="materialdefinitions/materialblock/lighting:transparentshadow"> </a><a class="target" name="toc4.2.28"> </a><h3>Lighting: transparentShadow</h3>
|
||||
<p>
|
||||
|
||||
|
||||
@@ -2132,7 +2164,7 @@ radius of 4. Model <a href="https://sketchfab.com/3d-models/bottle-of-water-48fd
|
||||
by <a href="https://sketchfab.com/person-x">T-Art</a>.</span></center></div></center>
|
||||
|
||||
<p></p>
|
||||
<a class="target" name="lighting:clearcoatiorchange"> </a><a class="target" name="materialdefinitions/materialblock/lighting:clearcoatiorchange"> </a><a class="target" name="toc4.2.28"> </a><h3>Lighting: clearCoatIorChange</h3>
|
||||
<a class="target" name="lighting:clearcoatiorchange"> </a><a class="target" name="materialdefinitions/materialblock/lighting:clearcoatiorchange"> </a><a class="target" name="toc4.2.29"> </a><h3>Lighting: clearCoatIorChange</h3>
|
||||
<p>
|
||||
|
||||
|
||||
@@ -2154,7 +2186,7 @@ with <code>clearCoatIorChange</code> enabled (left) and disabled
|
||||
(right).</span></center></div></center>
|
||||
|
||||
<p></p>
|
||||
<a class="target" name="lighting:multibounceambientocclusion"> </a><a class="target" name="materialdefinitions/materialblock/lighting:multibounceambientocclusion"> </a><a class="target" name="toc4.2.29"> </a><h3>Lighting: multiBounceAmbientOcclusion</h3>
|
||||
<a class="target" name="lighting:multibounceambientocclusion"> </a><a class="target" name="materialdefinitions/materialblock/lighting:multibounceambientocclusion"> </a><a class="target" name="toc4.2.30"> </a><h3>Lighting: multiBounceAmbientOcclusion</h3>
|
||||
<p>
|
||||
|
||||
|
||||
@@ -2183,7 +2215,7 @@ occclusion enabled (left) and disabled (right).</span></center></div></center>
|
||||
occclusion enabled and disabled.</span></center></div></center>
|
||||
|
||||
<p></p>
|
||||
<a class="target" name="lighting:specularambientocclusion"> </a><a class="target" name="materialdefinitions/materialblock/lighting:specularambientocclusion"> </a><a class="target" name="toc4.2.30"> </a><h3>Lighting: specularAmbientOcclusion</h3>
|
||||
<a class="target" name="lighting:specularambientocclusion"> </a><a class="target" name="materialdefinitions/materialblock/lighting:specularambientocclusion"> </a><a class="target" name="toc4.2.31"> </a><h3>Lighting: specularAmbientOcclusion</h3>
|
||||
<p>
|
||||
|
||||
|
||||
@@ -2209,7 +2241,7 @@ occclusion enabled and disabled.</span></center></div></center>
|
||||
particularly visible under the hose.</span></center></div></center>
|
||||
|
||||
<p></p>
|
||||
<a class="target" name="anti-aliasing:specularantialiasing"> </a><a class="target" name="materialdefinitions/materialblock/anti-aliasing:specularantialiasing"> </a><a class="target" name="toc4.2.31"> </a><h3>Anti-aliasing: specularAntiAliasing</h3>
|
||||
<a class="target" name="anti-aliasing:specularantialiasing"> </a><a class="target" name="materialdefinitions/materialblock/anti-aliasing:specularantialiasing"> </a><a class="target" name="toc4.2.32"> </a><h3>Anti-aliasing: specularAntiAliasing</h3>
|
||||
<p>
|
||||
|
||||
|
||||
@@ -2226,7 +2258,7 @@ particularly visible under the hose.</span></center></div></center>
|
||||
</p></dd></dl><p></p><pre class="listing tilde"><code><span class="line">material {</span>
|
||||
<span class="line"> specularAntiAliasing : <span class="hljs-literal">true</span></span>
|
||||
<span class="line">}</span></code></pre>
|
||||
<a class="target" name="anti-aliasing:specularantialiasingvariance"> </a><a class="target" name="materialdefinitions/materialblock/anti-aliasing:specularantialiasingvariance"> </a><a class="target" name="toc4.2.32"> </a><h3>Anti-aliasing: specularAntiAliasingVariance</h3>
|
||||
<a class="target" name="anti-aliasing:specularantialiasingvariance"> </a><a class="target" name="materialdefinitions/materialblock/anti-aliasing:specularantialiasingvariance"> </a><a class="target" name="toc4.2.33"> </a><h3>Anti-aliasing: specularAntiAliasingVariance</h3>
|
||||
<p>
|
||||
|
||||
|
||||
@@ -2241,7 +2273,7 @@ particularly visible under the hose.</span></center></div></center>
|
||||
</p></dd></dl><p></p><pre class="listing tilde"><code><span class="line">material {</span>
|
||||
<span class="line"> specularAntiAliasingVariance : <span class="hljs-number">0.2</span></span>
|
||||
<span class="line">}</span></code></pre>
|
||||
<a class="target" name="anti-aliasing:specularantialiasingthreshold"> </a><a class="target" name="materialdefinitions/materialblock/anti-aliasing:specularantialiasingthreshold"> </a><a class="target" name="toc4.2.33"> </a><h3>Anti-aliasing: specularAntiAliasingThreshold</h3>
|
||||
<a class="target" name="anti-aliasing:specularantialiasingthreshold"> </a><a class="target" name="materialdefinitions/materialblock/anti-aliasing:specularantialiasingthreshold"> </a><a class="target" name="toc4.2.34"> </a><h3>Anti-aliasing: specularAntiAliasingThreshold</h3>
|
||||
<p>
|
||||
|
||||
|
||||
@@ -2255,7 +2287,7 @@ particularly visible under the hose.</span></center></div></center>
|
||||
</p></dd></dl><p></p><pre class="listing tilde"><code><span class="line">material {</span>
|
||||
<span class="line"> specularAntiAliasingThreshold : <span class="hljs-number">0.1</span></span>
|
||||
<span class="line">}</span></code></pre>
|
||||
<a class="target" name="shading:customsurfaceshading"> </a><a class="target" name="materialdefinitions/materialblock/shading:customsurfaceshading"> </a><a class="target" name="toc4.2.34"> </a><h3>Shading: customSurfaceShading</h3>
|
||||
<a class="target" name="shading:customsurfaceshading"> </a><a class="target" name="materialdefinitions/materialblock/shading:customsurfaceshading"> </a><a class="target" name="toc4.2.35"> </a><h3>Shading: customSurfaceShading</h3>
|
||||
<p>
|
||||
|
||||
|
||||
@@ -2335,8 +2367,9 @@ APIs listed in the <a href="#shaderpublicapis">Shader public APIs</a> section.
|
||||
<p></p><p>
|
||||
|
||||
To achieve good precision, the <code>worldPosition</code> coordinate in the vertex shader is shifted by the
|
||||
camera position. To get the true world-space position, users can add this to
|
||||
<code>getWorldOffset()</code>.</p></div>
|
||||
camera position. To get the true world-space position, users can use
|
||||
<code>getUserWorldPosition()</code>, however be aware that the true world-position might not
|
||||
be able to fit in a <code>float</code> or might be represented with severely reduced precision.</p></div>
|
||||
|
||||
<p></p><p>
|
||||
|
||||
@@ -2707,9 +2740,10 @@ type aliases:
|
||||
<p>
|
||||
|
||||
</p><div class="table"><table class="table"><tbody><tr><th style="text-align:left"> Name </th><th style="text-align:center"> Type </th><th style="text-align:left"> Description </th></tr>
|
||||
<tr><td style="text-align:left"> <strong class="asterisk">getResolution()</strong> </td><td style="text-align:center"> float4 </td><td style="text-align:left"> Dimensions of the view's effective viewport in pixels: <code>width</code>, <code>height</code>, <code>1 / width</code>, <code>1 / height</code>. This might be different from <code>View::getViewport()</code> for instance because of added rendering guard-bands. This can be used in conjunction with <code>getNormalizedViewportCoord()</code> to generate pixel coordinates. </td></tr>
|
||||
<tr><td style="text-align:left"> <strong class="asterisk">getWorldCameraPosition()</strong> </td><td style="text-align:center"> float3 </td><td style="text-align:left"> Position of the camera/eye in world space </td></tr>
|
||||
<tr><td style="text-align:left"> <strong class="asterisk">getWorldOffset()</strong> </td><td style="text-align:center"> float3 </td><td style="text-align:left"> The shift required to obtain API-level world space </td></tr>
|
||||
<tr><td style="text-align:left"> <strong class="asterisk">getResolution()</strong> </td><td style="text-align:center"> float4 </td><td style="text-align:left"> Dimensions of the view's effective (physical) viewport in pixels: <code>width</code>, <code>height</code>, <code>1 / width</code>, <code>1 / height</code>. This might be different from <code>View::getViewport()</code> for instance because of added rendering guard-bands. </td></tr>
|
||||
<tr><td style="text-align:left"> <strong class="asterisk">getWorldCameraPosition()</strong> </td><td style="text-align:center"> float3 </td><td style="text-align:left"> Position of the camera/eye in world space (see note below) </td></tr>
|
||||
<tr><td style="text-align:left"> <strong class="asterisk">getWorldOffset()</strong> </td><td style="text-align:center"> float3 </td><td style="text-align:left"> [deprecated] The shift required to obtain API-level world space. Use getUserWorldPosition() instead </td></tr>
|
||||
<tr><td style="text-align:left"> <strong class="asterisk">getUserWorldFromWorldMatrix()</strong> </td><td style="text-align:center"> float4×4 </td><td style="text-align:left"> Matrix that converts from world space to API-level (user) world space. </td></tr>
|
||||
<tr><td style="text-align:left"> <strong class="asterisk">getTime()</strong> </td><td style="text-align:center"> float </td><td style="text-align:left"> Current time as a remainder of 1 second. Yields a value between 0 and 1 </td></tr>
|
||||
<tr><td style="text-align:left"> <strong class="asterisk">getUserTime()</strong> </td><td style="text-align:center"> float4 </td><td style="text-align:left"> Current time in seconds: <code>time</code>, <code>(double)time - time</code>, <code>0</code>, <code>0</code> </td></tr>
|
||||
<tr><td style="text-align:left"> <strong class="asterisk">getUserTimeMode(float m)</strong> </td><td style="text-align:center"> float </td><td style="text-align:left"> Current time modulo m in seconds </td></tr>
|
||||
@@ -2725,7 +2759,7 @@ type aliases:
|
||||
|
||||
To achieve good precision, the “world space” in Filament's shading system does not necessarily
|
||||
match the API-level world space. To obtain the position of the API-level camera, custom
|
||||
materials can add <code>getWorldOffset()</code> to <code>getWorldCameraPosition()</code>.</p></div>
|
||||
materials can use <code>getUserWorldFromWorldMatrix()</code> to transform <code>getWorldCameraPosition()</code>.</p></div>
|
||||
|
||||
<p></p>
|
||||
<a class="target" name="vertexonly"> </a><a class="target" name="materialdefinitions/shaderpublicapis/vertexonly"> </a><a class="target" name="toc4.5.5"> </a><h3>Vertex only</h3>
|
||||
@@ -2750,11 +2784,12 @@ The following APIs are only available from the fragment block:
|
||||
</p><div class="table"><table class="table"><tbody><tr><th style="text-align:left"> Name </th><th style="text-align:center"> Type </th><th style="text-align:left"> Description </th></tr>
|
||||
<tr><td style="text-align:left"> <strong class="asterisk">getWorldTangentFrame()</strong> </td><td style="text-align:center"> float3×3 </td><td style="text-align:left"> Matrix containing in each column the <code>tangent</code> (<code>frame[0]</code>), <code>bi-tangent</code> (<code>frame[1]</code>) and <code>normal</code> (<code>frame[2]</code>) of the vertex in world space. If the material does not compute a tangent space normal for bump mapping or if the shading is not anisotropic, only the <code>normal</code> is valid in this matrix. </td></tr>
|
||||
<tr><td style="text-align:left"> <strong class="asterisk">getWorldPosition()</strong> </td><td style="text-align:center"> float3 </td><td style="text-align:left"> Position of the fragment in world space (see note below about world-space) </td></tr>
|
||||
<tr><td style="text-align:left"> <strong class="asterisk">getUserWorldPosition()</strong> </td><td style="text-align:center"> float3 </td><td style="text-align:left"> Position of the fragment in API-level (user) world-space (see note below about world-space) </td></tr>
|
||||
<tr><td style="text-align:left"> <strong class="asterisk">getWorldViewVector()</strong> </td><td style="text-align:center"> float3 </td><td style="text-align:left"> Normalized vector in world space from the fragment position to the eye </td></tr>
|
||||
<tr><td style="text-align:left"> <strong class="asterisk">getWorldNormalVector()</strong> </td><td style="text-align:center"> float3 </td><td style="text-align:left"> Normalized normal in world space, after bump mapping (must be used after <code>prepareMaterial()</code>) </td></tr>
|
||||
<tr><td style="text-align:left"> <strong class="asterisk">getWorldGeometricNormalVector()</strong> </td><td style="text-align:center"> float3 </td><td style="text-align:left"> Normalized normal in world space, before bump mapping (can be used before <code>prepareMaterial()</code>) </td></tr>
|
||||
<tr><td style="text-align:left"> <strong class="asterisk">getWorldReflectedVector()</strong> </td><td style="text-align:center"> float3 </td><td style="text-align:left"> Reflection of the view vector about the normal (must be used after <code>prepareMaterial()</code>) </td></tr>
|
||||
<tr><td style="text-align:left"> <strong class="asterisk">getNormalizedViewportCoord()</strong> </td><td style="text-align:center"> float3 </td><td style="text-align:left"> Normalized viewport position (i.e. NDC coordinates normalized to [0, 1], can be used before <code>prepareMaterial()</code>) </td></tr>
|
||||
<tr><td style="text-align:left"> <strong class="asterisk">getNormalizedViewportCoord()</strong> </td><td style="text-align:center"> float3 </td><td style="text-align:left"> Normalized user viewport position (i.e. NDC coordinates normalized to [0, 1] for the position, [1, 0] for the depth), can be used before <code>prepareMaterial()</code>). Because the user viewport is smaller than the actual physical viewport, these coordinates can be negative or superior to 1 in the non-visible area of the physical viewport. </td></tr>
|
||||
<tr><td style="text-align:left"> <strong class="asterisk">getNdotV()</strong> </td><td style="text-align:center"> float </td><td style="text-align:left"> The result of <code>dot(normal, view)</code>, always strictly greater than 0 (must be used after <code>prepareMaterial()</code>) </td></tr>
|
||||
<tr><td style="text-align:left"> <strong class="asterisk">getColor()</strong> </td><td style="text-align:center"> float4 </td><td style="text-align:left"> Interpolated color of the fragment, if the color attribute is required </td></tr>
|
||||
<tr><td style="text-align:left"> <strong class="asterisk">getUV0()</strong> </td><td style="text-align:center"> float2 </td><td style="text-align:left"> First interpolated set of UV coordinates, only available if the uv0 attribute is required </td></tr>
|
||||
@@ -2769,12 +2804,13 @@ The following APIs are only available from the fragment block:
|
||||
|
||||
<p></p><p>
|
||||
|
||||
</p><div class="admonition tip"><div class="admonition-title"> world space</div>
|
||||
</p><div class="admonition tip"><div class="admonition-title"> world-space</div>
|
||||
|
||||
<p></p><p>
|
||||
|
||||
To obtain API-level world space coordinates, custom materials should add <code>getWorldOffset()</code> to
|
||||
<code>getWorldPosition()</code> (et al).</p></div>
|
||||
To obtain API-level world-space coordinates, custom materials should use <code>getUserWorldPosition()</code>
|
||||
or use <code>getUserWorldFromWorldMatrix()</code>. Note that API-level world-space coordinates should
|
||||
never or rarely be used because they may not fit in a float3 or have severely reduced precision.</p></div>
|
||||
|
||||
<p></p><p>
|
||||
|
||||
|
||||
@@ -2306,7 +2306,7 @@ type aliases:
|
||||
**getUserWorldFromWorldMatrix()** | float4x4 | Matrix that converts from world space to API-level (user) world space.
|
||||
**getTime()** | float | Current time as a remainder of 1 second. Yields a value between 0 and 1
|
||||
**getUserTime()** | float4 | Current time in seconds: `time`, `(double)time - time`, `0`, `0`
|
||||
**getUserTimeMode(float m)** | float | Current time modulo m in seconds
|
||||
**getUserTimeMod(float m)** | float | Current time modulo m in seconds
|
||||
**getExposure()** | float | Photometric exposure of the camera
|
||||
**getEV100()** | float | [Exposure value at ISO 100](https://en.wikipedia.org/wiki/Exposure_value) of the camera
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <filament/Scene.h>
|
||||
#include <filament/View.h>
|
||||
#include <filament/Viewport.h>
|
||||
#include <filament/ColorGrading.h>
|
||||
|
||||
#include <utils/EntityManager.h>
|
||||
|
||||
@@ -41,7 +40,6 @@ protected:
|
||||
Scene* mScene = nullptr;
|
||||
Camera* mCamera = nullptr;
|
||||
utils::Entity mCameraEntity;
|
||||
ColorGrading* mColorGrading = nullptr;
|
||||
|
||||
using closure_t = std::function<void(uint8_t const* rgba, uint32_t width, uint32_t height)>;
|
||||
|
||||
@@ -59,20 +57,13 @@ protected:
|
||||
mView->setViewport({0, 0, 16, 16});
|
||||
mView->setScene(mScene);
|
||||
mView->setCamera(mCamera);
|
||||
|
||||
LinearToneMapper linearToneMapper;
|
||||
mColorGrading = ColorGrading::Builder()
|
||||
.toneMapper(&linearToneMapper)
|
||||
.build(*mEngine);
|
||||
mView->setColorGrading(mColorGrading);
|
||||
mView->setPostProcessingEnabled(false);
|
||||
|
||||
mSkybox = Skybox::Builder().build(*mEngine);
|
||||
mScene->setSkybox(mSkybox);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
mEngine->destroy(mColorGrading);
|
||||
|
||||
mEngine->destroyCameraComponent(mCameraEntity);
|
||||
utils::EntityManager::get().destroy(mCameraEntity);
|
||||
|
||||
@@ -115,27 +106,29 @@ private:
|
||||
};
|
||||
|
||||
TEST_F(RenderingTest, ClearRed) {
|
||||
// We need to clear red to >1 here to ensure a tonemapped value of 255 regardless of LUT
|
||||
// precision.
|
||||
mSkybox->setColor({ 2.0f, 0.0f, 0.0f, 1.0f });
|
||||
mSkybox->setColor({ 1.0f, 0.0f, 0.0f, 1.0f });
|
||||
mView->setDithering(View::Dithering::NONE);
|
||||
runTest([this](uint8_t const* rgba, uint32_t width, uint32_t height) {
|
||||
bool callbackCalled = false;
|
||||
runTest([this, &callbackCalled](uint8_t const* rgba, uint32_t width, uint32_t height) {
|
||||
EXPECT_EQ(rgba[0], 0xff);
|
||||
EXPECT_EQ(rgba[1], 0);
|
||||
EXPECT_EQ(rgba[2], 0);
|
||||
EXPECT_EQ(rgba[3], 0xff);
|
||||
callbackCalled = true;
|
||||
});
|
||||
EXPECT_TRUE(callbackCalled);
|
||||
}
|
||||
|
||||
TEST_F(RenderingTest, ClearGreen) {
|
||||
// We need to clear green to >1 here to ensure a tonemapped value of 255 regardless of LUT
|
||||
// precision.
|
||||
mSkybox->setColor({ 0.0f, 2.0f, 0.0f, 1.0f });
|
||||
mSkybox->setColor({ 0.0f, 1.0f, 0.0f, 1.0f });
|
||||
mView->setDithering(View::Dithering::NONE);
|
||||
runTest([this](uint8_t const* rgba, uint32_t width, uint32_t height) {
|
||||
bool callbackCalled = false;
|
||||
runTest([this, &callbackCalled](uint8_t const* rgba, uint32_t width, uint32_t height) {
|
||||
EXPECT_EQ(rgba[0], 0);
|
||||
EXPECT_EQ(rgba[1], 0xff);
|
||||
EXPECT_EQ(rgba[2], 0);
|
||||
EXPECT_EQ(rgba[3], 0xff);
|
||||
callbackCalled = true;
|
||||
});
|
||||
EXPECT_TRUE(callbackCalled);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
Pod::Spec.new do |spec|
|
||||
spec.name = "Filament"
|
||||
spec.version = "1.32.1"
|
||||
spec.version = "1.32.2"
|
||||
spec.license = { :type => "Apache 2.0", :file => "LICENSE" }
|
||||
spec.homepage = "https://google.github.io/filament"
|
||||
spec.authors = "Google LLC."
|
||||
spec.summary = "Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WASM/WebGL."
|
||||
spec.platform = :ios, "11.0"
|
||||
spec.source = { :http => "https://github.com/google/filament/releases/download/v1.32.1/filament-v1.32.1-ios.tgz" }
|
||||
spec.source = { :http => "https://github.com/google/filament/releases/download/v1.32.2/filament-v1.32.2-ios.tgz" }
|
||||
|
||||
# Fix linking error with Xcode 12; we do not yet support the simulator on Apple silicon.
|
||||
spec.pod_target_xcconfig = {
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
|
||||
#include <tsl/robin_map.h>
|
||||
|
||||
#include <utils/Invocable.h>
|
||||
|
||||
namespace filaflat {
|
||||
|
||||
class MaterialChunk {
|
||||
@@ -43,6 +45,9 @@ public:
|
||||
bool getShader(ShaderContent& shaderContent, BlobDictionary const& dictionary,
|
||||
uint8_t shaderModel, Variant variant, uint8_t stage);
|
||||
|
||||
void visitTextShaders(
|
||||
utils::Invocable<void(uint8_t, Variant::type_t, uint8_t)>&& visitor) const;
|
||||
|
||||
// These methods are for debugging purposes only (matdbg)
|
||||
// @{
|
||||
static void decodeKey(uint32_t key, uint8_t* model, Variant::type_t* variant, uint8_t* stage);
|
||||
|
||||
@@ -175,5 +175,34 @@ bool MaterialChunk::getShader(ShaderContent& shaderContent,
|
||||
}
|
||||
}
|
||||
|
||||
void MaterialChunk::visitTextShaders(
|
||||
utils::Invocable<void(uint8_t, Variant::type_t, uint8_t)>&& visitor) const {
|
||||
assert_invariant(mMaterialTag != filamat::ChunkType::MaterialSpirv);
|
||||
|
||||
Unflattener unflattener{ mUnflattener }; // make a copy
|
||||
|
||||
// read() calls below cannot fail by construction, because we've already run through them
|
||||
// in the constructor.
|
||||
|
||||
// Read how many shaders we have in the chunk.
|
||||
uint64_t numShaders;
|
||||
unflattener.read(&numShaders);
|
||||
|
||||
// Read all index entries.
|
||||
for (uint64_t i = 0; i < numShaders; i++) {
|
||||
uint8_t shaderModelValue;
|
||||
filament::Variant variant;
|
||||
uint8_t pipelineStageValue;
|
||||
uint32_t offsetValue;
|
||||
|
||||
unflattener.read(&shaderModelValue);
|
||||
unflattener.read(&variant);
|
||||
unflattener.read(&pipelineStageValue);
|
||||
unflattener.read(&offsetValue);
|
||||
|
||||
visitor(shaderModelValue, variant.key, pipelineStageValue);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace filaflat
|
||||
|
||||
|
||||
@@ -645,9 +645,9 @@ io::sstream& CodeGenerator::generateQualityDefine(io::sstream& out, ShaderQualit
|
||||
switch (quality) {
|
||||
case ShaderQuality::DEFAULT:
|
||||
switch (mShaderModel) {
|
||||
default: goto quality_normal;
|
||||
case ShaderModel::DESKTOP: goto quality_high;
|
||||
case ShaderModel::MOBILE: goto quality_low;
|
||||
default: goto quality_normal;
|
||||
case ShaderModel::DESKTOP: goto quality_high;
|
||||
case ShaderModel::MOBILE: goto quality_low;
|
||||
}
|
||||
case ShaderQuality::LOW:
|
||||
quality_low:
|
||||
|
||||
@@ -197,6 +197,17 @@ void Ktx2Provider::cancelDecoding() {
|
||||
// in-flight jobs. We should consider throttling the number of simultaneous decoder jobs, which
|
||||
// would allow for actual cancellation.
|
||||
waitForCompletion();
|
||||
|
||||
// For cancelled jobs, we need to set the QueueItemState to POPPED and free the decoded data
|
||||
// stored in item->async.
|
||||
for (auto& item : mQueueItems) {
|
||||
if (item->state != QueueItemState::TRANSCODING) {
|
||||
continue;
|
||||
}
|
||||
mKtxReader->asyncDestroy(&item->async);
|
||||
item->async = nullptr;
|
||||
item->state = QueueItemState::POPPED;
|
||||
}
|
||||
}
|
||||
|
||||
const char* Ktx2Provider::getPushMessage() const {
|
||||
|
||||
@@ -219,6 +219,22 @@ void StbProvider::cancelDecoding() {
|
||||
// in-flight jobs. We should consider throttling the number of simultaneous decoder jobs, which
|
||||
// would allow for actual cancellation.
|
||||
waitForCompletion();
|
||||
|
||||
// For cancelled jobs, we need to set the TextureInfo to the popped state and free the decoded
|
||||
// data.
|
||||
for (auto& info : mTextures) {
|
||||
if (info->state != TextureState::DECODING) {
|
||||
continue;
|
||||
}
|
||||
// Deleting data here should be safe thread-wise as the only other place where
|
||||
// decodedTexelsBaseMipmap is loaded is in the job threads, and we have waited them to
|
||||
// completion above. We also expect the TextureProvider API calls to be made only from one
|
||||
// thread.
|
||||
if (intptr_t data = info->decodedTexelsBaseMipmap.load()) {
|
||||
delete [] (uint8_t*) data;
|
||||
}
|
||||
info->state = TextureState::POPPED;
|
||||
}
|
||||
}
|
||||
|
||||
const char* StbProvider::getPushMessage() const {
|
||||
|
||||
@@ -142,7 +142,7 @@ class Ktx2Reader {
|
||||
|
||||
protected:
|
||||
Async() noexcept = default;
|
||||
~Async() = default;
|
||||
virtual ~Async();
|
||||
|
||||
public:
|
||||
Async(Async const&) = delete;
|
||||
|
||||
@@ -172,6 +172,9 @@ public:
|
||||
Result doTranscoding();
|
||||
void uploadImages();
|
||||
|
||||
protected:
|
||||
~FAsync();
|
||||
|
||||
private:
|
||||
using TranscoderResult = std::atomic<Texture::PixelBufferDescriptor*>;
|
||||
|
||||
@@ -260,6 +263,15 @@ Texture* Ktx2Reader::load(const void* data, size_t size, TransferFunction transf
|
||||
return texture;
|
||||
}
|
||||
|
||||
FAsync::~FAsync() {
|
||||
for (TranscoderResult& level : mTranscoderResults) {
|
||||
Texture::PixelBufferDescriptor* pbd = level.load();
|
||||
if (pbd) {
|
||||
delete pbd;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Result FAsync::doTranscoding() {
|
||||
ktx2_transcoder_state basisThreadState;
|
||||
basisThreadState.clear();
|
||||
@@ -412,6 +424,8 @@ Texture* Ktx2Reader::createTexture(ktx2_transcoder* transcoder, const void* data
|
||||
return texture;
|
||||
}
|
||||
|
||||
Async::~Async() = default;
|
||||
|
||||
Texture* Async::getTexture() const noexcept {
|
||||
return static_cast<FAsync const*>(this)->getTexture();
|
||||
}
|
||||
|
||||
@@ -306,18 +306,19 @@ ShaderIndex::ShaderIndex(ChunkType dictTag, ChunkType matTag, const filaflat::Ch
|
||||
filaflat::MaterialChunk matChunk(cc);
|
||||
matChunk.initialize(matTag);
|
||||
|
||||
const auto& offsets = matChunk.getOffsets();
|
||||
mShaderRecords.reserve(offsets.size());
|
||||
for (auto [key, offset] : offsets) {
|
||||
TextEntry info;
|
||||
filaflat::MaterialChunk::decodeKey(key, &info.shaderModel, &info.variantKey, &info.stage);
|
||||
matChunk.visitTextShaders(
|
||||
[this, &matChunk, &stringBlobs](uint8_t shaderModel, Variant::type_t variant,
|
||||
uint8_t stage) {
|
||||
|
||||
ShaderContent content;
|
||||
UTILS_UNUSED_IN_RELEASE bool success = matChunk.getShader(content,
|
||||
stringBlobs, info.shaderModel, Variant(info.variantKey), info.stage);
|
||||
info.shader = std::string(content.data(), content.data() + content.size() - 1);
|
||||
stringBlobs, shaderModel, Variant(variant), stage);
|
||||
|
||||
std::string source{content.data(), content.data() + content.size() - 1u};
|
||||
assert_invariant(success);
|
||||
mShaderRecords.emplace_back(info);
|
||||
}
|
||||
|
||||
mShaderRecords.push_back({ shaderModel, variant, stage, std::move(source) });
|
||||
});
|
||||
}
|
||||
|
||||
void ShaderIndex::writeChunks(ostream& stream) {
|
||||
|
||||
@@ -82,7 +82,7 @@ using LightManager = filament::LightManager;
|
||||
void applySettings(Engine* engine, const ViewSettings& settings, View* dest);
|
||||
void applySettings(Engine* engine, const MaterialSettings& settings, MaterialInstance* dest);
|
||||
void applySettings(Engine* engine, const LightSettings& settings, IndirectLight* ibl, utils::Entity sunlight,
|
||||
utils::Entity* sceneLights, size_t sceneLightCount, LightManager* lm, Scene* scene, View* view);
|
||||
const utils::Entity* sceneLights, size_t sceneLightCount, LightManager* lm, Scene* scene, View* view);
|
||||
void applySettings(Engine* engine, const ViewerOptions& settings, Camera* camera, Skybox* skybox,
|
||||
Renderer* renderer);
|
||||
|
||||
@@ -204,6 +204,9 @@ struct LightSettings {
|
||||
LightManager::ShadowOptions shadowOptions;
|
||||
SoftShadowOptions softShadowOptions;
|
||||
float sunlightIntensity = 100000.0f;
|
||||
float sunlightHaloSize = 10.0f;
|
||||
float sunlightHaloFalloff = 80.0f;
|
||||
float sunlightAngularRadius = 1.9f;
|
||||
math::float3 sunlightDirection = {0.6, -1.0, -0.8};
|
||||
math::float3 sunlightColor = filament::Color::toLinear<filament::ACCURATE>({ 0.98, 0.92, 0.89});
|
||||
float iblIntensity = 30000.0f;
|
||||
|
||||
@@ -234,8 +234,6 @@ public:
|
||||
private:
|
||||
using SceneMask = gltfio::NodeManager::SceneMask;
|
||||
|
||||
void updateIndirectLight();
|
||||
|
||||
bool isRemoteMode() const { return mAsset == nullptr; }
|
||||
|
||||
void sceneSelectionUI();
|
||||
|
||||
@@ -412,6 +412,12 @@ static int parse(jsmntok_t const* tokens, int i, const char* jsonChunk, LightSet
|
||||
i = parse(tokens, i + 1, jsonChunk, &out->softShadowOptions);
|
||||
} else if (compare(tok, jsonChunk, "sunlightIntensity") == 0) {
|
||||
i = parse(tokens, i + 1, jsonChunk, &out->sunlightIntensity);
|
||||
} else if (compare(tok, jsonChunk, "sunlightHaloSize") == 0) {
|
||||
i = parse(tokens, i + 1, jsonChunk, &out->sunlightHaloSize);
|
||||
} else if (compare(tok, jsonChunk, "sunlightHaloFalloff") == 0) {
|
||||
i = parse(tokens, i + 1, jsonChunk, &out->sunlightHaloFalloff);
|
||||
} else if (compare(tok, jsonChunk, "sunlightAngularRadius") == 0) {
|
||||
i = parse(tokens, i + 1, jsonChunk, &out->sunlightAngularRadius);
|
||||
} else if (compare(tok, jsonChunk, "sunlightDirection") == 0) {
|
||||
i = parse(tokens, i + 1, jsonChunk, &out->sunlightDirection);
|
||||
} else if (compare(tok, jsonChunk, "sunlightColor") == 0) {
|
||||
@@ -537,7 +543,7 @@ void applySettings(Engine* engine, const MaterialSettings& settings, MaterialIns
|
||||
}
|
||||
|
||||
void applySettings(Engine* engine, const LightSettings& settings, IndirectLight* ibl, utils::Entity sunlight,
|
||||
utils::Entity* sceneLights, size_t sceneLightCount, LightManager* lm, Scene* scene, View* view) {
|
||||
const utils::Entity* sceneLights, size_t sceneLightCount, LightManager* lm, Scene* scene, View* view) {
|
||||
auto light = lm->getInstance(sunlight);
|
||||
if (light) {
|
||||
if (settings.enableSunlight) {
|
||||
@@ -546,6 +552,9 @@ void applySettings(Engine* engine, const LightSettings& settings, IndirectLight*
|
||||
scene->remove(sunlight);
|
||||
}
|
||||
lm->setIntensity(light, settings.sunlightIntensity);
|
||||
lm->setSunHaloSize(light, settings.sunlightHaloSize);
|
||||
lm->setSunHaloFalloff(light, settings.sunlightHaloFalloff);
|
||||
lm->setSunAngularRadius(light, settings.sunlightAngularRadius);
|
||||
lm->setDirection(light, normalize(settings.sunlightDirection));
|
||||
lm->setColor(light, settings.sunlightColor);
|
||||
lm->setShadowCaster(light, settings.enableShadows);
|
||||
@@ -765,6 +774,9 @@ static std::ostream& operator<<(std::ostream& out, const LightSettings& in) {
|
||||
<< "\"shadowOptions\": " << (in.shadowOptions) << ",\n"
|
||||
<< "\"softShadowOptions\": " << (in.softShadowOptions) << ",\n"
|
||||
<< "\"sunlightIntensity\": " << (in.sunlightIntensity) << ",\n"
|
||||
<< "\"sunlightHaloSize\": " << (in.sunlightHaloSize) << ",\n"
|
||||
<< "\"sunlightHaloFalloff\": " << (in.sunlightHaloFalloff) << ",\n"
|
||||
<< "\"sunlightAngularRadius\": " << (in.sunlightAngularRadius) << ",\n"
|
||||
<< "\"sunlightDirection\": " << (in.sunlightDirection) << ",\n"
|
||||
<< "\"sunlightColor\": " << (in.sunlightColor) << ",\n"
|
||||
<< "\"iblIntensity\": " << (in.iblIntensity) << ",\n"
|
||||
|
||||
@@ -382,9 +382,9 @@ ViewerGui::ViewerGui(filament::Engine* engine, filament::Scene* scene, filament:
|
||||
.intensity(mSettings.lighting.sunlightIntensity)
|
||||
.direction(normalize(mSettings.lighting.sunlightDirection))
|
||||
.castShadows(true)
|
||||
.sunAngularRadius(1.0f)
|
||||
.sunHaloSize(2.0f)
|
||||
.sunHaloFalloff(80.0f)
|
||||
.sunAngularRadius(mSettings.lighting.sunlightAngularRadius)
|
||||
.sunHaloSize(mSettings.lighting.sunlightHaloSize)
|
||||
.sunHaloFalloff(mSettings.lighting.sunlightHaloFalloff)
|
||||
.build(*engine, mSunlight);
|
||||
if (mSettings.lighting.enableSunlight) {
|
||||
mScene->addEntity(mSunlight);
|
||||
@@ -462,7 +462,6 @@ void ViewerGui::setIndirectLight(filament::IndirectLight* ibl,
|
||||
mSettings.lighting.sunlightDirection = d;
|
||||
mSettings.lighting.sunlightColor = c.rgb;
|
||||
mSettings.lighting.sunlightIntensity = c[3] * ibl->getIntensity();
|
||||
updateIndirectLight();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -482,14 +481,6 @@ void ViewerGui::updateRootTransform() {
|
||||
tcm.setTransform(root, transform);
|
||||
}
|
||||
|
||||
void ViewerGui::updateIndirectLight() {
|
||||
using namespace filament::math;
|
||||
if (mIndirectLight) {
|
||||
mIndirectLight->setIntensity(mSettings.lighting.iblIntensity);
|
||||
mIndirectLight->setRotation(mat3f::rotation(mSettings.lighting.iblRotation, float3{ 0, 1, 0 }));
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerGui::sceneSelectionUI() {
|
||||
// Build a list of checkboxes, one for each glTF scene.
|
||||
bool changed = false;
|
||||
@@ -774,7 +765,7 @@ void ViewerGui::updateUserInterface() {
|
||||
int lowpass = (int) ssao.lowPassFilter;
|
||||
bool upsampling = ssao.upsampling != View::QualityLevel::LOW;
|
||||
|
||||
bool halfRes = ssao.resolution == 1.0f ? false : true;
|
||||
bool halfRes = ssao.resolution != 1.0f;
|
||||
ImGui::SliderInt("Quality", &quality, 0, 3);
|
||||
ImGui::SliderInt("Low Pass", &lowpass, 0, 2);
|
||||
ImGui::Checkbox("Bent Normals", &ssao.bentNormals);
|
||||
@@ -841,7 +832,10 @@ void ViewerGui::updateUserInterface() {
|
||||
}
|
||||
if (ImGui::CollapsingHeader("Sunlight")) {
|
||||
ImGui::Checkbox("Enable sunlight", &light.enableSunlight);
|
||||
ImGui::SliderFloat("Sun intensity", &light.sunlightIntensity, 50000.0, 150000.0f);
|
||||
ImGui::SliderFloat("Sun intensity", &light.sunlightIntensity, 50000.0f, 150000.0f);
|
||||
ImGui::SliderFloat("Halo size", &light.sunlightHaloSize, 1.01f, 40.0f);
|
||||
ImGui::SliderFloat("Halo falloff", &light.sunlightHaloFalloff, 4.0f, 1024.0f);
|
||||
ImGui::SliderFloat("Sun radius", &light.sunlightAngularRadius, 0.1f, 10.0f);
|
||||
ImGuiExt::DirectionWidget("Sun direction", light.sunlightDirection.v);
|
||||
}
|
||||
if (ImGui::CollapsingHeader("All lights")) {
|
||||
@@ -1016,25 +1010,8 @@ void ViewerGui::updateUserInterface() {
|
||||
// At this point, all View settings have been modified,
|
||||
// so we can now push them into the Filament View.
|
||||
applySettings(mEngine, mSettings.view, mView);
|
||||
|
||||
mView->setSoftShadowOptions(mSettings.lighting.softShadowOptions);
|
||||
|
||||
if (light.enableSunlight) {
|
||||
mScene->addEntity(mSunlight);
|
||||
auto sun = lm.getInstance(mSunlight);
|
||||
lm.setIntensity(sun, light.sunlightIntensity);
|
||||
lm.setDirection(sun, normalize(light.sunlightDirection));
|
||||
lm.setColor(sun, light.sunlightColor);
|
||||
lm.setShadowCaster(sun, light.enableShadows);
|
||||
lm.setShadowOptions(sun, light.shadowOptions);
|
||||
} else {
|
||||
mScene->remove(mSunlight);
|
||||
}
|
||||
|
||||
lm.forEachComponent([this, &lm, &light](utils::Entity e, LightManager::Instance ci) {
|
||||
lm.setShadowOptions(ci, light.shadowOptions);
|
||||
lm.setShadowCaster(ci, light.enableShadows);
|
||||
});
|
||||
applySettings(mEngine, mSettings.lighting, mIndirectLight, mSunlight,
|
||||
lm.getEntities(), lm.getComponentCount(), &lm, mScene, mView);
|
||||
|
||||
// TODO(prideout): add support for hierarchy, animation and variant selection in remote mode. To
|
||||
// support these features, we will need to send a message (list of strings) from DebugServer to
|
||||
@@ -1112,8 +1089,6 @@ void ViewerGui::updateUserInterface() {
|
||||
|
||||
mSidebarWidth = ImGui::GetWindowWidth();
|
||||
ImGui::End();
|
||||
|
||||
updateIndirectLight();
|
||||
}
|
||||
|
||||
} // namespace viewer
|
||||
|
||||
@@ -185,8 +185,12 @@ vec4 computeWorldPosition() {
|
||||
// GL convention to inverted DX convention
|
||||
p.z = p.z * -0.5 + 0.5;
|
||||
vec4 position = transform * p;
|
||||
if (abs(position.w) < MEDIUMP_FLT_MIN) {
|
||||
position.w = position.w < 0.0 ? -MEDIUMP_FLT_MIN : MEDIUMP_FLT_MIN;
|
||||
// w could be zero (e.g.: with the skybox) which corresponds to an infinite distance in
|
||||
// world-space. However, we want to avoid infinites and divides-by-zero, so we use a very
|
||||
// small number instead in that case (2^-63 seem to work well).
|
||||
const highp float ALMOST_ZERO_FLT = 1.08420217249e-19f;
|
||||
if (abs(position.w) < ALMOST_ZERO_FLT) {
|
||||
position.w = position.w < 0.0 ? -ALMOST_ZERO_FLT : ALMOST_ZERO_FLT;
|
||||
}
|
||||
return position * (1.0 / position.w);
|
||||
#else
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Directional light evaluation
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if FILAMENT_QUALITY < FILAMENT_QUALITY_HIGH
|
||||
#if FILAMENT_QUALITY >= FILAMENT_QUALITY_HIGH
|
||||
#define SUN_AS_AREA_LIGHT
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "filament",
|
||||
"version": "1.32.1",
|
||||
"version": "1.32.2",
|
||||
"description": "Real-time physically based rendering engine",
|
||||
"main": "filament.js",
|
||||
"module": "filament.js",
|
||||
|
||||
@@ -74,7 +74,7 @@ class App {
|
||||
render() {
|
||||
if (this.animator) {
|
||||
const ms = Date.now() - this.animationStartTime;
|
||||
this.animator.applyAnimation(0, (ms / 1000) % 1.0);
|
||||
this.animator.applyAnimation(0, ms / 1000);
|
||||
this.animator.updateBoneMatrices();
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ class App {
|
||||
|
||||
if (this.animator) {
|
||||
const ms = Date.now() - this.animationStartTime;
|
||||
this.animator.applyAnimation(0, (ms / 1000) % 1.0);
|
||||
this.animator.applyAnimation(0, ms / 1000);
|
||||
this.animator.updateBoneMatrices();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user