auto ubo = mUniformBuffer[bufferIndex].get();
if(ubo)
{
- std::vector<Graphics::UniformBufferBinding>* bindings{nullptr};
- FillUniformBuffers(*program, instruction, *ubo, bindings, uboOffset, bufferIndex);
+ auto& reflection = mGraphicsController->GetProgramReflection(program->GetGraphicsProgram());
+ auto uboCount = reflection.GetUniformBlockCount();
+ mUniformBufferBindings.resize(uboCount);
- Vector4 finalColor;
- const Vector4& color = node.GetRenderColor(bufferIndex);
- if(mPremultipledAlphaEnabled)
- {
- 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));
- }
+ std::vector<Graphics::UniformBufferBinding>* bindings{&mUniformBufferBindings};
- // We know bindings for this renderer, so we can use 'offset' and write additional uniforms
+ // Write default uniforms
Matrix modelViewProjectionMatrix(false);
Matrix::Multiply(modelViewProjectionMatrix, modelViewMatrix, projectionMatrix);
WriteDefaultUniform(program->GetDefaultUniform(Program::DefaultUniformIndex::PROJECTION_MATRIX), *ubo, *bindings, projectionMatrix);
WriteDefaultUniform(program->GetDefaultUniform(Program::DefaultUniformIndex::MVP_MATRIX), *ubo, *bindings, modelViewProjectionMatrix);
WriteDefaultUniform(program->GetDefaultUniform(Program::DefaultUniformIndex::MODEL_VIEW_MATRIX), *ubo, *bindings, modelViewMatrix);
- WriteDefaultUniform(program->GetDefaultUniform(Program::DefaultUniformIndex::SIZE), *ubo, *bindings, size);
- WriteDefaultUniform(program->GetDefaultUniform(Program::DefaultUniformIndex::COLOR), *ubo, *bindings, finalColor);
// Update normal matrix only when used in the shader
Matrix3 normalMatrix(modelViewMatrix);
normalMatrix.Transpose();
WriteDefaultUniform(program->GetDefaultUniform(Program::DefaultUniformIndex::NORMAL_MATRIX), *ubo, *bindings, normalMatrix);
+ Vector4 finalColor;
+ const Vector4& color = node.GetRenderColor(bufferIndex);
+ if(mPremultipledAlphaEnabled)
+ {
+ 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), *ubo, *bindings, finalColor);
+
+ // Write uniforms from the uniform map
+ FillUniformBuffers(*program, instruction, *ubo, bindings, uboOffset, bufferIndex);
+
+ // Write uSize in the end, as it shouldn't be overridable by dynamic properties.
+ WriteDefaultUniform(program->GetDefaultUniform(Program::DefaultUniformIndex::SIZE), *ubo, *bindings, size);
+
commandBuffer->BindUniformBuffers(*bindings);
}
auto& reflection = mGraphicsController->GetProgramReflection(program.GetGraphicsProgram());
auto uboCount = reflection.GetUniformBlockCount();
- mUniformBufferBindings.resize(uboCount);
-
// Setup bindings
uint32_t dataOffset = offset;
for(auto i = 0u; i < uboCount; ++i)