Fixed for stereo

This commit is contained in:
Olivier Prat 2018-09-25 10:31:24 +02:00
parent 190996e670
commit 0c586edeeb
2 changed files with 8 additions and 7 deletions

View file

@ -111,7 +111,7 @@ void AmbientOcclusionFramebuffer::allocate() {
auto width = sideSize.x;
auto height = sideSize.y;
auto format = gpu::Element::COLOR_RGBA_32;
_normalTexture = gpu::Texture::createRenderBuffer(format, width, height, gpu::Texture::SINGLE_MIP, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_POINT, gpu::Sampler::WRAP_CLAMP));
_normalTexture = gpu::Texture::createRenderBuffer(format, width, height, gpu::Texture::SINGLE_MIP, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR, gpu::Sampler::WRAP_CLAMP));
_normalFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("ssaoNormals"));
_normalFramebuffer->setRenderBuffer(0, _normalTexture);
}
@ -131,7 +131,7 @@ void AmbientOcclusionFramebuffer::allocate() {
auto format = gpu::Element::COLOR_R_8;
_occlusionSplitTexture = gpu::Texture::createRenderBufferArray(format, width, height, SSAO_SPLIT_COUNT, gpu::Texture::SINGLE_MIP,
gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR, gpu::Sampler::WRAP_CLAMP));
gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_POINT, gpu::Sampler::WRAP_CLAMP));
for (int i = 0; i < SSAO_SPLIT_COUNT; i++) {
_occlusionSplitFramebuffers[i] = gpu::FramebufferPointer(gpu::Framebuffer::create("occlusion"));
_occlusionSplitFramebuffers[i]->setRenderBuffer(0, _occlusionSplitTexture, i);

View file

@ -31,20 +31,21 @@ void main(void) {
ivec2 fragPixelPos = ivec2(fragCoord.xy);
vec2 fragUVPos = varTexCoord0;
#if SSAO_USE_QUAD_SPLIT
vec3 fragNormalES = getNormalEyeAtUV(fragUVPos, 0);
#endif
// Stereo side info based on the real viewport size of this pass
vec2 sideDepthSize = getDepthTextureSideSize(0);
ivec2 sideOcclusionSize = ivec2( getOcclusionSideSize() );
ivec2 sideOcclusionSize = ivec2( getOcclusionSplitSideSize() );
ivec4 side = getStereoSideInfoFromWidth(fragPixelPos.x, sideOcclusionSize.x);
// From now on, fragUVPos is the UV pos in the side
fragUVPos.x = mix(fragUVPos.x, fragUVPos.x * 2.0 - getStereoSide(side), isStereo());
// The position and normal of the pixel fragment in Eye space
vec2 deltaDepthUV = vec2(1.0) / sideDepthSize;
vec3 fragPositionES = buildPosition(side, fragUVPos);
#if SSAO_USE_QUAD_SPLIT
vec3 fragNormalES = getNormalEyeAtUV(fragUVPos, 0);
#else
#if !SSAO_USE_QUAD_SPLIT
vec3 fragNormalES = buildNormal(side, fragUVPos, fragPositionES, deltaDepthUV);
#endif