diff --git a/docs/Materials.md.html b/docs/Materials.md.html
index 85428dbba9c..753e3a6b2f5 100644
--- a/docs/Materials.md.html
+++ b/docs/Materials.md.html
@@ -1308,7 +1308,12 @@
declare a variable called `eyeDirection` you can access it in the fragment shader using
`variable_eyeDirection`. In the vertex shader, the interpolant name is simply a member of
the `MaterialVertexInputs` structure (`material.eyeDirection` in your example). Each
- interpolant is of type `float4` (`vec4`) in the shaders.
+ interpolant is of type `float4` (`vec4`) in the shaders. By default the precision of the
+ interpolant is `highp` in *both* the vertex and fragment shaders.
+ An alternate syntax can be used to specify both the name and precision of the interpolant.
+ In this case the specified precision is used as-is in both fragment and vertex stages, in
+ particular if `default` is specified the default precision is used is the fragment shader
+ (`mediump`) and in the vertex shader (`highp`).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ JSON
material {
@@ -1320,7 +1325,11 @@
}
],
variables : [
- eyeDirection
+ eyeDirection,
+ {
+ name : eyeColor,
+ precision : medium
+ }
],
vertexDomain : device,
depthWrite : false,
diff --git a/libs/filamat/include/filamat/MaterialBuilder.h b/libs/filamat/include/filamat/MaterialBuilder.h
index 2587adba659..7a7e3ba2e2d 100644
--- a/libs/filamat/include/filamat/MaterialBuilder.h
+++ b/libs/filamat/include/filamat/MaterialBuilder.h
@@ -323,6 +323,9 @@ class UTILS_PUBLIC MaterialBuilder : public MaterialBuilderBase {
//! Custom variables (all float4).
MaterialBuilder& variable(Variable v, const char* name) noexcept;
+ MaterialBuilder& variable(Variable v, const char* name,
+ ParameterPrecision precision) noexcept;
+
/**
* Require a specified attribute.
*
@@ -708,11 +711,17 @@ class UTILS_PUBLIC MaterialBuilder : public MaterialBuilderBase {
ShaderStage stage;
};
+ struct CustomVariable {
+ utils::CString name;
+ Precision precision;
+ bool hasPrecision;
+ };
+
static constexpr size_t MATERIAL_PROPERTIES_COUNT = filament::MATERIAL_PROPERTIES_COUNT;
using Property = filament::Property;
using PropertyList = bool[MATERIAL_PROPERTIES_COUNT];
- using VariableList = utils::CString[MATERIAL_VARIABLES_COUNT];
+ using VariableList = CustomVariable[MATERIAL_VARIABLES_COUNT];
using OutputList = std::vector