[Bf-blender-cvs] [22ab4e6] master: Use spiral mapping for SSAO - it reduces banding a lot, especially in higher sample counts. Probably a blurring pass might be a good addition here as well.
Antony Riakiotakis
noreply at git.blender.org
Wed Feb 25 23:10:07 CET 2015
Commit: 22ab4e6e13ebaabe3960af539e46a5bdfaf9f877
Author: Antony Riakiotakis
Date: Wed Feb 25 23:10:01 2015 +0100
Branches: master
https://developer.blender.org/rB22ab4e6e13ebaabe3960af539e46a5bdfaf9f877
Use spiral mapping for SSAO - it reduces banding a lot, especially in
higher sample counts. Probably a blurring pass might be a good addition
here as well.
===================================================================
M source/blender/gpu/intern/gpu_compositing.c
===================================================================
diff --git a/source/blender/gpu/intern/gpu_compositing.c b/source/blender/gpu/intern/gpu_compositing.c
index e0a55b2..d0ddc99 100644
--- a/source/blender/gpu/intern/gpu_compositing.c
+++ b/source/blender/gpu/intern/gpu_compositing.c
@@ -113,6 +113,7 @@ struct GPUFX {
bool restore_stencil;
};
+#if 0
/* concentric mapping, see "A Low Distortion Map Between Disk and Square" and
* http://psgraphics.blogspot.nl/2011/01/improved-code-for-concentric-map.html */
static GPUTexture * create_concentric_sample_texture(int side)
@@ -145,6 +146,27 @@ static GPUTexture * create_concentric_sample_texture(int side)
MEM_freeN(texels);
return tex;
}
+#endif
+
+static GPUTexture * create_spiral_sample_texture(int side)
+{
+ GPUTexture *tex;
+ int numsaples = side * side;
+ float *texels = (float *)MEM_mallocN(sizeof(float) * 2 * numsaples, "concentric_tex");
+ int i;
+ const int spirals = 8;
+
+ for (i = 0; i < numsaples; i++) {
+ float r = (i + 0.5f) / (float) numsaples;
+ float phi = 2.0f * M_PI * r * spirals;
+ texels[i * 2] = r * cos(phi);
+ texels[i * 2 + 1] = r * sin(phi);
+ }
+
+ tex = GPU_texture_create_1D_procedural(side * side, texels, NULL);
+ MEM_freeN(texels);
+ return tex;
+}
/* generate a new FX compositor */
GPUFX *GPU_fx_compositor_create(void)
@@ -343,7 +365,7 @@ bool GPU_fx_compositor_initialize_passes(
GPU_texture_free(fx->ssao_concentric_samples_tex);
}
- fx->ssao_concentric_samples_tex = create_concentric_sample_texture(fx_settings->ssao->samples);
+ fx->ssao_concentric_samples_tex = create_spiral_sample_texture(fx_settings->ssao->samples);
}
}
else {
More information about the Bf-blender-cvs
mailing list