// Vec/matrix types, as raw float arrays
typedef float (vec3)[3];
typedef float (vec4)[4];
- typedef float (mat4)[16];
-
+ typedef float (mat4)[16];
namespace Util
{
inline uint8_t* StealData();
inline void SetData(uint8_t* data, size_t length, Asset& r);
- };
+ };
+
+ const vec4 defaultBaseColor = {1, 1, 1, 1};
+ const vec3 defaultEmissiveFactor = {0, 0, 0};
+ const vec4 defaultDiffuseFactor = {1, 1, 1, 1};
+ const vec3 defaultSpecularFactor = {1, 1, 1};
struct TextureInfo
{
}
namespace {
- void SetVector(vec4& v, float x, float y, float z, float w)
- { v[0] = x; v[1] = y; v[2] = z; v[3] = w; }
+ void SetVector(vec4& v, const float(&in)[4])
+ { v[0] = in[0]; v[1] = in[1]; v[2] = in[2]; v[3] = in[3]; }
- void SetVector(vec3& v, float x, float y, float z)
- { v[0] = x; v[1] = y; v[2] = z; }
+ void SetVector(vec3& v, const float(&in)[3])
+ { v[0] = in[0]; v[1] = in[1]; v[2] = in[2]; }
}
inline void Material::SetDefaults()
{
//pbr materials
- SetVector(pbrMetallicRoughness.baseColorFactor, 1, 1, 1, 1);
+ SetVector(pbrMetallicRoughness.baseColorFactor, defaultBaseColor);
pbrMetallicRoughness.metallicFactor = 1.0;
pbrMetallicRoughness.roughnessFactor = 1.0;
- SetVector(emissiveFactor, 0, 0, 0);
+ SetVector(emissiveFactor, defaultEmissiveFactor);
alphaMode = "OPAQUE";
alphaCutoff = 0.5;
doubleSided = false;
//pbrSpecularGlossiness properties
- SetVector(pbrSpecularGlossiness.diffuseFactor, 1, 1, 1, 1);
- SetVector(pbrSpecularGlossiness.specularFactor, 1, 1, 1);
+ SetVector(pbrSpecularGlossiness.diffuseFactor, defaultDiffuseFactor);
+ SetVector(pbrSpecularGlossiness.specularFactor, defaultSpecularFactor);
pbrSpecularGlossiness.glossinessFactor = 1.0;
}
}
template<size_t N>
- inline void WriteVec(Value& obj, float(&prop)[N], const char* propName, float(&defaultVal)[N], MemoryPoolAllocator<>& al)
+ inline void WriteVec(Value& obj, float(&prop)[N], const char* propName, const float(&defaultVal)[N], MemoryPoolAllocator<>& al)
{
if (!std::equal(std::begin(prop), std::end(prop), std::begin(defaultVal))) {
WriteVec(obj, prop, propName, al);
{
WriteTex(pbrMetallicRoughness, m.pbrMetallicRoughness.baseColorTexture, "baseColorTexture", w.mAl);
WriteTex(pbrMetallicRoughness, m.pbrMetallicRoughness.metallicRoughnessTexture, "metallicRoughnessTexture", w.mAl);
-
- //@TODO: define this as a constant?
- vec4 defaultEmissiveFactor = {1, 1, 1, 1};
- WriteVec(pbrMetallicRoughness, m.pbrMetallicRoughness.baseColorFactor, "baseColorFactor", defaultEmissiveFactor, w.mAl);
+ WriteVec(pbrMetallicRoughness, m.pbrMetallicRoughness.baseColorFactor, "baseColorFactor", defaultBaseColor, w.mAl);
if (m.pbrMetallicRoughness.metallicFactor != 1) {
WriteFloat(pbrMetallicRoughness, m.pbrMetallicRoughness.metallicFactor, "metallicFactor", w.mAl);
WriteTex(obj, m.normalTexture, "normalTexture", w.mAl);
WriteTex(obj, m.emissiveTexture, "emissiveTexture", w.mAl);
WriteTex(obj, m.occlusionTexture, "occlusionTexture", w.mAl);
-
- //@TODO: define this as a constant?
- vec3 defaultEmissiveFactor = {0, 0, 0};
WriteVec(obj, m.emissiveFactor, "emissiveFactor", defaultEmissiveFactor, w.mAl);
if (m.alphaCutoff != 0.5) {
pbrSpecularGlossiness.SetObject();
{
//pbrSpecularGlossiness
-
- vec4 defaultDiffuseFactor = {1, 1, 1, 1};
WriteVec(pbrSpecularGlossiness, m.pbrSpecularGlossiness.diffuseFactor, "diffuseFactor", defaultDiffuseFactor, w.mAl);
-
- vec3 defaultSpecularFactor = {1, 1, 1};
WriteVec(pbrSpecularGlossiness, m.pbrSpecularGlossiness.specularFactor, "specularFactor", defaultSpecularFactor, w.mAl);
if (m.pbrSpecularGlossiness.glossinessFactor != 1) {