upgrade to Filament 1.21.0
This commit is contained in:
@@ -103,6 +103,7 @@ class FColorGrading;
|
||||
class UTILS_PUBLIC ColorGrading : public FilamentAPI {
|
||||
struct BuilderDetails;
|
||||
public:
|
||||
|
||||
enum class QualityLevel : uint8_t {
|
||||
LOW,
|
||||
MEDIUM,
|
||||
@@ -110,6 +111,12 @@ public:
|
||||
ULTRA
|
||||
};
|
||||
|
||||
enum class LutFormat : uint8_t {
|
||||
INTEGER, //!< 10 bits per component
|
||||
FLOAT, //!< 16 bits per component (10 bits mantissa precision)
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* List of available tone-mapping operators.
|
||||
*
|
||||
@@ -140,6 +147,7 @@ public:
|
||||
* 3D texture. For instance, a low quality level will use a 16x16x16 10 bit LUT, a medium
|
||||
* quality level will use a 32x32x32 10 bit LUT, a high quality will use a 32x32x32 16 bit
|
||||
* LUT, and a ultra quality will use a 64x64x64 16 bit LUT.
|
||||
* This overrides the values set by format() and dimensions().
|
||||
*
|
||||
* The default quality is medium.
|
||||
*
|
||||
@@ -149,6 +157,30 @@ public:
|
||||
*/
|
||||
Builder& quality(QualityLevel qualityLevel) noexcept;
|
||||
|
||||
/**
|
||||
* When color grading is implemented using a 3D LUT, this sets the texture format of
|
||||
* of the LUT. This overrides the value set by quality().
|
||||
*
|
||||
* The default is INTEGER
|
||||
*
|
||||
* @param format The desired format of the 3D LUT.
|
||||
*
|
||||
* @return This Builder, for chaining calls
|
||||
*/
|
||||
Builder& format(LutFormat format) noexcept;
|
||||
|
||||
/**
|
||||
* When color grading is implemented using a 3D LUT, this sets the dimension of the LUT.
|
||||
* This overrides the value set by quality().
|
||||
*
|
||||
* The default is 32
|
||||
*
|
||||
* @param dim The desired dimension of the LUT. Between 16 and 64.
|
||||
*
|
||||
* @return This Builder, for chaining calls
|
||||
*/
|
||||
Builder& dimensions(uint8_t dim) noexcept;
|
||||
|
||||
/**
|
||||
* Selects the tone mapping operator to apply to the HDR color buffer as the last
|
||||
* operation of the color grading post-processing step.
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#define TNT_FILAMENT_FILAMENTAPI_H
|
||||
|
||||
#include <utils/compiler.h>
|
||||
#include <utils/PrivateImplementation.h>
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
@@ -52,39 +53,8 @@ public:
|
||||
static void operator delete[](void*) = delete;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \privatesection
|
||||
* BuilderBase is used to hide the implementation details of builders and ensure a higher
|
||||
* level of backward binary compatibility.
|
||||
* The actual implementation is in src/FilamentAPI-impl.h"
|
||||
*/
|
||||
template <typename T>
|
||||
class BuilderBase {
|
||||
public:
|
||||
// none of these methods must be implemented inline because it's important that their
|
||||
// implementation be hidden from the public headers.
|
||||
template<typename ... ARGS>
|
||||
explicit BuilderBase(ARGS&& ...) noexcept;
|
||||
BuilderBase() noexcept;
|
||||
~BuilderBase() noexcept;
|
||||
BuilderBase(BuilderBase const& rhs) noexcept;
|
||||
BuilderBase& operator = (BuilderBase const& rhs) noexcept;
|
||||
|
||||
// move ctor and copy operator can be implemented inline and don't need to be exported
|
||||
BuilderBase(BuilderBase&& rhs) noexcept : mImpl(rhs.mImpl) { rhs.mImpl = nullptr; }
|
||||
BuilderBase& operator = (BuilderBase&& rhs) noexcept {
|
||||
auto temp = mImpl;
|
||||
mImpl = rhs.mImpl;
|
||||
rhs.mImpl = temp;
|
||||
return *this;
|
||||
}
|
||||
|
||||
protected:
|
||||
T* mImpl = nullptr;
|
||||
inline T* operator->() noexcept { return mImpl; }
|
||||
inline T const* operator->() const noexcept { return mImpl; }
|
||||
};
|
||||
template<typename T>
|
||||
using BuilderBase = utils::PrivateImplementation<T>;
|
||||
|
||||
} // namespace filament
|
||||
|
||||
|
||||
@@ -58,30 +58,6 @@ public:
|
||||
*/
|
||||
explicit Frustum(const math::mat4f& pv);
|
||||
|
||||
/**
|
||||
* Creates a frustum from 8 corner coordinates.
|
||||
* @param corners the corners of the frustum
|
||||
*
|
||||
* The corners should be specified in this order:
|
||||
* 0. far bottom left
|
||||
* 1. far bottom right
|
||||
* 2. far top left
|
||||
* 3. far top right
|
||||
* 4. near bottom left
|
||||
* 5. near bottom right
|
||||
* 6. near top left
|
||||
* 7. near top right
|
||||
*
|
||||
* 2----3
|
||||
* /| /|
|
||||
* 6----7 |
|
||||
* | 0--|-1 far
|
||||
* |/ |/ /
|
||||
* 4----5 near
|
||||
*
|
||||
*/
|
||||
explicit Frustum(const math::float3 corners[8]);
|
||||
|
||||
/**
|
||||
* Sets the frustum from the given projection matrix
|
||||
* @param pv a 4x4 projection matrix
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
namespace filament {
|
||||
|
||||
// update this when a new version of filament wouldn't work with older materials
|
||||
static constexpr size_t MATERIAL_VERSION = 17;
|
||||
static constexpr size_t MATERIAL_VERSION = 21;
|
||||
|
||||
/**
|
||||
* Supported shading models
|
||||
@@ -136,10 +136,22 @@ enum VertexAttribute : uint8_t {
|
||||
CUSTOM6 = 14,
|
||||
CUSTOM7 = 15,
|
||||
|
||||
// Aliases for legacy vertex morphing.
|
||||
// See RenderableManager::Builder::morphing().
|
||||
MORPH_POSITION_0 = CUSTOM0,
|
||||
MORPH_POSITION_1 = CUSTOM1,
|
||||
MORPH_POSITION_2 = CUSTOM2,
|
||||
MORPH_POSITION_3 = CUSTOM3,
|
||||
MORPH_TANGENTS_0 = CUSTOM4,
|
||||
MORPH_TANGENTS_1 = CUSTOM5,
|
||||
MORPH_TANGENTS_2 = CUSTOM6,
|
||||
MORPH_TANGENTS_3 = CUSTOM7,
|
||||
|
||||
// this is limited by driver::MAX_VERTEX_ATTRIBUTE_COUNT
|
||||
};
|
||||
|
||||
static constexpr size_t MAX_MORPH_TARGETS = 128; // this is limited by filament::CONFIG_MAX_MORPH_TARGET_COUNT
|
||||
static constexpr size_t MAX_LEGACY_MORPH_TARGETS = 4;
|
||||
static constexpr size_t MAX_MORPH_TARGETS = 256; // this is limited by filament::CONFIG_MAX_MORPH_TARGET_COUNT
|
||||
static constexpr size_t MAX_CUSTOM_ATTRIBUTES = 8;
|
||||
|
||||
/**
|
||||
@@ -219,6 +231,18 @@ enum class Property : uint8_t {
|
||||
// when adding new Properties, make sure to update MATERIAL_PROPERTIES_COUNT
|
||||
};
|
||||
|
||||
enum class UserVariantFilterBit : uint32_t {
|
||||
DIRECTIONAL_LIGHTING = 0x01,
|
||||
DYNAMIC_LIGHTING = 0x02,
|
||||
SHADOW_RECEIVER = 0x04,
|
||||
SKINNING = 0x08,
|
||||
FOG = 0x10,
|
||||
VSM = 0x20,
|
||||
SSR = 0x40,
|
||||
};
|
||||
|
||||
using UserVariantFilterMask = uint32_t;
|
||||
|
||||
} // namespace filament
|
||||
|
||||
#endif
|
||||
|
||||
@@ -109,6 +109,9 @@ public:
|
||||
/**
|
||||
* Set a texture as the named parameter
|
||||
*
|
||||
* Note: Depth textures can't be sampled with a linear filter unless the comparison mode is set
|
||||
* to COMPARE_TO_TEXTURE.
|
||||
*
|
||||
* @param name Name of the parameter as defined by Material. Cannot be nullptr.
|
||||
* @param texture Non nullptr Texture object pointer.
|
||||
* @param sampler Sampler parameters.
|
||||
|
||||
@@ -28,6 +28,9 @@ namespace filament {
|
||||
|
||||
/**
|
||||
* MorphTargetBuffer is used to hold morphing data (positions and tangents).
|
||||
*
|
||||
* Both positions and tangents are required.
|
||||
*
|
||||
*/
|
||||
class UTILS_PUBLIC MorphTargetBuffer : public FilamentAPI {
|
||||
struct BuilderDetails;
|
||||
@@ -76,30 +79,45 @@ public:
|
||||
|
||||
/**
|
||||
* Updates the position of morph target at the index.
|
||||
*
|
||||
* Both positions and tangents must be provided.
|
||||
*
|
||||
* @param engine Reference to the filament::Engine associated with this MorphTargetBuffer.
|
||||
* @param targetIndex the index of morph target to be updated.
|
||||
* @param weights pointer to at least count positions
|
||||
* @param count number of position elements in positions
|
||||
* @see setTangentsAt
|
||||
*/
|
||||
void setPositionsAt(Engine& engine, size_t targetIndex, math::float3 const* positions, size_t count);
|
||||
void setPositionsAt(Engine& engine, size_t targetIndex,
|
||||
math::float3 const* positions, size_t count, size_t offset = 0);
|
||||
|
||||
/**
|
||||
* Updates the position of morph target at the index.
|
||||
*
|
||||
* Both positions and tangents must be provided.
|
||||
*
|
||||
* @param engine Reference to the filament::Engine associated with this MorphTargetBuffer.
|
||||
* @param targetIndex the index of morph target to be updated.
|
||||
* @param weights pointer to at least count positions
|
||||
* @param count number of position elements in positions
|
||||
* @see setPositionsAt
|
||||
*/
|
||||
void setPositionsAt(Engine& engine, size_t targetIndex, math::float4 const* positions, size_t count);
|
||||
void setPositionsAt(Engine& engine, size_t targetIndex,
|
||||
math::float4 const* positions, size_t count, size_t offset = 0);
|
||||
|
||||
/**
|
||||
* Updates the position of morph target at the index.
|
||||
*
|
||||
* Both positions and tangents must be provided.
|
||||
*
|
||||
* @param engine Reference to the filament::Engine associated with this MorphTargetBuffer.
|
||||
* @param targetIndex the index of morph target to be updated.
|
||||
* @param tangents pointer to at least count tangents
|
||||
* @param count number of tangent elements in tangents
|
||||
* @see setTangentsAt
|
||||
*/
|
||||
void setTangentsAt(Engine& engine, size_t targetIndex, math::short4 const* tangents, size_t count);
|
||||
void setTangentsAt(Engine& engine, size_t targetIndex,
|
||||
math::short4 const* tangents, size_t count, size_t offset = 0);
|
||||
|
||||
/**
|
||||
* Returns the vertex count of this MorphTargetBuffer.
|
||||
|
||||
@@ -321,10 +321,10 @@ struct TemporalAntiAliasingOptions {
|
||||
* @see setScreenSpaceReflectionsOptions()
|
||||
*/
|
||||
struct ScreenSpaceReflectionsOptions {
|
||||
float thickness = 0.5f; //!< ray thickness, in world units
|
||||
float thickness = 0.1f; //!< ray thickness, in world units
|
||||
float bias = 0.01f; //!< bias, in world units, to prevent self-intersections
|
||||
float maxDistance = 3.0f; //!< maximum distance, in world units, to raycast
|
||||
float stride = 1.0f; //!< stride, in texels, for samples along the ray.
|
||||
float stride = 2.0f; //!< stride, in texels, for samples along the ray.
|
||||
bool enabled = false;
|
||||
};
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <filament/Box.h>
|
||||
#include <filament/FilamentAPI.h>
|
||||
#include <filament/MaterialEnums.h>
|
||||
#include <filament/MorphTargetBuffer.h>
|
||||
|
||||
#include <backend/DriverEnums.h>
|
||||
|
||||
@@ -41,7 +42,6 @@ class Engine;
|
||||
class IndexBuffer;
|
||||
class Material;
|
||||
class MaterialInstance;
|
||||
class MorphTargetBuffer;
|
||||
class Renderer;
|
||||
class SkinningBuffer;
|
||||
class VertexBuffer;
|
||||
@@ -300,12 +300,45 @@ public:
|
||||
Builder& skinning(size_t boneCount) noexcept; //!< \overload
|
||||
|
||||
/**
|
||||
* Controls if the renderable has vertex morphing targets, false by default.
|
||||
* Controls if the renderable has vertex morphing targets, zero by default. This is
|
||||
* required to enable GPU morphing.
|
||||
*
|
||||
* Filament supports two morphing modes: standard (default) and legacy.
|
||||
*
|
||||
* For standard morphing, A MorphTargetBuffer must be created and provided via
|
||||
* RenderableManager::setMorphTargetBufferAt(). Standard morphing supports up to
|
||||
* \c CONFIG_MAX_MORPH_TARGET_COUNT morph targets.
|
||||
*
|
||||
* For legacy morphing, the attached VertexBuffer must provide data in the
|
||||
* appropriate VertexAttribute slots (\c MORPH_POSITION_0 etc). Legacy morphing only
|
||||
* supports up to 4 morph targets and will be deprecated in the future. Legacy morphing must
|
||||
* be enabled on the material definition: either via the legacyMorphing material attribute
|
||||
* or by calling filamat::MaterialBuilder::useLegacyMorphing().
|
||||
*
|
||||
* See also RenderableManager::setMorphWeights(), which can be called on a per-frame basis
|
||||
* to advance the animation.
|
||||
*/
|
||||
Builder& morphing(bool enable) noexcept;
|
||||
Builder& morphing(size_t targetCount) noexcept;
|
||||
|
||||
/**
|
||||
* Specifies the morph target buffer for a primitive.
|
||||
*
|
||||
* The morph target buffer must have an associated renderable and geometry. Two conditions
|
||||
* must be met:
|
||||
* 1. The number of morph targets in the buffer must equal the renderable's morph target
|
||||
* count.
|
||||
* 2. The vertex count of each morph target must equal the geometry's vertex count.
|
||||
*
|
||||
* @param level the level of detail (lod), only 0 can be specified
|
||||
* @param primitiveIndex zero-based index of the primitive, must be less than the count passed to Builder constructor
|
||||
* @param morphTargetBuffer specifies the morph target buffer
|
||||
* @param offset specifies where in the morph target buffer to start reading (expressed as a number of vertices)
|
||||
* @param count number of vertices in the morph target buffer to read, must equal the geometry's count (for triangles, this should be a multiple of 3)
|
||||
*/
|
||||
Builder& morphing(uint8_t level, size_t primitiveIndex,
|
||||
MorphTargetBuffer* morphTargetBuffer, size_t offset, size_t count) noexcept;
|
||||
inline Builder& morphing(uint8_t level, size_t primitiveIndex,
|
||||
MorphTargetBuffer* morphTargetBuffer) noexcept;
|
||||
|
||||
/**
|
||||
* Sets an ordering index for blended primitives that all live at the same Z value.
|
||||
@@ -315,6 +348,18 @@ public:
|
||||
*/
|
||||
Builder& blendOrder(size_t primitiveIndex, uint16_t order) noexcept;
|
||||
|
||||
/**
|
||||
* Specifies the number of draw instance of this renderable. The default is 1 instance and
|
||||
* the maximum number of instances allowed is 65535. 0 is invalid.
|
||||
* All instances are culled using the same bounding box, so care must be taken to make
|
||||
* sure all instances render inside the specified bounding box.
|
||||
* The material can use getInstanceIndex() in the vertex shader to get the instance index and
|
||||
* possibly adjust the position or transform.
|
||||
*
|
||||
* @param instanceCount the number of instances silently clamped between 1 and 65535.
|
||||
*/
|
||||
Builder& instances(size_t instanceCount) noexcept;
|
||||
|
||||
/**
|
||||
* Adds the Renderable component to an entity.
|
||||
*
|
||||
@@ -349,6 +394,11 @@ public:
|
||||
MaterialInstance const* materialInstance = nullptr;
|
||||
PrimitiveType type = PrimitiveType::TRIANGLES;
|
||||
uint16_t blendOrder = 0;
|
||||
struct {
|
||||
MorphTargetBuffer* buffer = nullptr;
|
||||
size_t offset = 0;
|
||||
size_t count = 0;
|
||||
} morphing;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -443,28 +493,45 @@ public:
|
||||
* Updates the bone transforms in the range [offset, offset + boneCount).
|
||||
* The bones must be pre-allocated using Builder::skinning().
|
||||
*/
|
||||
void setBones(Instance instance, Bone const* transforms, size_t boneCount = 1, size_t offset = 0) noexcept;
|
||||
void setBones(Instance instance, math::mat4f const* transforms, size_t boneCount = 1, size_t offset = 0) noexcept; //!< \overload
|
||||
void setBones(Instance instance, Bone const* transforms, size_t boneCount = 1, size_t offset = 0);
|
||||
void setBones(Instance instance, math::mat4f const* transforms, size_t boneCount = 1, size_t offset = 0); //!< \overload
|
||||
|
||||
/**
|
||||
* Associates a SkinningBuffer to a renderable instance
|
||||
*/
|
||||
void setSkinningBuffer(Instance instance, SkinningBuffer* skinningBuffer,
|
||||
size_t count, size_t offset) noexcept;
|
||||
size_t count, size_t offset);
|
||||
|
||||
/**
|
||||
* Updates the vertex morphing weights on a renderable, all zeroes by default.
|
||||
*
|
||||
* The renderable must be built with morphing enabled, see Builder::morphing().
|
||||
* The renderable must be built with morphing enabled, see Builder::morphing(). In legacy
|
||||
* morphing mode, only the first 4 weights are considered.
|
||||
*
|
||||
* @param instance Instance of the component obtained from getInstance().
|
||||
* @param weights Pointer to morph target weights to be update.
|
||||
* @param count Number of morph target weights.
|
||||
* @param offset Index of the first first morph target weight to set at instance.
|
||||
*/
|
||||
void setMorphWeights(Instance instance, float const* weights, size_t count) noexcept;
|
||||
|
||||
void setMorphWeights(Instance instance,
|
||||
float const* weights, size_t count, size_t offset = 0);
|
||||
|
||||
/**
|
||||
* Associates a MorphTargetBuffer to the given primitive.
|
||||
*/
|
||||
void setMorphTargetBufferAt(Instance instance,
|
||||
size_t primitiveIndex, MorphTargetBuffer* morphTargetBuffer) noexcept;
|
||||
void setMorphTargetBufferAt(Instance instance, uint8_t level, size_t primitiveIndex,
|
||||
MorphTargetBuffer* morphTargetBuffer, size_t offset, size_t count);
|
||||
|
||||
/**
|
||||
* Utility method to change a MorphTargetBuffer to the given primitive
|
||||
*/
|
||||
inline void setMorphTargetBufferAt(Instance instance, uint8_t level, size_t primitiveIndex,
|
||||
MorphTargetBuffer* morphTargetBuffer);
|
||||
|
||||
/**
|
||||
* Gets the number of morphing in the given entity.
|
||||
*/
|
||||
size_t getMorphTargetCount(Instance instance) const noexcept;
|
||||
|
||||
/**
|
||||
* Gets the bounding box used for frustum culling.
|
||||
@@ -568,6 +635,18 @@ public:
|
||||
size_t stride = sizeof(VECTOR)) noexcept;
|
||||
};
|
||||
|
||||
RenderableManager::Builder& RenderableManager::Builder::morphing(uint8_t level, size_t primitiveIndex,
|
||||
MorphTargetBuffer* morphTargetBuffer) noexcept {
|
||||
return morphing(level, primitiveIndex, morphTargetBuffer, 0,
|
||||
morphTargetBuffer->getVertexCount());
|
||||
}
|
||||
|
||||
void RenderableManager::setMorphTargetBufferAt(Instance instance, uint8_t level, size_t primitiveIndex,
|
||||
MorphTargetBuffer* morphTargetBuffer) {
|
||||
setMorphTargetBufferAt(instance, level, primitiveIndex, morphTargetBuffer, 0,
|
||||
morphTargetBuffer->getVertexCount());
|
||||
}
|
||||
|
||||
template<typename VECTOR, typename INDEX, typename, typename>
|
||||
Box RenderableManager::computeAABB(VECTOR const* vertices, INDEX const* indices, size_t count,
|
||||
size_t stride) noexcept {
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <filament/FilamentAPI.h>
|
||||
|
||||
#include <utils/compiler.h>
|
||||
#include <utils/Invocable.h>
|
||||
|
||||
namespace utils {
|
||||
class Entity;
|
||||
@@ -156,6 +157,15 @@ public:
|
||||
* @return Whether the given entity is in the Scene.
|
||||
*/
|
||||
bool hasEntity(utils::Entity entity) const noexcept;
|
||||
|
||||
/**
|
||||
* Invokes user functor on each entity in the scene.
|
||||
*
|
||||
* It is not allowed to add or remove an entity from the scene within the functor.
|
||||
*
|
||||
* @param functor User provided functor called for each entity in the scene
|
||||
*/
|
||||
void forEach(utils::Invocable<void(utils::Entity entity)>&& functor) const noexcept;
|
||||
};
|
||||
|
||||
} // namespace filament
|
||||
|
||||
@@ -70,13 +70,19 @@ class UTILS_PUBLIC TransformManager : public FilamentAPI {
|
||||
public:
|
||||
using Instance = utils::EntityInstance<TransformManager>;
|
||||
|
||||
class children_iterator : std::iterator<std::forward_iterator_tag, Instance> {
|
||||
class children_iterator {
|
||||
friend class FTransformManager;
|
||||
TransformManager const& mManager;
|
||||
Instance mInstance;
|
||||
children_iterator(TransformManager const& mgr, Instance instance) noexcept
|
||||
: mManager(mgr), mInstance(instance) { }
|
||||
public:
|
||||
using value_type = Instance;
|
||||
using difference_type = ptrdiff_t;
|
||||
using pointer = Instance*;
|
||||
using reference = Instance&;
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
|
||||
children_iterator& operator++();
|
||||
|
||||
children_iterator operator++(int) { // NOLINT
|
||||
|
||||
@@ -674,7 +674,7 @@ public:
|
||||
* @tparam method Method to call on T (e.g.: &Foo::bar)
|
||||
* @param x Horizontal coordinate to query in the viewport with origin on the left.
|
||||
* @param y Vertical coordinate to query on the viewport with origin at the bottom.
|
||||
* @param data A pointer to an instance of T
|
||||
* @param instance A pointer to an instance of T
|
||||
* @param handler Handler to dispatch the callback or nullptr for the default handler.
|
||||
*/
|
||||
template<typename T, void(T::*method)(PickingQueryResult const&)>
|
||||
@@ -694,7 +694,7 @@ public:
|
||||
* @tparam method Method to call on T (e.g.: &Foo::bar)
|
||||
* @param x Horizontal coordinate to query in the viewport with origin on the left.
|
||||
* @param y Vertical coordinate to query on the viewport with origin at the bottom.
|
||||
* @param data An instance of T
|
||||
* @param instance An instance of T
|
||||
* @param handler Handler to dispatch the callback or nullptr for the default handler.
|
||||
*/
|
||||
template<typename T, void(T::*method)(PickingQueryResult const&)>
|
||||
|
||||
Reference in New Issue
Block a user