diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2018-06-22 11:32:10 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2018-06-27 05:11:26 +0000 |
commit | 979570f4e421a4f4aab2f39e32b7bed629a89531 (patch) | |
tree | 0d6428efeca5a2e4612642a15e887c46b1ebe235 /src/render/renderers/opengl | |
parent | dc3187218c8fc40183685ba270bb7a06ef9d63e9 (diff) |
Don't abort rendering when env light textures are not set
The MetalRoughMaterial provides parameters for the env light textures even
though they are optional but are needed to avoid issues with unbound textures
on some drivers.
In practice, when an env light is present, the values would be overridden.
However if no env light is present, when setting the texture values on the
shader, they would actually reference invalid textures and Qt3D would not
render. We want to keep the behavior for the general case but make an
exception for MetalRoughMaterial, therefore we are checking if the missing
textures are the ones for env light or not before aborting.
Ideally, we should shortly be able to remove the QParameters altogether with
the Shader Builder.
Change-Id: Id54436ff9e328c390eacceb3e63809c757b28b2a
Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com>
Diffstat (limited to 'src/render/renderers/opengl')
-rw-r--r-- | src/render/renderers/opengl/graphicshelpers/submissioncontext.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/render/renderers/opengl/graphicshelpers/submissioncontext.cpp b/src/render/renderers/opengl/graphicshelpers/submissioncontext.cpp index 20aca81bc..cdc895f4d 100644 --- a/src/render/renderers/opengl/graphicshelpers/submissioncontext.cpp +++ b/src/render/renderers/opengl/graphicshelpers/submissioncontext.cpp @@ -60,6 +60,7 @@ #include <Qt3DRender/private/attachmentpack_p.h> #include <Qt3DRender/private/qbuffer_p.h> #include <Qt3DRender/private/renderbuffer_p.h> +#include <Qt3DRender/private/stringtoint_p.h> #include <QOpenGLShaderProgram> #if !defined(QT_OPENGL_ES_2) @@ -1251,6 +1252,8 @@ void SubmissionContext::clearStencilValue(int stencil) // than the other way around bool SubmissionContext::setParameters(ShaderParameterPack ¶meterPack) { + static const int irradianceId = StringToInt::lookupId(QLatin1String("envLight.irradiance")); + static const int specularId = StringToInt::lookupId(QLatin1String("envLight.specular")); // Activate textures and update TextureUniform in the pack // with the correct textureUnit @@ -1272,8 +1275,13 @@ bool SubmissionContext::setParameters(ShaderParameterPack ¶meterPack) Q_ASSERT(texUniform.valueType() == UniformValue::TextureValue); const int texUnit = activateTexture(TextureScopeMaterial, t); texUniform.data<int>()[namedTex.uniformArrayIndex] = texUnit; - if (texUnit == -1) - return false; + if (texUnit == -1) { + if (namedTex.glslNameId != irradianceId && + namedTex.glslNameId != specularId) { + // Only return false if we are not dealing with env light textures + return false; + } + } } } } |