Graphics/Shadows: Add directional shadow mapping (WIP)
It still needs some debug Former-commit-id: 029872debc1a784712a33802ddd70a2b61e55623
This commit is contained in:
@@ -59,7 +59,9 @@ class NAZARA_GRAPHICS_API NzAbstractRenderQueue
|
||||
struct DirectionalLight
|
||||
{
|
||||
NzColor color;
|
||||
NzMatrix4f transformMatrix;
|
||||
NzVector3f direction;
|
||||
NzTexture* shadowMap;
|
||||
float ambientFactor;
|
||||
float diffuseFactor;
|
||||
};
|
||||
|
||||
@@ -25,6 +25,20 @@ inline void NzForwardRenderTechnique::SendLightUniforms(const NzShader* shader,
|
||||
shader->SendColor(uniforms.locations.color + uniformOffset, light.color);
|
||||
shader->SendVector(uniforms.locations.factors + uniformOffset, NzVector2f(light.ambientFactor, light.diffuseFactor));
|
||||
shader->SendVector(uniforms.locations.parameters1 + uniformOffset, NzVector4f(light.direction));
|
||||
|
||||
shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr);
|
||||
if (light.shadowMap)
|
||||
{
|
||||
NzRenderer::SetTexture(availableTextureUnit, light.shadowMap);
|
||||
NzRenderer::SetTextureSampler(availableTextureUnit, s_shadowSampler);
|
||||
|
||||
shader->SendMatrix(uniforms.locations.lightViewProjMatrix + index, light.transformMatrix);
|
||||
shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, availableTextureUnit);
|
||||
}
|
||||
else
|
||||
shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture);
|
||||
|
||||
shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -48,7 +62,7 @@ inline void NzForwardRenderTechnique::SendLightUniforms(const NzShader* shader,
|
||||
else
|
||||
shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap);
|
||||
|
||||
shader->SendInteger(uniforms.locations.spotLightShadowMap + index, dummyTexture);
|
||||
shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -69,10 +83,10 @@ inline void NzForwardRenderTechnique::SendLightUniforms(const NzShader* shader,
|
||||
NzRenderer::SetTextureSampler(availableTextureUnit, s_shadowSampler);
|
||||
|
||||
shader->SendMatrix(uniforms.locations.lightViewProjMatrix + index, light.transformMatrix);
|
||||
shader->SendInteger(uniforms.locations.spotLightShadowMap + index, availableTextureUnit);
|
||||
shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, availableTextureUnit);
|
||||
}
|
||||
else
|
||||
shader->SendInteger(uniforms.locations.spotLightShadowMap + index, dummyTexture);
|
||||
shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture);
|
||||
|
||||
shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap);
|
||||
break;
|
||||
@@ -82,8 +96,8 @@ inline void NzForwardRenderTechnique::SendLightUniforms(const NzShader* shader,
|
||||
else
|
||||
{
|
||||
shader->SendInteger(uniforms.locations.type + uniformOffset, -1); //< Disable the light in the shader
|
||||
shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture);
|
||||
shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap);
|
||||
shader->SendInteger(uniforms.locations.spotLightShadowMap + index, dummyTexture);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -97,6 +97,7 @@ struct NzLightUniforms
|
||||
{
|
||||
int type;
|
||||
int color;
|
||||
int directionalSpotLightShadowMap;
|
||||
int factors;
|
||||
int lightViewProjMatrix;
|
||||
int parameters1;
|
||||
@@ -104,7 +105,6 @@ struct NzLightUniforms
|
||||
int parameters3;
|
||||
int pointLightShadowMap;
|
||||
int shadowMapping;
|
||||
int spotLightShadowMap;
|
||||
};
|
||||
|
||||
bool ubo;
|
||||
|
||||
Reference in New Issue
Block a user