Fix for bug #28332: Smoke Simulation rendering artifacts.
authorMiika Hamalainen <blender@miikah.org>
Mon, 12 Sep 2011 09:55:04 +0000 (09:55 +0000)
committerMiika Hamalainen <blender@miikah.org>
Mon, 12 Sep 2011 09:55:04 +0000 (09:55 +0000)
Volume pre-caching altered shared data simultaneously in multiple threads, causing invalid scattering results when "Asymmetry" value was used. The view vector is now passed as a function argument.

source/blender/render/intern/include/volumetric.h
source/blender/render/intern/source/volume_precache.c
source/blender/render/intern/source/volumetric.c

index 6d8d4cbe0f2490791c6fa2d327ae57b3ba70c4a7..a2d1821a62b523fb521c0ace273463bdbd2b21a8 100644 (file)
@@ -36,7 +36,7 @@ struct ShadeInput;
 struct ShadeResult;
 
 float vol_get_density(struct ShadeInput *shi, float *co);
-void vol_get_scattering(ShadeInput *shi, float *scatter_col, float *co_);
+void vol_get_scattering(ShadeInput *shi, float *scatter_col, float *co_, float *view);
 
 void shade_volume_outside(ShadeInput *shi, ShadeResult *shr);
 void shade_volume_inside(ShadeInput *shi, ShadeResult *shr);
index 2037acc943f290e8a5f91ae9dbc67fa96a2476ad..18132c4a7f3ee9bb1901a1746d193282962c76e9 100644 (file)
@@ -490,7 +490,7 @@ static void *vol_precache_part(void *data)
        RayObject *tree = pa->tree;
        ShadeInput *shi = pa->shi;
        float scatter_col[3] = {0.f, 0.f, 0.f};
-       float co[3], cco[3];
+       float co[3], cco[3], view[3];
        int x, y, z, i;
        int res[3];
 
@@ -523,9 +523,9 @@ static void *vol_precache_part(void *data)
                                        continue;
                                }
                                
-                               copy_v3_v3(shi->view, cco);
-                               normalize_v3(shi->view);
-                               vol_get_scattering(shi, scatter_col, cco);
+                               copy_v3_v3(view, cco);
+                               normalize_v3(view);
+                               vol_get_scattering(shi, scatter_col, cco, view);
                        
                                obi->volume_precache->data_r[i] = scatter_col[0];
                                obi->volume_precache->data_g[i] = scatter_col[1];
index a5dab4adc159ac11b3a08c6e50c99b10fcd025a9..fdc9bbe4b33c6cfb4fb86de363db50ce07db7a99 100644 (file)
@@ -464,7 +464,7 @@ static void vol_get_transmittance(ShadeInput *shi, float *tr, float *co, float *
        tr[2] = expf(-tau[2]);
 }
 
-static void vol_shade_one_lamp(struct ShadeInput *shi, float *co, LampRen *lar, float *lacol)
+static void vol_shade_one_lamp(struct ShadeInput *shi, float *co, float *view, LampRen *lar, float *lacol)
 {
        float visifac, lv[3], lampdist;
        float tr[3]={1.0,1.0,1.0};
@@ -535,7 +535,7 @@ static void vol_shade_one_lamp(struct ShadeInput *shi, float *co, LampRen *lar,
        if (luminance(lacol) < 0.001f) return;
        
        normalize_v3(lv);
-       p = vol_get_phasefunc(shi, shi->mat->vol.asymmetry, shi->view, lv);
+       p = vol_get_phasefunc(shi, shi->mat->vol.asymmetry, view, lv);
        
        /* physically based scattering with non-physically based RGB gain */
        vol_get_reflection_color(shi, ref_col, co);
@@ -546,7 +546,7 @@ static void vol_shade_one_lamp(struct ShadeInput *shi, float *co, LampRen *lar,
 }
 
 /* single scattering only for now */
-void vol_get_scattering(ShadeInput *shi, float *scatter_col, float *co)
+void vol_get_scattering(ShadeInput *shi, float *scatter_col, float *co, float *view)
 {
        ListBase *lights;
        GroupObject *go;
@@ -561,7 +561,7 @@ void vol_get_scattering(ShadeInput *shi, float *scatter_col, float *co)
                lar= go->lampren;
                
                if (lar) {
-                       vol_shade_one_lamp(shi, co, lar, lacol);
+                       vol_shade_one_lamp(shi, co, view, lar, lacol);
                        add_v3_v3(scatter_col, lacol);
                }
        }
@@ -629,7 +629,7 @@ static void volumeintegrate(struct ShadeInput *shi, float *col, float *co, float
                                
                                vol_get_precached_scattering(&R, shi, scatter_col, p2);
                        } else
-                               vol_get_scattering(shi, scatter_col, p);
+                               vol_get_scattering(shi, scatter_col, p, shi->view);
                        
                        radiance[0] += stepd * tr[0] * (emit_col[0] + scatter_col[0]);
                        radiance[1] += stepd * tr[1] * (emit_col[1] + scatter_col[1]);