summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2020-07-17 15:17:59 +0200
committerPaul Lemire <paul.lemire@kdab.com>2020-08-25 11:02:19 +0200
commita026e98d7f9e3d7d8a2757c98bd7de4fe28ff798 (patch)
tree26612a7288e19b0b3b9562001158f070d18a85f6
parent1c6498d2fd5ee6d6558bb0dc4e99e6c40d990fe9 (diff)
downloadqt3d-a026e98d7f9e3d7d8a2757c98bd7de4fe28ff798.tar.gz
EnvLight uniforms add name aliases
Add alias envLightIrradiance for envLight.irradiance and envLightSpecular for envLight.specular. Uniform struct can contain samplers but UBOs cannot contain samplers. Depending on the target platform, having standalone uniform names to access the env light specular and irradiance maps are therefore required. Change-Id: I006bb45865175396a8b0c2bf9ed7e9cee94abf60 Reviewed-by: Jean-Michaƫl Celerier <jean-michael.celerier@kdab.com> Reviewed-by: Mike Krus <mike.krus@kdab.com> (cherry picked from commit ad815df128fab21c64edd2cc963f7c9fbc9091ff)
-rw-r--r--src/plugins/renderers/opengl/renderer/renderview.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/plugins/renderers/opengl/renderer/renderview.cpp b/src/plugins/renderers/opengl/renderer/renderview.cpp
index 429984ef5..aaa27dc6d 100644
--- a/src/plugins/renderers/opengl/renderer/renderview.cpp
+++ b/src/plugins/renderers/opengl/renderer/renderview.cpp
@@ -1194,19 +1194,29 @@ void RenderView::updateLightUniforms(RenderCommand *command, const Entity *entit
// Environment Light
int envLightCount = 0;
+ static const int irradianceStructId = StringToInt::lookupId(QLatin1String("envLight.irradiance"));
+ static const int specularStructId = StringToInt::lookupId(QLatin1String("envLight.specular"));
+ static const int irradianceId = StringToInt::lookupId(QLatin1String("envLightIrradiance"));
+ static const int specularId = StringToInt::lookupId(QLatin1String("envLightSpecular"));
if (m_environmentLight && m_environmentLight->isEnabled()) {
ShaderData *shaderData = m_manager->shaderDataManager()->lookupResource(m_environmentLight->shaderData());
if (shaderData) {
setDefaultUniformBlockShaderDataValue(command->m_parameterPack, shader, shaderData, QStringLiteral("envLight"));
+ auto irr =
+ shaderData->properties()["irradiance"].value.value<Qt3DCore::QNodeId>();
+ auto spec =
+ shaderData->properties()["specular"].value.value<Qt3DCore::QNodeId>();
+ setUniformValue(command->m_parameterPack, irradianceId, irr);
+ setUniformValue(command->m_parameterPack, specularId, spec);
envLightCount = 1;
}
} else {
// with some drivers, samplers (like the envbox sampler) need to be bound even though
// they may not be actually used, otherwise draw calls can fail
- static const int irradianceId = StringToInt::lookupId(QLatin1String("envLight.irradiance"));
- static const int specularId = StringToInt::lookupId(QLatin1String("envLight.specular"));
setUniformValue(command->m_parameterPack, irradianceId, m_renderer->submissionContext()->maxTextureUnitsCount());
+ setUniformValue(command->m_parameterPack, irradianceStructId, m_renderer->submissionContext()->maxTextureUnitsCount());
setUniformValue(command->m_parameterPack, specularId, m_renderer->submissionContext()->maxTextureUnitsCount());
+ setUniformValue(command->m_parameterPack, specularStructId, m_renderer->submissionContext()->maxTextureUnitsCount());
}
setUniformValue(command->m_parameterPack, StringToInt::lookupId(QStringLiteral("envLightCount")), envLightCount);
}