mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 04:53:25 +02:00
Square vector lengths to bunch them up towards the center, add a minimum
length, include the URL of the SSAO tutorial.
This commit is contained in:
parent
b41fa1e03c
commit
e7dab88d69
2 changed files with 8 additions and 2 deletions
|
@ -45,7 +45,12 @@ void AmbientOcclusionEffect::init() {
|
||||||
const int SAMPLE_KERNEL_SIZE = 16;
|
const int SAMPLE_KERNEL_SIZE = 16;
|
||||||
QVector3D sampleKernel[SAMPLE_KERNEL_SIZE];
|
QVector3D sampleKernel[SAMPLE_KERNEL_SIZE];
|
||||||
for (int i = 0; i < SAMPLE_KERNEL_SIZE; i++) {
|
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);
|
sampleKernel[i] = QVector3D(vector.x, vector.y, vector.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
|
|
||||||
class ProgramObject;
|
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 {
|
class AmbientOcclusionEffect {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue