update to Filament libs with inverse bind matrices
This commit is contained in:
@@ -398,6 +398,18 @@ enum class CompressedPixelDataType : uint16_t {
|
||||
SRGB8_ALPHA8_ASTC_10x10,
|
||||
SRGB8_ALPHA8_ASTC_12x10,
|
||||
SRGB8_ALPHA8_ASTC_12x12,
|
||||
|
||||
// RGTC formats available with a GLES extension
|
||||
RED_RGTC1, // BC4 unsigned
|
||||
SIGNED_RED_RGTC1, // BC4 signed
|
||||
RED_GREEN_RGTC2, // BC5 unsigned
|
||||
SIGNED_RED_GREEN_RGTC2, // BC5 signed
|
||||
|
||||
// BPTC formats available with a GLES extension
|
||||
RGB_BPTC_SIGNED_FLOAT, // BC6H signed
|
||||
RGB_BPTC_UNSIGNED_FLOAT,// BC6H unsigned
|
||||
RGBA_BPTC_UNORM, // BC7
|
||||
SRGB_ALPHA_BPTC_UNORM, // BC7 sRGB
|
||||
};
|
||||
|
||||
/** Supported texel formats
|
||||
@@ -552,6 +564,18 @@ enum class TextureFormat : uint16_t {
|
||||
SRGB8_ALPHA8_ASTC_10x10,
|
||||
SRGB8_ALPHA8_ASTC_12x10,
|
||||
SRGB8_ALPHA8_ASTC_12x12,
|
||||
|
||||
// RGTC formats available with a GLES extension
|
||||
RED_RGTC1, // BC4 unsigned
|
||||
SIGNED_RED_RGTC1, // BC4 signed
|
||||
RED_GREEN_RGTC2, // BC5 unsigned
|
||||
SIGNED_RED_GREEN_RGTC2, // BC5 signed
|
||||
|
||||
// BPTC formats available with a GLES extension
|
||||
RGB_BPTC_SIGNED_FLOAT, // BC6H signed
|
||||
RGB_BPTC_UNSIGNED_FLOAT,// BC6H unsigned
|
||||
RGBA_BPTC_UNORM, // BC7
|
||||
SRGB_ALPHA_BPTC_UNORM, // BC7 sRGB
|
||||
};
|
||||
|
||||
//! Bitmask describing the intended Texture Usage
|
||||
@@ -632,7 +656,7 @@ static constexpr bool isSignedIntFormat(TextureFormat format) {
|
||||
}
|
||||
}
|
||||
|
||||
//! returns whether this format a compressed format
|
||||
//! returns whether this format is a compressed format
|
||||
static constexpr bool isCompressedFormat(TextureFormat format) noexcept {
|
||||
return format >= TextureFormat::EAC_R11;
|
||||
}
|
||||
@@ -642,7 +666,7 @@ static constexpr bool isETC2Compression(TextureFormat format) noexcept {
|
||||
return format >= TextureFormat::EAC_R11 && format <= TextureFormat::ETC2_EAC_SRGBA8;
|
||||
}
|
||||
|
||||
//! returns whether this format is an ETC3 compressed format
|
||||
//! returns whether this format is an S3TC compressed format
|
||||
static constexpr bool isS3TCCompression(TextureFormat format) noexcept {
|
||||
return format >= TextureFormat::DXT1_RGB && format <= TextureFormat::DXT5_SRGBA;
|
||||
}
|
||||
@@ -651,6 +675,16 @@ static constexpr bool isS3TCSRGBCompression(TextureFormat format) noexcept {
|
||||
return format >= TextureFormat::DXT1_SRGB && format <= TextureFormat::DXT5_SRGBA;
|
||||
}
|
||||
|
||||
//! returns whether this format is an RGTC compressed format
|
||||
static constexpr bool isRGTCCompression(TextureFormat format) noexcept {
|
||||
return format >= TextureFormat::RED_RGTC1 && format <= TextureFormat::SIGNED_RED_GREEN_RGTC2;
|
||||
}
|
||||
|
||||
//! returns whether this format is an BPTC compressed format
|
||||
static constexpr bool isBPTCCompression(TextureFormat format) noexcept {
|
||||
return format >= TextureFormat::RGB_BPTC_SIGNED_FLOAT && format <= TextureFormat::SRGB_ALPHA_BPTC_UNORM;
|
||||
}
|
||||
|
||||
static constexpr bool isASTCCompression(TextureFormat format) noexcept {
|
||||
return format >= TextureFormat::RGBA_ASTC_4x4 && format <= TextureFormat::SRGB8_ALPHA8_ASTC_12x12;
|
||||
}
|
||||
|
||||
@@ -40,33 +40,33 @@ using sRGBColorA = math::float4;
|
||||
|
||||
//! types of RGB colors
|
||||
enum class RgbType : uint8_t {
|
||||
sRGB, //!< the color is defined in sRGB space
|
||||
LINEAR, //!< the color is defined in linear space
|
||||
sRGB, //!< the color is defined in Rec.709-sRGB-D65 (sRGB) space
|
||||
LINEAR, //!< the color is defined in Rec.709-Linear-D65 ("linear sRGB") space
|
||||
};
|
||||
|
||||
//! types of RGBA colors
|
||||
enum class RgbaType : uint8_t {
|
||||
/**
|
||||
* the color is defined in sRGB space and the RGB values
|
||||
* have not been premultiplied by the alpha (for instance, a 50%
|
||||
* the color is defined in Rec.709-sRGB-D65 (sRGB) space and the RGB values
|
||||
* have not been pre-multiplied by the alpha (for instance, a 50%
|
||||
* transparent red is <1,0,0,0.5>)
|
||||
*/
|
||||
sRGB,
|
||||
/**
|
||||
* the color is defined in linear space and the RGB values
|
||||
* have not been premultiplied by the alpha (for instance, a 50%
|
||||
* the color is defined in Rec.709-Linear-D65 ("linear sRGB") space and the
|
||||
* RGB values have not been pre-multiplied by the alpha (for instance, a 50%
|
||||
* transparent red is <1,0,0,0.5>)
|
||||
*/
|
||||
LINEAR,
|
||||
/**
|
||||
* the color is defined in sRGB space and the RGB values
|
||||
* have been premultiplied by the alpha (for instance, a 50%
|
||||
* the color is defined in Rec.709-sRGB-D65 (sRGB) space and the RGB values
|
||||
* have been pre-multiplied by the alpha (for instance, a 50%
|
||||
* transparent red is <0.5,0,0,0.5>)
|
||||
*/
|
||||
PREMULTIPLIED_sRGB,
|
||||
/**
|
||||
* the color is defined in linear space and the RGB values
|
||||
* have been premultiplied by the alpha (for instance, a 50%
|
||||
* the color is defined in Rec.709-Linear-D65 ("linear sRGB") space and the
|
||||
* RGB values have been pre-multiplied by the alpha (for instance, a 50%
|
||||
* transparent red is <0.5,0,0,0.5>)
|
||||
*/
|
||||
PREMULTIPLIED_LINEAR
|
||||
@@ -93,40 +93,44 @@ public:
|
||||
template<ColorConversion = ACCURATE>
|
||||
static LinearColor toLinear(sRGBColor const& color);
|
||||
|
||||
//! converts an RGB color in linear space to an RGB color in sRGB space
|
||||
/**
|
||||
* Converts an RGB color in Rec.709-Linear-D65 ("linear sRGB") space to an
|
||||
* RGB color in Rec.709-sRGB-D65 (sRGB) space.
|
||||
*/
|
||||
template<ColorConversion = ACCURATE>
|
||||
static sRGBColor toSRGB(LinearColor const& color);
|
||||
|
||||
/**
|
||||
* converts an RGBA color in sRGB space to an RGBA color in linear space
|
||||
* the alpha component is left unmodified
|
||||
* Converts an RGBA color in Rec.709-sRGB-D65 (sRGB) space to an RGBA color in
|
||||
* Rec.709-Linear-D65 ("linear sRGB") space the alpha component is left unmodified.
|
||||
*/
|
||||
template<ColorConversion = ACCURATE>
|
||||
static LinearColorA toLinear(sRGBColorA const& color);
|
||||
|
||||
/**
|
||||
* converts an RGBA color in linear space to an RGBA color in sRGB space
|
||||
* the alpha component is left unmodified
|
||||
* Converts an RGBA color in Rec.709-Linear-D65 ("linear sRGB") space to
|
||||
* an RGBA color in Rec.709-sRGB-D65 (sRGB) space the alpha component is
|
||||
* left unmodified.
|
||||
*/
|
||||
template<ColorConversion = ACCURATE>
|
||||
static sRGBColorA toSRGB(LinearColorA const& color);
|
||||
|
||||
/**
|
||||
* converts a correlated color temperature to a linear RGB color in sRGB
|
||||
* Converts a correlated color temperature to a linear RGB color in sRGB
|
||||
* space the temperature must be expressed in kelvin and must be in the
|
||||
* range 1,000K to 15,000K
|
||||
* range 1,000K to 15,000K.
|
||||
*/
|
||||
static LinearColor cct(float K);
|
||||
|
||||
/**
|
||||
* converts a CIE standard illuminant series D to a linear RGB color in
|
||||
* Converts a CIE standard illuminant series D to a linear RGB color in
|
||||
* sRGB space the temperature must be expressed in kelvin and must be in
|
||||
* the range 4,000K to 25,000K
|
||||
*/
|
||||
static LinearColor illuminantD(float K);
|
||||
|
||||
/**
|
||||
* computes the Beer-Lambert absorption coefficients from the specified
|
||||
* Computes the Beer-Lambert absorption coefficients from the specified
|
||||
* transmittance color and distance. The computed absorption will guarantee
|
||||
* the white light will become the specified color at the specified distance.
|
||||
* The output of this function can be used as the absorption parameter of
|
||||
|
||||
@@ -31,6 +31,10 @@ namespace filament {
|
||||
class Engine;
|
||||
class FColorGrading;
|
||||
|
||||
namespace color {
|
||||
class ColorSpace;
|
||||
}
|
||||
|
||||
/**
|
||||
* ColorGrading is used to transform (either to modify or correct) the colors of the HDR buffer
|
||||
* rendered by Filament. Color grading transforms are applied after lighting, and after any lens
|
||||
@@ -97,6 +101,7 @@ class FColorGrading;
|
||||
* - Tone mapping: ACESLegacyToneMapper
|
||||
* - Luminance scaling: false
|
||||
* - Gamut mapping: false
|
||||
* - Output color space: Rec709-sRGB-D65
|
||||
*
|
||||
* @see View
|
||||
*/
|
||||
@@ -447,6 +452,19 @@ public:
|
||||
*/
|
||||
Builder& curves(math::float3 shadowGamma, math::float3 midPoint, math::float3 highlightScale) noexcept;
|
||||
|
||||
/**
|
||||
* Sets the output color space for this ColorGrading object. After all color grading steps
|
||||
* have been applied, the final color will be converted in the desired color space.
|
||||
*
|
||||
* NOTE: Currently the output color space must be one of Rec709-sRGB-D65 or
|
||||
* Rec709-Linear-D65. Only the transfer function is taken into account.
|
||||
*
|
||||
* @param colorSpace The output color space.
|
||||
*
|
||||
* @return This Builder, for chaining calls
|
||||
*/
|
||||
Builder& outputColorSpace(const color::ColorSpace& colorSpace) noexcept;
|
||||
|
||||
/**
|
||||
* Creates the ColorGrading object and returns a pointer to it.
|
||||
*
|
||||
|
||||
256
ios/include/filament/ColorSpace.h
Normal file
256
ios/include/filament/ColorSpace.h
Normal file
@@ -0,0 +1,256 @@
|
||||
/*
|
||||
* Copyright (C) 2015 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TNT_FILAMENT_COLOR_SPACE_H
|
||||
#define TNT_FILAMENT_COLOR_SPACE_H
|
||||
|
||||
#include <math/vec2.h>
|
||||
#include <math/vec3.h>
|
||||
|
||||
namespace filament {
|
||||
namespace color {
|
||||
|
||||
using namespace math;
|
||||
|
||||
/**
|
||||
* Holds the chromaticities of a color space's primaries as xy coordinates
|
||||
* in xyY (Y is assumed to be 1).
|
||||
*/
|
||||
struct Primaries {
|
||||
float2 r;
|
||||
float2 g;
|
||||
float2 b;
|
||||
|
||||
bool operator==(const Primaries& rhs) const noexcept {
|
||||
return r == rhs.r && b == rhs.b && g == rhs.b;
|
||||
}
|
||||
};
|
||||
|
||||
//! Reference white for a color space, defined as the xy coordinates in the xyY space.
|
||||
using WhitePoint = float2;
|
||||
|
||||
/**
|
||||
* <p>Defines the parameters for the ICC parametric curve type 4, as
|
||||
* defined in ICC.1:2004-10, section 10.15.</p>
|
||||
*
|
||||
* <p>The EOTF is of the form:</p>
|
||||
*
|
||||
* \(\begin{equation}
|
||||
* Y = \begin{cases}c X + f & X \lt d \\\
|
||||
* \left( a X + b \right) ^{g} + e & X \ge d \end{cases}
|
||||
* \end{equation}\)
|
||||
*
|
||||
* <p>The corresponding OETF is simply the inverse function.</p>
|
||||
*
|
||||
* <p>The parameters defined by this class form a valid transfer
|
||||
* function only if all the following conditions are met:</p>
|
||||
* <ul>
|
||||
* <li>No parameter is a NaN</li>
|
||||
* <li>\(d\) is in the range \([0..1]\)</li>
|
||||
* <li>The function is not constant</li>
|
||||
* <li>The function is positive and increasing</li>
|
||||
* </ul>
|
||||
*/
|
||||
struct TransferFunction {
|
||||
/**
|
||||
* <p>Defines the parameters for the ICC parametric curve type 3, as
|
||||
* defined in ICC.1:2004-10, section 10.15.</p>
|
||||
*
|
||||
* <p>The EOTF is of the form:</p>
|
||||
*
|
||||
* \(\begin{equation}
|
||||
* Y = \begin{cases}c X & X \lt d \\\
|
||||
* \left( a X + b \right) ^{g} & X \ge d \end{cases}
|
||||
* \end{equation}\)
|
||||
*
|
||||
* <p>This constructor is equivalent to setting \(e\) and \(f\) to 0.</p>
|
||||
*
|
||||
* @param a The value of \(a\) in the equation of the EOTF described above
|
||||
* @param b The value of \(b\) in the equation of the EOTF described above
|
||||
* @param c The value of \(c\) in the equation of the EOTF described above
|
||||
* @param d The value of \(d\) in the equation of the EOTF described above
|
||||
* @param g The value of \(g\) in the equation of the EOTF described above
|
||||
*/
|
||||
constexpr TransferFunction(
|
||||
double a,
|
||||
double b,
|
||||
double c,
|
||||
double d,
|
||||
double e,
|
||||
double f,
|
||||
double g
|
||||
) : a(a),
|
||||
b(b),
|
||||
c(c),
|
||||
d(d),
|
||||
e(e),
|
||||
f(f),
|
||||
g(g) {
|
||||
}
|
||||
|
||||
constexpr TransferFunction(
|
||||
double a,
|
||||
double b,
|
||||
double c,
|
||||
double d,
|
||||
double g
|
||||
) : TransferFunction(a, b, c, d, 0.0, 0.0, g) {
|
||||
}
|
||||
|
||||
bool operator==(const TransferFunction& rhs) const noexcept {
|
||||
return
|
||||
a == rhs.a &&
|
||||
b == rhs.b &&
|
||||
c == rhs.c &&
|
||||
d == rhs.d &&
|
||||
e == rhs.e &&
|
||||
f == rhs.f &&
|
||||
g == rhs.g;
|
||||
}
|
||||
|
||||
double a;
|
||||
double b;
|
||||
double c;
|
||||
double d;
|
||||
double e;
|
||||
double f;
|
||||
double g;
|
||||
};
|
||||
|
||||
/**
|
||||
* <p>A color space in Filament is always an RGB color space. A specific RGB color space
|
||||
* is defined by the following properties:</p>
|
||||
* <ul>
|
||||
* <li>Three chromaticities of the red, green and blue primaries, which
|
||||
* define the gamut of the color space.</li>
|
||||
* <li>A white point chromaticity that defines the stimulus to which
|
||||
* color space values are normalized (also just called "white").</li>
|
||||
* <li>An opto-electronic transfer function, also called opto-electronic
|
||||
* conversion function or often, and approximately, gamma function.</li>
|
||||
* <li>An electro-optical transfer function, also called electo-optical
|
||||
* conversion function or often, and approximately, gamma function.</li>
|
||||
* </ul>
|
||||
*
|
||||
* <h3>Primaries and white point chromaticities</h3>
|
||||
* <p>In this implementation, the chromaticity of the primaries and the white
|
||||
* point of an RGB color space is defined in the CIE xyY color space. This
|
||||
* color space separates the chromaticity of a color, the x and y components,
|
||||
* and its luminance, the Y component. Since the primaries and the white
|
||||
* point have full brightness, the Y component is assumed to be 1 and only
|
||||
* the x and y components are needed to encode them.</p>
|
||||
*
|
||||
* <h3>Transfer functions</h3>
|
||||
* <p>A transfer function is a color component conversion function, defined as
|
||||
* a single variable, monotonic mathematical function. It is applied to each
|
||||
* individual component of a color. They are used to perform the mapping
|
||||
* between linear tristimulus values and non-linear electronic signal value.</p>
|
||||
* <p>The <em>opto-electronic transfer function</em> (OETF or OECF) encodes
|
||||
* tristimulus values in a scene to a non-linear electronic signal value.</p>
|
||||
*/
|
||||
class ColorSpace {
|
||||
public:
|
||||
constexpr ColorSpace(
|
||||
const Primaries primaries,
|
||||
const TransferFunction transferFunction,
|
||||
const WhitePoint whitePoint
|
||||
) : mPrimaries(primaries),
|
||||
mTransferFunction(transferFunction),
|
||||
mWhitePoint(whitePoint) {
|
||||
}
|
||||
|
||||
bool operator==(const ColorSpace& rhs) const noexcept {
|
||||
return mPrimaries == rhs.mPrimaries &&
|
||||
mTransferFunction == rhs.mTransferFunction &&
|
||||
mWhitePoint == rhs.mWhitePoint;
|
||||
}
|
||||
|
||||
constexpr const Primaries& getPrimaries() const { return mPrimaries; }
|
||||
constexpr const TransferFunction& getTransferFunction() const { return mTransferFunction; }
|
||||
constexpr const WhitePoint& getWhitePoint() const { return mWhitePoint; }
|
||||
|
||||
private:
|
||||
Primaries mPrimaries;
|
||||
TransferFunction mTransferFunction;
|
||||
WhitePoint mWhitePoint;
|
||||
};
|
||||
|
||||
/**
|
||||
* Intermediate class used when building a color space using the "-" syntax:
|
||||
*
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* // Declares a "linear sRGB" color space.
|
||||
* ColorSpace myColorSpace = Rec709-Linear-sRGB;
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
*/
|
||||
class PartialColorSpace {
|
||||
public:
|
||||
constexpr ColorSpace operator-(const WhitePoint whitePoint) const {
|
||||
return ColorSpace(mPrimaries, mTransferFunction, whitePoint);
|
||||
}
|
||||
|
||||
private:
|
||||
constexpr PartialColorSpace(
|
||||
const Primaries primaries,
|
||||
const TransferFunction transferFunction
|
||||
) : mPrimaries(primaries),
|
||||
mTransferFunction(transferFunction) {
|
||||
}
|
||||
|
||||
Primaries mPrimaries;
|
||||
TransferFunction mTransferFunction;
|
||||
|
||||
friend class Gamut;
|
||||
};
|
||||
|
||||
/**
|
||||
* Defines the chromaticities of the primaries for a color space. The chromaticities
|
||||
* are expressed as three pairs of xy coordinates (in xyY) for the red, green, and blue
|
||||
* chromaticities.
|
||||
*/
|
||||
class Gamut {
|
||||
public:
|
||||
constexpr Gamut(const Primaries primaries) : mPrimaries(primaries) {
|
||||
}
|
||||
|
||||
constexpr Gamut(float2 r, float2 g, float2 b) : Gamut(Primaries{r, g, b}) {
|
||||
}
|
||||
|
||||
constexpr PartialColorSpace operator-(const TransferFunction transferFunction) const {
|
||||
return PartialColorSpace(mPrimaries, transferFunction);
|
||||
}
|
||||
|
||||
constexpr const Primaries& getPrimaries() const { return mPrimaries; }
|
||||
|
||||
private:
|
||||
Primaries mPrimaries;
|
||||
};
|
||||
|
||||
//! Rec.709 color gamut, used in the sRGB and DisplayP3 color spaces.
|
||||
constexpr Gamut Rec709 = Gamut({0.640f, 0.330f}, {0.300f, 0.600f}, {0.150f, 0.060f});
|
||||
|
||||
//! Linear transfer function.
|
||||
constexpr TransferFunction Linear = TransferFunction(1.0, 0.0, 0.0, 0.0, 1.0);
|
||||
//! sRGB transfer function.
|
||||
constexpr TransferFunction sRGB =
|
||||
TransferFunction(1.0 / 1.055, 0.055 / 1.055, 1.0 / 12.92, 0.04045, 2.4);
|
||||
|
||||
//! Standard CIE 1931 2° illuminant D65. This illuminant has a color temperature of 6504K.
|
||||
constexpr WhitePoint D65 = WhitePoint({0.31271f, 0.32902f});
|
||||
|
||||
} // namespace color
|
||||
} // namespace filament
|
||||
|
||||
#endif // TNT_FILAMENT_COLOR_SPACE_H
|
||||
@@ -340,14 +340,6 @@ public:
|
||||
* @see View::setShadowType
|
||||
*/
|
||||
struct Vsm {
|
||||
/**
|
||||
* The number of MSAA samples to use when rendering VSM shadow maps.
|
||||
* Must be a power-of-two and greater than or equal to 1. A value of 1 effectively turns
|
||||
* off MSAA.
|
||||
* Higher values may not be available depending on the underlying hardware.
|
||||
*/
|
||||
uint8_t msaaSamples = 1;
|
||||
|
||||
/**
|
||||
* When elvsm is set to true, "Exponential Layered VSM without Layers" are used. It is
|
||||
* an improvement to the default EVSM which suffers important light leaks. Enabling
|
||||
|
||||
@@ -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 = 28;
|
||||
static constexpr size_t MATERIAL_VERSION = 31;
|
||||
|
||||
/**
|
||||
* Supported shading models
|
||||
|
||||
@@ -277,6 +277,12 @@ public:
|
||||
*/
|
||||
void setMaskThreshold(float threshold) noexcept;
|
||||
|
||||
/**
|
||||
* Gets the minimum alpha value a fragment must have to not be discarded when the blend
|
||||
* mode is MASKED
|
||||
*/
|
||||
float getMaskThreshold() const noexcept;
|
||||
|
||||
/**
|
||||
* Sets the screen space variance of the filter kernel used when applying specular
|
||||
* anti-aliasing. The default value is set to 0.15. The specified value should be between
|
||||
@@ -284,6 +290,12 @@ public:
|
||||
*/
|
||||
void setSpecularAntiAliasingVariance(float variance) noexcept;
|
||||
|
||||
/**
|
||||
* Gets the screen space variance of the filter kernel used when applying specular
|
||||
* anti-aliasing.
|
||||
*/
|
||||
float getSpecularAntiAliasingVariance() const noexcept;
|
||||
|
||||
/**
|
||||
* Sets the clamping threshold used to suppress estimation errors when applying specular
|
||||
* anti-aliasing. The default value is set to 0.2. The specified value should be between 0
|
||||
@@ -291,6 +303,12 @@ public:
|
||||
*/
|
||||
void setSpecularAntiAliasingThreshold(float threshold) noexcept;
|
||||
|
||||
/**
|
||||
* Gets the clamping threshold used to suppress estimation errors when applying specular
|
||||
* anti-aliasing.
|
||||
*/
|
||||
float getSpecularAntiAliasingThreshold() const noexcept;
|
||||
|
||||
/**
|
||||
* Enables or disables double-sided lighting if the parent Material has double-sided capability,
|
||||
* otherwise prints a warning. If double-sided lighting is enabled, backface culling is
|
||||
@@ -298,36 +316,72 @@ public:
|
||||
*/
|
||||
void setDoubleSided(bool doubleSided) noexcept;
|
||||
|
||||
/**
|
||||
* Returns whether double-sided lighting is enabled when the parent Material has double-sided
|
||||
* capability.
|
||||
*/
|
||||
bool isDoubleSided() const noexcept;
|
||||
|
||||
/**
|
||||
* Specifies how transparent objects should be rendered (default is DEFAULT).
|
||||
*/
|
||||
void setTransparencyMode(TransparencyMode mode) noexcept;
|
||||
|
||||
/**
|
||||
* Returns the transparency mode.
|
||||
*/
|
||||
TransparencyMode getTransparencyMode() const noexcept;
|
||||
|
||||
/**
|
||||
* Overrides the default triangle culling state that was set on the material.
|
||||
*/
|
||||
void setCullingMode(CullingMode culling) noexcept;
|
||||
|
||||
/**
|
||||
* Returns the face culling mode.
|
||||
*/
|
||||
CullingMode getCullingMode() const noexcept;
|
||||
|
||||
/**
|
||||
* Overrides the default color-buffer write state that was set on the material.
|
||||
*/
|
||||
void setColorWrite(bool enable) noexcept;
|
||||
|
||||
/**
|
||||
* Returns whether color write is enabled.
|
||||
*/
|
||||
bool isColorWriteEnabled() const noexcept;
|
||||
|
||||
/**
|
||||
* Overrides the default depth-buffer write state that was set on the material.
|
||||
*/
|
||||
void setDepthWrite(bool enable) noexcept;
|
||||
|
||||
/**
|
||||
* Returns whether depth write is enabled.
|
||||
*/
|
||||
bool isDepthWriteEnabled() const noexcept;
|
||||
|
||||
/**
|
||||
* Overrides the default depth testing state that was set on the material.
|
||||
*/
|
||||
void setDepthCulling(bool enable) noexcept;
|
||||
|
||||
/**
|
||||
* Returns whether depth culling is enabled.
|
||||
*/
|
||||
bool isDepthCullingEnabled() const noexcept;
|
||||
|
||||
/**
|
||||
* Overrides the default stencil-buffer write state that was set on the material.
|
||||
*/
|
||||
void setStencilWrite(bool enable) noexcept;
|
||||
|
||||
/**
|
||||
* Returns whether stencil write is enabled.
|
||||
*/
|
||||
bool isStencilWriteEnabled() const noexcept;
|
||||
|
||||
/**
|
||||
* Sets the stencil comparison function (default is StencilCompareFunc::A).
|
||||
*
|
||||
|
||||
@@ -390,6 +390,14 @@ struct VsmShadowOptions {
|
||||
*/
|
||||
bool mipmapping = false;
|
||||
|
||||
/**
|
||||
* The number of MSAA samples to use when rendering VSM shadow maps.
|
||||
* Must be a power-of-two and greater than or equal to 1. A value of 1 effectively turns
|
||||
* off MSAA.
|
||||
* Higher values may not be available depending on the underlying hardware.
|
||||
*/
|
||||
uint8_t msaaSamples = 1;
|
||||
|
||||
/**
|
||||
* Whether to use a 32-bits or 16-bits texture format for VSM shadow maps. 32-bits
|
||||
* precision is rarely needed, but it does reduces light leaks as well as "fading"
|
||||
|
||||
@@ -117,15 +117,37 @@ public:
|
||||
* ClearOptions are used at the beginning of a frame to clear or retain the SwapChain content.
|
||||
*/
|
||||
struct ClearOptions {
|
||||
/** Color to use to clear the SwapChain */
|
||||
/**
|
||||
* Color (sRGB linear) to use to clear the RenderTarget (typically the SwapChain).
|
||||
*
|
||||
* The RenderTarget is cleared using this color, which won't be tone-mapped since
|
||||
* tone-mapping is part of View rendering (this is not).
|
||||
*
|
||||
* When a View is rendered, there are 3 scenarios to consider:
|
||||
* - Pixels rendered by the View replace the clear color (or blend with it in
|
||||
* `BlendMode::TRANSLUCENT` mode).
|
||||
*
|
||||
* - With blending mode set to `BlendMode::TRANSLUCENT`, Pixels untouched by the View
|
||||
* are considered fulling transparent and let the clear color show through.
|
||||
*
|
||||
* - With blending mode set to `BlendMode::OPAQUE`, Pixels untouched by the View
|
||||
* are set to the clear color. However, because it is now used in the context of a View,
|
||||
* it will go through the post-processing stage, which includes tone-mapping.
|
||||
*
|
||||
* For consistency, it is recommended to always use a Skybox to clear an opaque View's
|
||||
* background, or to use black or fully-transparent (i.e. {0,0,0,0}) as the clear color.
|
||||
*/
|
||||
math::float4 clearColor = {};
|
||||
|
||||
/** Value to clear the stencil buffer */
|
||||
uint8_t clearStencil = 0u;
|
||||
|
||||
/**
|
||||
* Whether the SwapChain should be cleared using the clearColor. Use this if translucent
|
||||
* View will be drawn, for instance.
|
||||
*/
|
||||
bool clear = false;
|
||||
|
||||
/**
|
||||
* Whether the SwapChain content should be discarded. clear implies discard. Set this
|
||||
* to false (along with clear to false as well) if the SwapChain already has content that
|
||||
|
||||
@@ -80,14 +80,7 @@ public:
|
||||
*
|
||||
* @return The associated Skybox, or nullptr if there is none.
|
||||
*/
|
||||
Skybox* getSkybox() noexcept;
|
||||
|
||||
/**
|
||||
* Returns an immutable Skybox associated with the Scene.
|
||||
*
|
||||
* @return The associated Skybox, or nullptr if there is none.
|
||||
*/
|
||||
Skybox const* getSkybox() const noexcept;
|
||||
Skybox* getSkybox() const noexcept;
|
||||
|
||||
/**
|
||||
* Set the IndirectLight to use when rendering the Scene.
|
||||
@@ -96,8 +89,17 @@ public:
|
||||
* IndirectLight.
|
||||
*
|
||||
* @param ibl The IndirectLight to use when rendering the Scene or nullptr to unset.
|
||||
* @see getIndirectLight
|
||||
*/
|
||||
void setIndirectLight(IndirectLight const* ibl) noexcept;
|
||||
void setIndirectLight(IndirectLight* ibl) noexcept;
|
||||
|
||||
/**
|
||||
* Get the IndirectLight or nullptr if none is set.
|
||||
*
|
||||
* @return the the IndirectLight or nullptr if none is set
|
||||
* @see setIndirectLight
|
||||
*/
|
||||
IndirectLight* getIndirectLight() const noexcept;
|
||||
|
||||
/**
|
||||
* Adds an Entity to the Scene.
|
||||
|
||||
@@ -126,7 +126,12 @@ public:
|
||||
*/
|
||||
void detachSkin(size_t skinIndex, utils::Entity target) noexcept;
|
||||
|
||||
const math::mat4f* getInverseBindMatricesAt(size_t skinIndex) const noexcept;
|
||||
/**
|
||||
* Gets inverse bind matrices for all joints at the given skin index.
|
||||
*
|
||||
* See getJointCountAt for determining the number of matrices returned (i.e. the number of joints).
|
||||
*/
|
||||
math::mat4f const* getInverseBindMatricesAt(size_t skinIndex) const;
|
||||
|
||||
/**
|
||||
* Resets the AABB on all renderables by manually computing the bounding box.
|
||||
|
||||
@@ -225,6 +225,16 @@ public:
|
||||
static constexpr uint32_t RGBA_S3TC_DXT3 = 0x83F2;
|
||||
static constexpr uint32_t RGBA_S3TC_DXT5 = 0x83F3;
|
||||
|
||||
static constexpr uint32_t R_RGTC_BC4_UNORM = 0x8DBB;
|
||||
static constexpr uint32_t R_RGTC_BC4_SNORM = 0x8DBC;
|
||||
static constexpr uint32_t RG_RGTC_BC5_UNORM = 0x8DBD;
|
||||
static constexpr uint32_t RG_RGTC_BC5_SNORM = 0x8DBE;
|
||||
|
||||
static constexpr uint32_t RGBA_BPTC_BC7 = 0x8E8C;
|
||||
static constexpr uint32_t SRGB8_ALPHA8_BPTC_BC7 = 0x8E8D;
|
||||
static constexpr uint32_t RGB_BPTC_BC6H_SNORM = 0x8E8E;
|
||||
static constexpr uint32_t RGB_BPTC_BC6H_UNORM = 0x8E8F;
|
||||
|
||||
static constexpr uint32_t RGBA_ASTC_4x4 = 0x93B0;
|
||||
static constexpr uint32_t RGBA_ASTC_5x4 = 0x93B1;
|
||||
static constexpr uint32_t RGBA_ASTC_5x5 = 0x93B2;
|
||||
|
||||
@@ -51,7 +51,6 @@ namespace Ktx1Reader {
|
||||
PixelDataFormat toPixelDataFormat(const KtxInfo& info);
|
||||
bool isCompressed(const KtxInfo& info);
|
||||
TextureFormat toTextureFormat(const KtxInfo& info);
|
||||
TextureFormat toSrgbTextureFormat(TextureFormat tex);
|
||||
|
||||
template<typename T>
|
||||
T toCompressedFilamentEnum(uint32_t format) {
|
||||
@@ -60,6 +59,14 @@ namespace Ktx1Reader {
|
||||
case Ktx1Bundle::RGBA_S3TC_DXT1: return T::DXT1_RGBA;
|
||||
case Ktx1Bundle::RGBA_S3TC_DXT3: return T::DXT3_RGBA;
|
||||
case Ktx1Bundle::RGBA_S3TC_DXT5: return T::DXT5_RGBA;
|
||||
case Ktx1Bundle::R_RGTC_BC4_UNORM: return T::RED_RGTC1;
|
||||
case Ktx1Bundle::R_RGTC_BC4_SNORM: return T::SIGNED_RED_RGTC1;
|
||||
case Ktx1Bundle::RG_RGTC_BC5_UNORM: return T::RED_GREEN_RGTC2;
|
||||
case Ktx1Bundle::RG_RGTC_BC5_SNORM: return T::SIGNED_RED_GREEN_RGTC2;
|
||||
case Ktx1Bundle::RGBA_BPTC_BC7: return T::RGBA_BPTC_UNORM;
|
||||
case Ktx1Bundle::SRGB8_ALPHA8_BPTC_BC7: return T::SRGB_ALPHA_BPTC_UNORM;
|
||||
case Ktx1Bundle::RGB_BPTC_BC6H_SNORM: return T::RGB_BPTC_SIGNED_FLOAT;
|
||||
case Ktx1Bundle::RGB_BPTC_BC6H_UNORM: return T::RGB_BPTC_UNSIGNED_FLOAT;
|
||||
case Ktx1Bundle::RGBA_ASTC_4x4: return T::RGBA_ASTC_4x4;
|
||||
case Ktx1Bundle::RGBA_ASTC_5x4: return T::RGBA_ASTC_5x4;
|
||||
case Ktx1Bundle::RGBA_ASTC_5x5: return T::RGBA_ASTC_5x5;
|
||||
|
||||
@@ -588,6 +588,26 @@ constexpr mat4f highPrecisionMultiply(mat4f const& lhs, mat4f const& rhs) noexce
|
||||
};
|
||||
}
|
||||
|
||||
// mat4 * float4, with double precision intermediates
|
||||
constexpr double4 highPrecisionMultiplyd(mat4f const& lhs, float4 const& rhs) noexcept {
|
||||
double4 result{};
|
||||
result += lhs[0] * rhs[0];
|
||||
result += lhs[1] * rhs[1];
|
||||
result += lhs[2] * rhs[2];
|
||||
result += lhs[3] * rhs[3];
|
||||
return result;
|
||||
}
|
||||
|
||||
// mat4 * mat4, with double precision intermediates
|
||||
constexpr mat4 highPrecisionMultiplyd(mat4f const& lhs, mat4f const& rhs) noexcept {
|
||||
return {
|
||||
highPrecisionMultiplyd(lhs, rhs[0]),
|
||||
highPrecisionMultiplyd(lhs, rhs[1]),
|
||||
highPrecisionMultiplyd(lhs, rhs[2]),
|
||||
highPrecisionMultiplyd(lhs, rhs[3])
|
||||
};
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
} // namespace math
|
||||
} // namespace filament
|
||||
|
||||
Reference in New Issue
Block a user