diff options
author | Määttä Antti <antti.maatta@qt.io> | 2018-05-31 14:56:38 +0300 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@qt.io> | 2018-06-01 04:08:54 +0000 |
commit | 8fc0026450fbd9c4591561874578001483cabacb (patch) | |
tree | b27c5e2b53b5d4a6b4df26e57cb6a43fdf8dc5ce /src/Runtime/Source/Qt3DSRender/Source/backends | |
parent | a465515bcd856d355f92255d4c0034e0d2aeda24 (diff) |
Fix lighting with custom material and shadows
There are two problems with the shadows.
1. The shader cache key for default materials is not properly initialized,
which causes invalid shader being used for the material.
2. Custom material shadow cubes and maps uniforms are not set correctly.
Only first element in those sampler arrays were set, so when custom material
lighting had more then 1 light and shadows, only one light affected the
rendered result.
Fixed the default material key and implemented proper setters for sampler
uniforms.
Task-number: QT3DS-1824
Change-Id: I0b97a4642410f37011392adf1020bc1d2bd21bb3
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'src/Runtime/Source/Qt3DSRender/Source/backends')
-rw-r--r-- | src/Runtime/Source/Qt3DSRender/Source/backends/gl/Qt3DSRenderBackendGL4.cpp | 9 | ||||
-rw-r--r-- | src/Runtime/Source/Qt3DSRender/Source/backends/gl/Qt3DSRenderBackendGLBase.cpp | 9 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/Runtime/Source/Qt3DSRender/Source/backends/gl/Qt3DSRenderBackendGL4.cpp b/src/Runtime/Source/Qt3DSRender/Source/backends/gl/Qt3DSRenderBackendGL4.cpp index 47a26e7f..08ff9bb0 100644 --- a/src/Runtime/Source/Qt3DSRender/Source/backends/gl/Qt3DSRenderBackendGL4.cpp +++ b/src/Runtime/Source/Qt3DSRender/Source/backends/gl/Qt3DSRenderBackendGL4.cpp @@ -513,8 +513,13 @@ namespace render { case GL_SAMPLER_2D_ARRAY: case GL_SAMPLER_2D_SHADOW: case GL_SAMPLER_CUBE: { - GLint sampler = *(GLint *)value; - GL_CALL_EXTRA_FUNCTION(glProgramUniform1i(programID, id, sampler)); + if (count <= 1) { + GLint sampler = *(GLint *)value; + GL_CALL_EXTRA_FUNCTION(glProgramUniform1i(programID, id, sampler)); + } else { + GLint *sampler = (GLint *)value; + GL_CALL_EXTRA_FUNCTION(glProgramUniform1iv(programID, id, count, sampler)); + } } break; default: qCCritical(INTERNAL_ERROR, "Unknown shader type format %d", type); diff --git a/src/Runtime/Source/Qt3DSRender/Source/backends/gl/Qt3DSRenderBackendGLBase.cpp b/src/Runtime/Source/Qt3DSRender/Source/backends/gl/Qt3DSRenderBackendGLBase.cpp index 7a780e24..0fb26b35 100644 --- a/src/Runtime/Source/Qt3DSRender/Source/backends/gl/Qt3DSRenderBackendGLBase.cpp +++ b/src/Runtime/Source/Qt3DSRender/Source/backends/gl/Qt3DSRenderBackendGLBase.cpp @@ -1962,8 +1962,13 @@ namespace render { case GL_SAMPLER_2D_ARRAY: case GL_SAMPLER_2D_SHADOW: case GL_SAMPLER_CUBE: { - GLint sampler = *(GLint *)value; - GL_CALL_FUNCTION(glUniform1i(id, sampler)); + if (count > 1) { + GLint *sampler = (GLint *)value; + GL_CALL_FUNCTION(glUniform1iv(id, count, sampler)); + } else { + GLint sampler = *(GLint *)value; + GL_CALL_FUNCTION(glUniform1i(id, sampler)); + } } break; default: qCCritical(INTERNAL_ERROR, "Unknown shader type format %d", type); |