From a026e98d7f9e3d7d8a2757c98bd7de4fe28ff798 Mon Sep 17 00:00:00 2001 From: Paul Lemire Date: Fri, 17 Jul 2020 15:17:59 +0200 Subject: EnvLight uniforms add name aliases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Mike Krus (cherry picked from commit ad815df128fab21c64edd2cc963f7c9fbc9091ff) --- src/plugins/renderers/opengl/renderer/renderview.cpp | 14 ++++++++++++-- 1 file 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(); + auto spec = + shaderData->properties()["specular"].value.value(); + 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); } -- cgit v1.2.1