[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17053] branches/sim_physics/source/ blender: * New option for step size: Randomized
Matt Ebb
matt at mke3.net
Mon Oct 13 02:35:58 CEST 2008
Revision: 17053
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17053
Author: broken
Date: 2008-10-13 02:35:58 +0200 (Mon, 13 Oct 2008)
Log Message:
-----------
* New option for step size: Randomized
This is on by default, and trades random noise for banding. It jitters
the step size from 75% to 125% of its original amount, and since it
uses the threaded random seeds, shouldn't flicker during animation.
These two images took roughly the same time to render:
http://mke3.net/blender/devel/rendering/volumetrics/vol_stepsize_randomized.jpg
Modified Paths:
--------------
branches/sim_physics/source/blender/makesdna/DNA_material_types.h
branches/sim_physics/source/blender/render/intern/source/volumetric.c
branches/sim_physics/source/blender/src/buttons_shading.c
Modified: branches/sim_physics/source/blender/makesdna/DNA_material_types.h
===================================================================
--- branches/sim_physics/source/blender/makesdna/DNA_material_types.h 2008-10-12 23:39:52 UTC (rev 17052)
+++ branches/sim_physics/source/blender/makesdna/DNA_material_types.h 2008-10-13 00:35:58 UTC (rev 17053)
@@ -63,11 +63,12 @@
/* end synced with render_types.h */
short material_type; /* solid, halo, volumetric */
- short pad5[3];
+ short pad5[2];
/* volumetrics */
+ short vol_stepsize_type;
+ float vol_stepsize, vol_shade_stepsize;
float vol_density_scale;
- float vol_stepsize, vol_shade_stepsize;
float vol_absorption, vol_scattering;
float vol_absorption_col[3];
short vol_shadeflag;
@@ -347,6 +348,11 @@
/* sss_flag */
#define MA_DIFF_SSS 1
+/* vol_stepsize_type */
+#define MA_VOL_STEP_RANDOMIZED 0
+#define MA_VOL_STEP_CONSTANT 1
+#define MA_VOL_STEP_ADAPTIVE 2
+
/* vol_shadeflag */
#define MA_VOL_SHADED 1
#define MA_VOL_ATTENUATED 2
Modified: branches/sim_physics/source/blender/render/intern/source/volumetric.c
===================================================================
--- branches/sim_physics/source/blender/render/intern/source/volumetric.c 2008-10-12 23:39:52 UTC (rev 17052)
+++ branches/sim_physics/source/blender/render/intern/source/volumetric.c 2008-10-13 00:35:58 UTC (rev 17053)
@@ -128,6 +128,29 @@
}
}
+#define STEPSIZE_VIEW 0
+#define STEPSIZE_SHADE 1
+float vol_get_stepsize(struct ShadeInput *shi, int context)
+{
+ if (shi->mat->vol_stepsize_type == MA_VOL_STEP_RANDOMIZED) {
+ /* range between 0.75 and 1.25 */
+ const float rnd = 0.5f * BLI_thread_frand(shi->thread) + 0.75f;
+
+ if (context == STEPSIZE_VIEW)
+ return shi->mat->vol_stepsize * rnd;
+ else if (context == STEPSIZE_SHADE)
+ return shi->mat->vol_shade_stepsize * rnd;
+ }
+ else {
+ // MA_VOL_STEP_CONSTANT
+
+ if (context == STEPSIZE_VIEW)
+ return shi->mat->vol_stepsize;
+ else if (context == STEPSIZE_SHADE)
+ return shi->mat->vol_shade_stepsize;
+ }
+}
+
float vol_get_density(struct ShadeInput *shi, float *co)
{
float density = shi->mat->alpha;
@@ -264,6 +287,7 @@
float hitco[3], *atten_co;
float p;
float scatter_fac;
+ float shade_stepsize = vol_get_stepsize(shi, STEPSIZE_SHADE);
if (lar->mode & LA_LAYER) if((lar->lay & shi->obi->lay)==0) return;
if ((lar->lay & shi->lay)==0) return;
@@ -303,8 +327,8 @@
atten_co = lar->co;
} else
atten_co = hitco;
-
- vol_get_attenuation(shi, tau, co, atten_co, density, shi->mat->vol_shade_stepsize);
+
+ vol_get_attenuation(shi, tau, co, atten_co, density, shade_stepsize);
tr[0] = exp(-tau[0]);
tr[1] = exp(-tau[1]);
tr[2] = exp(-tau[2]);
@@ -321,8 +345,6 @@
vol_get_scattering_fac(shi, &scatter_fac, co, density);
VecMulf(lacol, scatter_fac);
-
-
}
/* shadows -> trace a ray to find blocker geometry
@@ -362,7 +384,7 @@
{
float tr[3] = {1.0f, 1.0f, 1.0f}; /* total transmittance */
float radiance[3] = {0.f, 0.f, 0.f}, d_radiance[3] = {0.f, 0.f, 0.f};
- float stepsize = shi->mat->vol_stepsize;
+ float stepsize = vol_get_stepsize(shi, STEPSIZE_VIEW);
int nsteps;
float vec[3], stepvec[3] = {0.0, 0.0, 0.0};
float tau[3], step_emit[3], step_scatter[3] = {0.0, 0.0, 0.0};
Modified: branches/sim_physics/source/blender/src/buttons_shading.c
===================================================================
--- branches/sim_physics/source/blender/src/buttons_shading.c 2008-10-12 23:39:52 UTC (rev 17052)
+++ branches/sim_physics/source/blender/src/buttons_shading.c 2008-10-13 00:35:58 UTC (rev 17053)
@@ -4363,7 +4363,9 @@
uiBlockBeginAlign(block);
uiDefButF(block, NUM, B_MATPRV, "Step Size: ",
- X2CLM1, yco-=BUTH, BUTW2, BUTH, &(ma->vol_stepsize), 0.001, 100.0, 100, 2, "Ray marching step size");
+ X2CLM1, yco-=BUTH, BUTW2, BUTH, &(ma->vol_stepsize), 0.001, 100.0, 10, 2, "Ray marching step size");
+ uiDefButS(block, MENU, B_TEXREDR_PRV, "Step Size Calculation %t|Randomized %x0|Constant %x1",
+ X2CLM1, yco-=BUTH, BUTW2, BUTH, &ma->vol_stepsize_type, 0.0, 0.0, 0, 0, "Step size calculation, replace banding with jittering");
uiBlockEndAlign(block);
yco -= YSPACE;
@@ -4372,7 +4374,7 @@
uiDefButBitS(block, TOG, MA_VOL_ATTENUATED, B_MATPRV, "Shading",
X2CLM1, yco-=BUTH, BUTW2, BUTH, &(ma->vol_shadeflag), 0, 0, 0, 0, "Uses absorption for light attenuation");
uiDefButF(block, NUM, B_MATPRV, "Step Size: ",
- X2CLM1, yco-=BUTH, BUTW2, BUTH, &(ma->vol_shade_stepsize), 0.001, 100.0, 100, 2, "Step");
+ X2CLM1, yco-=BUTH, BUTW2, BUTH, &(ma->vol_shade_stepsize), 0.001, 100.0, 10, 2, "Step");
uiBlockEndAlign(block);
yco -= YSPACE;
@@ -4393,7 +4395,7 @@
uiDefButF(block, NUMSLI, B_MATPRV, "Density: ",
X2CLM2, yco-=BUTH, BUTW2, BUTH, &(ma->alpha), 0.0, 1.0, 0, 0, "Base density value - textured density is added on top");
uiDefButF(block, NUM, B_MATPRV, "Density Scale: ",
- X2CLM2, yco-=BUTH, BUTW2, BUTH, &(ma->vol_density_scale), 0.000001, 100.0, 100, 2, "Global density multiplier");
+ X2CLM2, yco-=BUTH, BUTW2, BUTH, &(ma->vol_density_scale), 0.000001, 100.0, 10, 2, "Global density multiplier");
uiBlockEndAlign(block);
yco -= YSPACE;
More information about the Bf-blender-cvs
mailing list