Commit: 23d2f708f312b73186aff4a42e952480413e7096
Author: Clément Foucault
Date:   Mon Feb 5 01:49:19 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB23d2f708f312b73186aff4a42e952480413e7096

Eevee: Pixel Filter: Add parameter & rescale final LUT.

===================================================================

M       release/scripts/startup/bl_ui/properties_render.py
M       source/blender/draw/engines/eevee/eevee_temporal_sampling.c
M       source/blender/makesrna/intern/rna_scene.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_render.py 
b/release/scripts/startup/bl_ui/properties_render.py
index 3ec1dbf85a7..12b0df795c7 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -892,7 +892,12 @@ class RENDER_PT_eevee_film(RenderButtonsPanel, Panel):
         scene = context.scene
         rd = scene.render
 
-        col = layout.column()
+        split = layout.split()
+
+        col = split.column()
+        col.prop(rd, "filter_size")
+
+        col = split.column()
         col.prop(rd, "alpha_mode", text="Alpha")
 
 
diff --git a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c 
b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c
index 0324310d398..09f40254f1b 100644
--- a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c
+++ b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c
@@ -49,7 +49,12 @@ static void eevee_create_shader_temporal_sampling(void)
        e_data.taa_resolve_sh = 
DRW_shader_create_fullscreen(datatoc_effect_temporal_aa_glsl, NULL);
 }
 
-static float blackman_harris(float x)
+static float UNUSED_FUNCTION(filter_box)(float UNUSED(x))
+{
+       return 1.0f;
+}
+
+static float filter_blackman_harris(float x)
 {
        /* Hardcoded 1px footprint [-0.5..0.5]. We resize later. */
        const float width = 1.0f;
@@ -110,10 +115,21 @@ static void eevee_create_cdf_table_temporal_sampling(void)
 {
        float *cdf_table = MEM_mallocN(sizeof(float) * FILTER_CDF_TABLE_SIZE, 
"Eevee Filter CDF table");
 
-       /* Use blackman-harris filter. */
-       compute_cdf(blackman_harris, cdf_table);
+       float filter_width = 2.0f; /* Use a 2 pixel footprint by default. */
+
+       {
+               /* Use blackman-harris filter. */
+               filter_width *= 2.0f;
+               compute_cdf(filter_blackman_harris, cdf_table);
+       }
+
        invert_cdf(cdf_table, e_data.inverted_cdf);
 
+       /* Scale and offset table. */
+       for (int i = 0; i < FILTER_CDF_TABLE_SIZE; ++i) {
+               e_data.inverted_cdf[i] = (e_data.inverted_cdf[i] - 0.5f) * 
filter_width;
+       }
+
        MEM_freeN(cdf_table);
 }
 
@@ -121,14 +137,14 @@ void EEVEE_temporal_sampling_matrices_calc(
         EEVEE_EffectsInfo *effects, float viewmat[4][4], float persmat[4][4], 
const double ht_point[2])
 {
        const float *viewport_size = DRW_viewport_size_get();
+       const DRWContextState *draw_ctx = DRW_context_state_get();
+       Scene *scene = draw_ctx->scene;
+       RenderData *rd = &scene->r;
+
+       float filter_size = rd->gauss; /* Sigh.. Stupid legacy naming. */
 
-       float filter_size = 1.5f; /* TODO Option. */
-       filter_size *= 2.0f; /* Because of Blackmann Harris to gaussian width 
matching. */
-       /* The cdf precomputing is giving distribution inside [0..1].
-        * We need to map it to [-1..1] THEN scale by the desired filter size. 
*/
-       filter_size *= 2.0f;
-       float ofs_x = (eval_table(e_data.inverted_cdf, (float)(ht_point[0])) - 
0.5f) * filter_size;
-       float ofs_y = (eval_table(e_data.inverted_cdf, (float)(ht_point[1])) - 
0.5f) * filter_size;
+       float ofs_x = eval_table(e_data.inverted_cdf, (float)(ht_point[0])) * 
filter_size;
+       float ofs_y = eval_table(e_data.inverted_cdf, (float)(ht_point[1])) * 
filter_size;
 
        window_translate_m4(
                effects->overide_winmat, persmat,
diff --git a/source/blender/makesrna/intern/rna_scene.c 
b/source/blender/makesrna/intern/rna_scene.c
index 5518b296e22..51efb5fa6ef 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -5720,7 +5720,8 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
        
        prop = RNA_def_property(srna, "filter_size", PROP_FLOAT, PROP_PIXEL);
        RNA_def_property_float_sdna(prop, NULL, "gauss");
-       RNA_def_property_range(prop, 0.5f, 1.5f);
+       RNA_def_property_range(prop, 0.0f, 500.0f);
+       RNA_def_property_ui_range(prop, 0.01f, 10.0f, 1, 2);
        RNA_def_property_ui_text(prop, "Filter Size", "Width over which the 
reconstruction filter combines samples");
        RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to