Graphics/ForwardRenderTechnique: Fix sending uniforms when shadows are disabled

Former-commit-id: a1c74d1c8e90fb0c9fd00342cd9688b7987c8229 [formerly 30588634d7283d3afa190d45672955631cd275be] [formerly 5f006c4db2f43bf5a167e2c2f02559d5d7c01275 [formerly 43b03cfc6e1255d5ebd86d0af8e49d19087e7ce0]]
Former-commit-id: 1717577f8523b12489ad79b4f525a3059d11915d [formerly d0b9210e3c6acf35885b4d22717ce660756ef181]
Former-commit-id: f175b9ca43fe11cc11050d7c13f2e8df35e4888a
This commit is contained in:
Lynix 2016-10-09 12:56:42 +02:00
parent 1788cd0735
commit 5c3e29c750
1 changed files with 38 additions and 17 deletions

View File

@ -38,18 +38,24 @@ namespace Nz
shader->SendVector(uniforms.locations.factors + uniformOffset, Vector2f(light.ambientFactor, light.diffuseFactor)); shader->SendVector(uniforms.locations.factors + uniformOffset, Vector2f(light.ambientFactor, light.diffuseFactor));
shader->SendVector(uniforms.locations.parameters1 + uniformOffset, Vector4f(light.direction)); shader->SendVector(uniforms.locations.parameters1 + uniformOffset, Vector4f(light.direction));
if (uniforms.locations.shadowMapping != -1)
shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr); shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr);
if (light.shadowMap) if (light.shadowMap)
{ {
Renderer::SetTexture(availableTextureUnit, light.shadowMap); Renderer::SetTexture(availableTextureUnit, light.shadowMap);
Renderer::SetTextureSampler(availableTextureUnit, s_shadowSampler); Renderer::SetTextureSampler(availableTextureUnit, s_shadowSampler);
if (uniforms.locations.lightViewProjMatrix != -1)
shader->SendMatrix(uniforms.locations.lightViewProjMatrix + index, light.transformMatrix); shader->SendMatrix(uniforms.locations.lightViewProjMatrix + index, light.transformMatrix);
if (uniforms.locations.directionalSpotLightShadowMap != -1)
shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, availableTextureUnit); shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, availableTextureUnit);
} }
else else if (uniforms.locations.directionalSpotLightShadowMap != -1)
shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture); shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture);
if (uniforms.locations.directionalSpotLightShadowMap != -1)
shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap); shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap);
break; break;
} }
@ -63,17 +69,21 @@ namespace Nz
shader->SendVector(uniforms.locations.parameters1 + uniformOffset, Vector4f(light.position, light.attenuation)); shader->SendVector(uniforms.locations.parameters1 + uniformOffset, Vector4f(light.position, light.attenuation));
shader->SendVector(uniforms.locations.parameters2 + uniformOffset, Vector4f(0.f, 0.f, 0.f, light.invRadius)); shader->SendVector(uniforms.locations.parameters2 + uniformOffset, Vector4f(0.f, 0.f, 0.f, light.invRadius));
if (uniforms.locations.shadowMapping != -1)
shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr); shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr);
if (light.shadowMap) if (light.shadowMap)
{ {
Renderer::SetTexture(availableTextureUnit, light.shadowMap); Renderer::SetTexture(availableTextureUnit, light.shadowMap);
Renderer::SetTextureSampler(availableTextureUnit, s_shadowSampler); Renderer::SetTextureSampler(availableTextureUnit, s_shadowSampler);
if (uniforms.locations.pointLightShadowMap != -1)
shader->SendInteger(uniforms.locations.pointLightShadowMap + index, availableTextureUnit); shader->SendInteger(uniforms.locations.pointLightShadowMap + index, availableTextureUnit);
} }
else else if (uniforms.locations.pointLightShadowMap != -1)
shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap); shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap);
if (uniforms.locations.directionalSpotLightShadowMap != -1)
shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture); shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture);
break; break;
} }
@ -88,18 +98,24 @@ namespace Nz
shader->SendVector(uniforms.locations.parameters2 + uniformOffset, Vector4f(light.direction, light.invRadius)); shader->SendVector(uniforms.locations.parameters2 + uniformOffset, Vector4f(light.direction, light.invRadius));
shader->SendVector(uniforms.locations.parameters3 + uniformOffset, Vector2f(light.innerAngleCosine, light.outerAngleCosine)); shader->SendVector(uniforms.locations.parameters3 + uniformOffset, Vector2f(light.innerAngleCosine, light.outerAngleCosine));
if (uniforms.locations.shadowMapping != -1)
shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr); shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr);
if (light.shadowMap) if (light.shadowMap)
{ {
Renderer::SetTexture(availableTextureUnit, light.shadowMap); Renderer::SetTexture(availableTextureUnit, light.shadowMap);
Renderer::SetTextureSampler(availableTextureUnit, s_shadowSampler); Renderer::SetTextureSampler(availableTextureUnit, s_shadowSampler);
if (uniforms.locations.lightViewProjMatrix != -1)
shader->SendMatrix(uniforms.locations.lightViewProjMatrix + index, light.transformMatrix); shader->SendMatrix(uniforms.locations.lightViewProjMatrix + index, light.transformMatrix);
if (uniforms.locations.directionalSpotLightShadowMap != -1)
shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, availableTextureUnit); shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, availableTextureUnit);
} }
else else if (uniforms.locations.directionalSpotLightShadowMap != -1)
shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture); shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture);
if (uniforms.locations.pointLightShadowMap != -1)
shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap); shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap);
break; break;
@ -108,8 +124,13 @@ namespace Nz
} }
else else
{ {
if (uniforms.locations.type != -1)
shader->SendInteger(uniforms.locations.type + uniformOffset, -1); //< Disable the light in the shader shader->SendInteger(uniforms.locations.type + uniformOffset, -1); //< Disable the light in the shader
if (uniforms.locations.directionalSpotLightShadowMap != -1)
shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture); shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture);
if (uniforms.locations.pointLightShadowMap != -1)
shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap); shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap);
} }
} }