Compare commits
1 Commits
bjd/comman
...
bjd/additi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed3f5d1d76 |
@@ -13,3 +13,4 @@ appropriate header in [RELEASE_NOTES.md](./RELEASE_NOTES.md).
|
|||||||
dark fringes to appear (recompile materials)
|
dark fringes to appear (recompile materials)
|
||||||
- Allow glTF materials with transmission/volume extensions to choose their alpha mode
|
- Allow glTF materials with transmission/volume extensions to choose their alpha mode
|
||||||
instead of forcing `MASKED`
|
instead of forcing `MASKED`
|
||||||
|
- Add support for 2 additional material variables [⚠️ **Recompile materials**]
|
||||||
|
|||||||
@@ -102,7 +102,9 @@ public class MaterialBuilder {
|
|||||||
CUSTOM0,
|
CUSTOM0,
|
||||||
CUSTOM1,
|
CUSTOM1,
|
||||||
CUSTOM2,
|
CUSTOM2,
|
||||||
CUSTOM3
|
CUSTOM3,
|
||||||
|
CUSTOM4,
|
||||||
|
CUSTOM5
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum VertexAttribute {
|
public enum VertexAttribute {
|
||||||
|
|||||||
@@ -1299,7 +1299,7 @@ Type
|
|||||||
: array of `string`
|
: array of `string`
|
||||||
|
|
||||||
Value
|
Value
|
||||||
: Up to 4 strings, each must be a valid GLSL identifier.
|
: Up to 6 strings, each must be a valid GLSL identifier.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
: Defines custom interpolants (or variables) that are output by the material's vertex shader.
|
: Defines custom interpolants (or variables) that are output by the material's vertex shader.
|
||||||
|
|||||||
@@ -208,12 +208,14 @@ public:
|
|||||||
MaterialBuilder(MaterialBuilder&& rhs) noexcept = default;
|
MaterialBuilder(MaterialBuilder&& rhs) noexcept = default;
|
||||||
MaterialBuilder& operator=(MaterialBuilder&& rhs) noexcept = default;
|
MaterialBuilder& operator=(MaterialBuilder&& rhs) noexcept = default;
|
||||||
|
|
||||||
static constexpr size_t MATERIAL_VARIABLES_COUNT = 4;
|
static constexpr size_t MATERIAL_VARIABLES_COUNT = 6;
|
||||||
enum class Variable : uint8_t {
|
enum class Variable : uint8_t {
|
||||||
CUSTOM0,
|
CUSTOM0,
|
||||||
CUSTOM1,
|
CUSTOM1,
|
||||||
CUSTOM2,
|
CUSTOM2,
|
||||||
CUSTOM3
|
CUSTOM3,
|
||||||
|
CUSTOM4,
|
||||||
|
CUSTOM5
|
||||||
// when adding more variables, make sure to update MATERIAL_VARIABLES_COUNT
|
// when adding more variables, make sure to update MATERIAL_VARIABLES_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -205,6 +205,8 @@ MaterialBuilder& MaterialBuilder::variable(Variable v, const char* name) noexcep
|
|||||||
case Variable::CUSTOM1:
|
case Variable::CUSTOM1:
|
||||||
case Variable::CUSTOM2:
|
case Variable::CUSTOM2:
|
||||||
case Variable::CUSTOM3:
|
case Variable::CUSTOM3:
|
||||||
|
case Variable::CUSTOM4:
|
||||||
|
case Variable::CUSTOM5:
|
||||||
assert(size_t(v) < MATERIAL_VARIABLES_COUNT);
|
assert(size_t(v) < MATERIAL_VARIABLES_COUNT);
|
||||||
mVariables[size_t(v)] = CString(name);
|
mVariables[size_t(v)] = CString(name);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -2,34 +2,37 @@
|
|||||||
// Varyings
|
// Varyings
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
LAYOUT_LOCATION(4) VARYING highp vec4 vertex_worldPosition;
|
// Varying locations [0, MaterialBuilder::MATERIAL_VARIABLES_COUNT) are reserved for user material
|
||||||
|
// variables.
|
||||||
|
|
||||||
|
LAYOUT_LOCATION(6) VARYING highp vec4 vertex_worldPosition;
|
||||||
|
|
||||||
#if defined(HAS_ATTRIBUTE_TANGENTS)
|
#if defined(HAS_ATTRIBUTE_TANGENTS)
|
||||||
LAYOUT_LOCATION(5) SHADING_INTERPOLATION VARYING mediump vec3 vertex_worldNormal;
|
LAYOUT_LOCATION(7) SHADING_INTERPOLATION VARYING mediump vec3 vertex_worldNormal;
|
||||||
#if defined(MATERIAL_NEEDS_TBN)
|
#if defined(MATERIAL_NEEDS_TBN)
|
||||||
LAYOUT_LOCATION(6) SHADING_INTERPOLATION VARYING mediump vec4 vertex_worldTangent;
|
LAYOUT_LOCATION(8) SHADING_INTERPOLATION VARYING mediump vec4 vertex_worldTangent;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LAYOUT_LOCATION(7) VARYING highp vec4 vertex_position;
|
LAYOUT_LOCATION(9) VARYING highp vec4 vertex_position;
|
||||||
|
|
||||||
#if defined(FILAMENT_HAS_FEATURE_INSTANCING)
|
#if defined(FILAMENT_HAS_FEATURE_INSTANCING)
|
||||||
LAYOUT_LOCATION(8) flat VARYING highp int instance_index;
|
LAYOUT_LOCATION(10) flat VARYING highp int instance_index;
|
||||||
highp int logical_instance_index;
|
highp int logical_instance_index;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAS_ATTRIBUTE_COLOR)
|
#if defined(HAS_ATTRIBUTE_COLOR)
|
||||||
LAYOUT_LOCATION(9) VARYING mediump vec4 vertex_color;
|
LAYOUT_LOCATION(11) VARYING mediump vec4 vertex_color;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAS_ATTRIBUTE_UV0) && !defined(HAS_ATTRIBUTE_UV1)
|
#if defined(HAS_ATTRIBUTE_UV0) && !defined(HAS_ATTRIBUTE_UV1)
|
||||||
LAYOUT_LOCATION(10) VARYING highp vec2 vertex_uv01;
|
LAYOUT_LOCATION(12) VARYING highp vec2 vertex_uv01;
|
||||||
#elif defined(HAS_ATTRIBUTE_UV1)
|
#elif defined(HAS_ATTRIBUTE_UV1)
|
||||||
LAYOUT_LOCATION(10) VARYING highp vec4 vertex_uv01;
|
LAYOUT_LOCATION(12) VARYING highp vec4 vertex_uv01;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(VARIANT_HAS_SHADOWING) && defined(VARIANT_HAS_DIRECTIONAL_LIGHTING)
|
#if defined(VARIANT_HAS_SHADOWING) && defined(VARIANT_HAS_DIRECTIONAL_LIGHTING)
|
||||||
LAYOUT_LOCATION(11) VARYING highp vec4 vertex_lightSpacePosition;
|
LAYOUT_LOCATION(13) VARYING highp vec4 vertex_lightSpacePosition;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Note that fragColor is an output and is not declared here; see main.fs and depth_main.fs
|
// Note that fragColor is an output and is not declared here; see main.fs and depth_main.fs
|
||||||
|
|||||||
@@ -66,6 +66,8 @@ static MaterialBuilder::Variable intToVariable(size_t i) noexcept {
|
|||||||
case 1: return MaterialBuilder::Variable::CUSTOM1;
|
case 1: return MaterialBuilder::Variable::CUSTOM1;
|
||||||
case 2: return MaterialBuilder::Variable::CUSTOM2;
|
case 2: return MaterialBuilder::Variable::CUSTOM2;
|
||||||
case 3: return MaterialBuilder::Variable::CUSTOM3;
|
case 3: return MaterialBuilder::Variable::CUSTOM3;
|
||||||
|
case 4: return MaterialBuilder::Variable::CUSTOM4;
|
||||||
|
case 5: return MaterialBuilder::Variable::CUSTOM5;
|
||||||
default: return MaterialBuilder::Variable::CUSTOM0;
|
default: return MaterialBuilder::Variable::CUSTOM0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -607,8 +609,9 @@ static bool processVariables(MaterialBuilder& builder, const JsonishValue& value
|
|||||||
const JsonishArray* jsonArray = value.toJsonArray();
|
const JsonishArray* jsonArray = value.toJsonArray();
|
||||||
const auto& elements = jsonArray->getElements();
|
const auto& elements = jsonArray->getElements();
|
||||||
|
|
||||||
if (elements.size() > 4) {
|
if (elements.size() > MaterialBuilder::MATERIAL_VARIABLES_COUNT) {
|
||||||
std::cerr << "variables: Max array size is 4." << std::endl;
|
std::cerr << "variables: Max array size is " << MaterialBuilder::MATERIAL_VARIABLES_COUNT
|
||||||
|
<< "." << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user