From e7dab88d69269ac7a778543676a436eae146ba73 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Mon, 19 Aug 2013 10:32:56 -0700 Subject: [PATCH] Square vector lengths to bunch them up towards the center, add a minimum length, include the URL of the SSAO tutorial. --- interface/src/renderer/AmbientOcclusionEffect.cpp | 7 ++++++- interface/src/renderer/AmbientOcclusionEffect.h | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/interface/src/renderer/AmbientOcclusionEffect.cpp b/interface/src/renderer/AmbientOcclusionEffect.cpp index 83ed2fdbec..ff86615b26 100644 --- a/interface/src/renderer/AmbientOcclusionEffect.cpp +++ b/interface/src/renderer/AmbientOcclusionEffect.cpp @@ -45,7 +45,12 @@ void AmbientOcclusionEffect::init() { const int SAMPLE_KERNEL_SIZE = 16; QVector3D sampleKernel[SAMPLE_KERNEL_SIZE]; for (int i = 0; i < SAMPLE_KERNEL_SIZE; i++) { - glm::vec3 vector = glm::ballRand(1.0f); + // square the length in order to increase density towards the center + glm::vec3 vector = glm::sphericalRand(1.0f); + float scale = randFloat(); + const float MIN_VECTOR_LENGTH = 0.01f; + const float MAX_VECTOR_LENGTH = 1.0f; + vector *= glm::mix(MIN_VECTOR_LENGTH, MAX_VECTOR_LENGTH, scale * scale); sampleKernel[i] = QVector3D(vector.x, vector.y, vector.z); } diff --git a/interface/src/renderer/AmbientOcclusionEffect.h b/interface/src/renderer/AmbientOcclusionEffect.h index 4891a6eb2c..d41bb65381 100644 --- a/interface/src/renderer/AmbientOcclusionEffect.h +++ b/interface/src/renderer/AmbientOcclusionEffect.h @@ -13,7 +13,8 @@ class ProgramObject; -/// A screen space ambient occlusion effect. +/// A screen space ambient occlusion effect. See John Chapman's tutorial at +/// http://john-chapman-graphics.blogspot.co.uk/2013/01/ssao-tutorial.html for reference. class AmbientOcclusionEffect { public: