Switched AO buffer to single R8 component

This commit is contained in:
Olivier Prat 2018-09-18 11:54:39 +02:00
parent a2abf33669
commit f7379dfcc9
3 changed files with 7 additions and 6 deletions

View file

@ -78,7 +78,7 @@ void AmbientOcclusionFramebuffer::allocate() {
auto width = _frameSize.x;
auto height = _frameSize.y;
auto format = gpu::Element::COLOR_RGBA_32;
auto format = gpu::Element::COLOR_R_8;
_occlusionTexture = gpu::Texture::createRenderBuffer(format, width, height, gpu::Texture::SINGLE_MIP, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT, gpu::Sampler::WRAP_CLAMP));
_occlusionFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("occlusion"));

View file

@ -229,7 +229,6 @@ float getZEyeAtUV(vec2 texCoord, int level) {
const int LOG_MAX_OFFSET = 2;
const int MAX_MIP_LEVEL = 5;
int evalMipFromRadius(float radius) {
// mipLevel = floor(log(ssR / MAX_OFFSET));
return clamp(findMSB(int(radius)) - LOG_MAX_OFFSET, 0, MAX_MIP_LEVEL);
}
@ -293,12 +292,14 @@ float computeHorizonFromTap(vec3 tapPositionES, vec3 fragPositionES, vec3 fragNo
vec3 deltaVec = tapPositionES - fragPositionES;
float distance = length(deltaVec);
float cosHorizonAngle = dot(deltaVec, fragNormalES) / (distance + epsilon);
float cosHorizonAngle = 0.0;
float radiusFalloff = max(0.0, 1.0 - (distance*distance / getRadius2()));
cosHorizonAngle = dot(deltaVec, fragNormalES) / (distance + epsilon);
cosHorizonAngle = max(0.0, (cosHorizonAngle - getFalloffAngle()) * getFalloffAngleScale());
cosHorizonAngle *= radiusFalloff;
return cosHorizonAngle;
}

View file

@ -82,7 +82,7 @@ void main(void) {
// Accumulate the Obscurance for each samples
float sum = 0.0;
float keepTapRadius = 1.0;
int keepedMip = -1;
int keptMip = -1;
bool keep = false;
int sampleCount = int(getNumSamples());
for (int i = 0; i < sampleCount; ++i) {
@ -92,7 +92,7 @@ void main(void) {
vec2 fragToTap = vec2(ssC) + tap.xy - fragCoord.xy;
if (dot(fragToTap,fragToTap) < keepTapRadius) {
keep = true;
keepedMip = evalMipFromRadius(tap.z * float(doFetchMips()));
keptMip = evalMipFromRadius(tap.z * float(doFetchMips()));
}
vec3 tapUVZ = fetchTap(side, ssC, tap, imageSize);
@ -127,6 +127,6 @@ void main(void) {
if (!keep) {
outFragColor = vec4(0.1);
} else {
outFragColor.rgb = colorWheel(float(keepedMip)/float(MAX_MIP_LEVEL));
outFragColor.rgb = colorWheel(float(keptMip)/float(MAX_MIP_LEVEL));
}
}