Change samples variable for SSAO - now it is actual samples, not squared

- spiral scheme is much more intuitive here. Also use float number for
spirals to avoid having samples on the same radial direction when sample
number is divisible by spiral number.
This commit is contained in:
Antonis Ryakiotakis 2015-02-25 23:30:50 +01:00
parent 22ab4e6e13
commit 7708012b9d
2 changed files with 8 additions and 8 deletions

View File

@ -148,13 +148,13 @@ static GPUTexture * create_concentric_sample_texture(int side)
}
#endif
static GPUTexture * create_spiral_sample_texture(int side)
static GPUTexture * create_spiral_sample_texture(int numsaples)
{
GPUTexture *tex;
int numsaples = side * side;
float *texels = (float *)MEM_mallocN(sizeof(float) * 2 * numsaples, "concentric_tex");
int i;
const int spirals = 8;
/* random number to ensure we don't get conciding samples every circle */
const float spirals = 7.357;
for (i = 0; i < numsaples; i++) {
float r = (i + 0.5f) / (float) numsaples;
@ -163,7 +163,7 @@ static GPUTexture * create_spiral_sample_texture(int side)
texels[i * 2 + 1] = r * sin(phi);
}
tex = GPU_texture_create_1D_procedural(side * side, texels, NULL);
tex = GPU_texture_create_1D_procedural(numsaples, texels, NULL);
MEM_freeN(texels);
return tex;
}
@ -642,7 +642,7 @@ bool GPU_fx_do_composite_pass(GPUFX *fx, float projmat[4][4], bool is_persp, str
float ssao_params[4] = {fx_ssao->distance_max, fx_ssao->factor, fx_ssao->attenuation, 0.0f};
float sample_params[4];
sample_params[0] = fx->ssao_sample_count * fx->ssao_sample_count;
sample_params[0] = fx->ssao_sample_count;
/* multiplier so we tile the random texture on screen */
sample_params[2] = fx->gbuffer_dim[0] / 64.0;
sample_params[3] = fx->gbuffer_dim[1] / 64.0;
@ -978,5 +978,5 @@ void GPU_fx_compositor_init_ssao_settings(GPUSSAOSettings *fx_ssao)
fx_ssao->factor = 1.0f;
fx_ssao->distance_max = 0.2f;
fx_ssao->attenuation = 1.0f;
fx_ssao->samples = 4;
fx_ssao->samples = 20;
}

View File

@ -3903,8 +3903,8 @@ static void rna_def_gpu_ssao_fx(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "samples", PROP_INT, PROP_NONE);
RNA_def_property_ui_text(prop, "Samples", "Number of samples (final number is squared)");
RNA_def_property_range(prop, 1, 30); /* 0 is needed for compression. */
RNA_def_property_ui_text(prop, "Samples", "Number of samples");
RNA_def_property_range(prop, 1, 500);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA);