diff --git a/code/glTF2Asset.inl b/code/glTF2Asset.inl index c3dbb3540..857f9bb4e 100644 --- a/code/glTF2Asset.inl +++ b/code/glTF2Asset.inl @@ -485,7 +485,8 @@ uint8_t* new_data; inline size_t Buffer::AppendData(uint8_t* data, size_t length) { size_t offset = this->byteLength; - Grow(length); + // Force alignment to 4 bits + Grow((length + 3) & ~3); memcpy(mData.get() + offset, data, length); return offset; } diff --git a/code/glTF2Exporter.cpp b/code/glTF2Exporter.cpp index 693069e40..530ab0cc5 100644 --- a/code/glTF2Exporter.cpp +++ b/code/glTF2Exporter.cpp @@ -708,8 +708,13 @@ void glTF2Exporter::ExportMeshes() if (v) p.attributes.position.push_back(v); /******************** Normals ********************/ + // Normalize all normals as the validator can emit a warning otherwise + for (auto i = 0u; i < aim->mNumVertices; ++i) { + aim->mNormals[i].Normalize(); + } + Ref n = ExportData(*mAsset, meshId, b, aim->mNumVertices, aim->mNormals, AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT); - if (n) p.attributes.normal.push_back(n); + if (n) p.attributes.normal.push_back(n); /************** Texture coordinates **************/ for (int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) {