Disabled broken PCF and reset back to previous bias

This commit is contained in:
Olivier Prat 2017-10-26 18:29:29 +02:00
parent 44393f12d9
commit 0044759196
3 changed files with 17 additions and 2 deletions

View file

@ -18,6 +18,12 @@ std::string LightStage::_stageName { "LIGHT_STAGE"};
LightStage::LightStage() {
}
LightStage::Shadow::Schema::Schema() :
bias{ 0.005f },
scale{ 1.0f / MAP_SIZE } {
}
LightStage::Shadow::Shadow(model::LightPointer light) : _light{ light}, _frustum{ std::make_shared<ViewFrustum>() } {
framebuffer = gpu::FramebufferPointer(gpu::Framebuffer::createShadowmap(MAP_SIZE));
map = framebuffer->getDepthStencilBuffer();

View file

@ -60,17 +60,21 @@ public:
gpu::FramebufferPointer framebuffer;
gpu::TexturePointer map;
protected:
model::LightPointer _light;
std::shared_ptr<ViewFrustum> _frustum;
class Schema {
public:
Schema();
glm::mat4 projection;
glm::mat4 viewInverse;
glm::float32 bias = 0.003f;
glm::float32 scale = 1 / MAP_SIZE;
glm::float32 bias;
glm::float32 scale;
};
UniformBufferView _schemaBuffer = nullptr;

View file

@ -68,6 +68,8 @@ vec2 PCFkernel[4] = vec2[4](
);
float evalShadowAttenuationPCF(vec4 position, vec4 shadowTexcoord) {
// PCF is buggy so disable it for the time being
#if 0
float pcfRadius = 3.0;
float shadowScale = getShadowScale();
@ -80,6 +82,9 @@ float evalShadowAttenuationPCF(vec4 position, vec4 shadowTexcoord) {
fetchShadow(shadowTexcoord.xyz + shadowScale * vec3(offset + PCFkernel[2], 0.0)) +
fetchShadow(shadowTexcoord.xyz + shadowScale * vec3(offset + PCFkernel[3], 0.0))
));
#else
float shadowAttenuation = fetchShadow(shadowTexcoord.xyz);
#endif
return shadowAttenuation;
}