+ 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);
+ }
+}
+
+template<class T>
+bool Renderer::WriteDefaultUniform(const Graphics::UniformInfo* uniformInfo, Render::UniformBufferView& ubo, const T& data)
+{
+ if(uniformInfo && !uniformInfo->name.empty())
+ {
+ WriteUniform(ubo, *uniformInfo, data);
+ return true;
+ }
+ return false;
+}
+
+template<class T>
+void Renderer::WriteUniform(Render::UniformBufferView& ubo, const Graphics::UniformInfo& uniformInfo, const T& data)
+{
+ WriteUniform(ubo, uniformInfo, &data, sizeof(T));
+}
+
+void Renderer::WriteUniform(Render::UniformBufferView& ubo, const Graphics::UniformInfo& uniformInfo, const void* data, uint32_t size)
+{
+ ubo.Write(data, size, ubo.GetOffset() + uniformInfo.offset);
+}
+
+void Renderer::FillUniformBuffer(Program& program,
+ const SceneGraph::RenderInstruction& instruction,
+ Render::UniformBufferView& ubo,
+ std::vector<Graphics::UniformBufferBinding>*& outBindings,
+ uint32_t& offset,
+ BufferIndex updateBufferIndex,
+ int nodeIndex)
+{
+ auto& reflection = mGraphicsController->GetProgramReflection(program.GetGraphicsProgram());
+ auto uboCount = reflection.GetUniformBlockCount();
+
+ // Setup bindings
+ uint32_t dataOffset = offset;
+ for(auto i = 0u; i < uboCount; ++i)
+ {
+ mUniformBufferBindings[i].dataSize = reflection.GetUniformBlockSize(i);
+ mUniformBufferBindings[i].binding = reflection.GetUniformBlockBinding(i);
+
+ dataOffset += GetUniformBufferDataAlignment(mUniformBufferBindings[i].dataSize);
+ mUniformBufferBindings[i].buffer = ubo.GetBuffer(&mUniformBufferBindings[i].offset);
+
+ for(auto iter = mUniformIndexMaps[nodeIndex].begin(),
+ end = mUniformIndexMaps[nodeIndex].end();
+ iter != end;
+ ++iter)
+ {
+ auto& uniform = *iter;
+ int arrayIndex = uniform.arrayIndex;
+
+ if(!uniform.uniformFunc)