+ auto uboCount = reflection.GetUniformBlockCount();
+ mUniformBufferBindings.resize(uboCount);
+
+ std::vector<Graphics::UniformBufferBinding>* bindings{&mUniformBufferBindings};
+
+ mUniformBufferBindings[0].buffer = uboView->GetBuffer(&mUniformBufferBindings[0].offset);
+
+ // Write default uniforms
+ WriteDefaultUniform(program->GetDefaultUniform(Program::DefaultUniformIndex::MODEL_MATRIX), *uboView, modelMatrix);
+ WriteDefaultUniform(program->GetDefaultUniform(Program::DefaultUniformIndex::VIEW_MATRIX), *uboView, viewMatrix);
+ WriteDefaultUniform(program->GetDefaultUniform(Program::DefaultUniformIndex::PROJECTION_MATRIX), *uboView, projectionMatrix);
+ WriteDefaultUniform(program->GetDefaultUniform(Program::DefaultUniformIndex::MODEL_VIEW_MATRIX), *uboView, modelViewMatrix);
+
+ auto mvpUniformInfo = program->GetDefaultUniform(Program::DefaultUniformIndex::MVP_MATRIX);
+ if(mvpUniformInfo && !mvpUniformInfo->name.empty())
+ {
+ Matrix modelViewProjectionMatrix(false);
+ MatrixUtils::MultiplyProjectionMatrix(modelViewProjectionMatrix, modelViewMatrix, projectionMatrix);
+ WriteDefaultUniform(mvpUniformInfo, *uboView, modelViewProjectionMatrix);
+ }
+
+ auto normalUniformInfo = program->GetDefaultUniform(Program::DefaultUniformIndex::NORMAL_MATRIX);
+ if(normalUniformInfo && !normalUniformInfo->name.empty())
+ {
+ Matrix3 normalMatrix(modelViewMatrix);
+ normalMatrix.Invert();
+ normalMatrix.Transpose();
+ WriteDefaultUniform(normalUniformInfo, *uboView, normalMatrix);
+ }
+
+ Vector4 finalColor; ///< Applied renderer's opacity color
+ const Vector4& color = node.GetRenderColor(bufferIndex); ///< Actor's original color
+ if(mPremultipliedAlphaEnabled)
+ {
+ const float& alpha = color.a * mRenderDataProvider->GetOpacity(bufferIndex);
+ finalColor = Vector4(color.r * alpha, color.g * alpha, color.b * alpha, alpha);
+ }
+ else
+ {
+ finalColor = Vector4(color.r, color.g, color.b, color.a * mRenderDataProvider->GetOpacity(bufferIndex));
+ }
+ WriteDefaultUniform(program->GetDefaultUniform(Program::DefaultUniformIndex::COLOR), *uboView, finalColor);
+ WriteDefaultUniform(program->GetDefaultUniform(Program::DefaultUniformIndex::ACTOR_COLOR), *uboView, color);
+
+ // Write uniforms from the uniform map
+ FillUniformBuffer(*program, instruction, *uboView, bindings, uboOffset, bufferIndex, nodeIndex);
+
+ // Write uSize in the end, as it shouldn't be overridable by dynamic properties.
+ WriteDefaultUniform(program->GetDefaultUniform(Program::DefaultUniformIndex::SIZE), *uboView, size);
+
+ commandBuffer.BindUniformBuffers(*bindings);