Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Ebb <matt@mke3.net>2008-10-01 11:13:28 +0400
committerMatt Ebb <matt@mke3.net>2008-10-01 11:13:28 +0400
commit25236b56a6c8c5619a3a8d35841be7e413df1e5e (patch)
tree104cc3879260e701926400f4183fb0169445ce08 /source/blender
parent8622cbca359d77eb980250b42d0635c0dddfa48b (diff)
* Fix for volumetric rendering. It previously wasn't multiplying
the emission component by the density at the current point, which made the volume too bright in less dense areas. This made it look too rough, as opposed to smooth as it should be. This makes the particle rendering look *much* better, thanks a bunch to ZanQdo for complaining and kicking my butt to make me realise the error. Here's an example of how smooth it looks now: http://mke3.net/blender/devel/rendering/volumetrics/smoke_test03.mov http://mke3.net/blender/devel/rendering/volumetrics/smoke_test03.blend Settings in existing files will have to be tweaked a bit, since what they were set up for before, was incorrect. * Added two new interpolation types to Point Density: Constant and Root. These work similarly to in proportional edit for example, just gives a bit more choice over how hard-edged the particles should look.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/makesdna/DNA_texture_types.h3
-rw-r--r--source/blender/render/intern/source/pointdensity.c23
-rw-r--r--source/blender/render/intern/source/volumetric.c16
-rw-r--r--source/blender/src/buttons_shading.c4
4 files changed, 32 insertions, 14 deletions
diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h
index d23672f9284..9c608302b22 100644
--- a/source/blender/makesdna/DNA_texture_types.h
+++ b/source/blender/makesdna/DNA_texture_types.h
@@ -132,7 +132,6 @@ typedef struct PointDensity {
short falloff_type;
float radius;
-
short source;
short pdpad[3];
@@ -422,6 +421,8 @@ typedef struct TexMapping {
#define TEX_PD_FALLOFF_STD 0
#define TEX_PD_FALLOFF_SMOOTH 1
#define TEX_PD_FALLOFF_SHARP 2
+#define TEX_PD_FALLOFF_CONSTANT 3
+#define TEX_PD_FALLOFF_ROOT 4
/* psys_cache_space */
#define TEX_PD_OBJECTLOC 0
diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c
index 4422b9fbbdd..c4124fba8bb 100644
--- a/source/blender/render/intern/source/pointdensity.c
+++ b/source/blender/render/intern/source/pointdensity.c
@@ -224,7 +224,6 @@ void free_pointdensities(Render *re)
}
}
-
void accum_density_std(void *userdata, int index, float squared_dist, float squared_radius)
{
float *density = userdata;
@@ -249,6 +248,22 @@ void accum_density_sharp(void *userdata, int index, float squared_dist, float sq
*density+= dist*dist;
}
+void accum_density_constant(void *userdata, int index, float squared_dist, float squared_radius)
+{
+ float *density = userdata;
+
+ *density+= squared_radius;
+}
+
+void accum_density_root(void *userdata, int index, float squared_dist, float squared_radius)
+{
+ float *density = userdata;
+ const float dist = squared_radius - squared_dist;
+
+ *density+= sqrt(dist);
+}
+
+
#define MAX_POINTS_NEAREST 25
int pointdensitytex(Tex *tex, float *texvec, TexResult *texres)
{
@@ -267,7 +282,11 @@ int pointdensitytex(Tex *tex, float *texvec, TexResult *texres)
BLI_bvhtree_range_query(pd->point_tree, texvec, pd->radius, accum_density_smooth, &density);
else if (pd->falloff_type == TEX_PD_FALLOFF_SHARP)
BLI_bvhtree_range_query(pd->point_tree, texvec, pd->radius, accum_density_sharp, &density);
-
+ else if (pd->falloff_type == TEX_PD_FALLOFF_CONSTANT)
+ BLI_bvhtree_range_query(pd->point_tree, texvec, pd->radius, accum_density_constant, &density);
+ else if (pd->falloff_type == TEX_PD_FALLOFF_ROOT)
+ BLI_bvhtree_range_query(pd->point_tree, texvec, pd->radius, accum_density_root, &density);
+
texres->tin = density;
/*
diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c
index 4d138ea8545..5d28540f17a 100644
--- a/source/blender/render/intern/source/volumetric.c
+++ b/source/blender/render/intern/source/volumetric.c
@@ -152,7 +152,7 @@ void vol_get_emission(ShadeInput *shi, float *em, float *co, float density)
do_volume_tex(shi, co, MAP_EMIT+MAP_COL, col, &emission);
- em[0] = em[1] = em[2] = emission;
+ em[0] = em[1] = em[2] = emission * density;
VecMulVecf(em, em, col);
}
@@ -365,13 +365,10 @@ static void volumeintegrate(struct ShadeInput *shi, float *col, float *co, float
/* get radiance from all points along the ray due to participating media */
for (s = 0; s < nsteps; s++) {
if (s > 0) density = vol_get_density(shi, step_sta);
-
- /* there's only any point shading here
+
+ /* there's only any use in shading here
* if there's actually some density to shade! */
if (density > 0.01f) {
- step_mid[0] = step_sta[0] + (stepvec[0] * 0.5);
- step_mid[1] = step_sta[1] + (stepvec[1] * 0.5);
- step_mid[2] = step_sta[2] + (stepvec[2] * 0.5);
/* transmittance component (alpha) */
vol_get_attenuation(shi, tau, step_sta, step_end, density, stepsize);
@@ -379,9 +376,10 @@ static void volumeintegrate(struct ShadeInput *shi, float *col, float *co, float
tr[1] *= exp(-tau[1]);
tr[2] *= exp(-tau[2]);
- /* Terminate raymarching if transmittance is small */
- //if ((tr[0] + tr[1] + tr[2] * 0.333f) < 0.01f) continue;
-
+ step_mid[0] = step_sta[0] + (stepvec[0] * 0.5);
+ step_mid[1] = step_sta[1] + (stepvec[1] * 0.5);
+ step_mid[2] = step_sta[2] + (stepvec[2] * 0.5);
+
/* incoming light via emission or scattering (additive) */
vol_get_emission(shi, step_emit, step_mid, density);
vol_get_scattering(shi, step_scatter, step_mid, stepsize, density);
diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c
index 050dae6026e..7a154d084bc 100644
--- a/source/blender/src/buttons_shading.c
+++ b/source/blender/src/buttons_shading.c
@@ -758,7 +758,7 @@ static void texture_panel_pointdensity(Tex *tex)
uiDefBut(block, LABEL, B_NOP, "Falloff:",
X2CLM1, yco-=BUTH, BUTW2, BUTH, 0, 0, 0, 0, 0, "");
- uiDefButS(block, MENU, B_REDR, "Standard %x0|Smooth %x1|Sharp %x2",
+ uiDefButS(block, MENU, B_REDR, "Standard %x0|Smooth %x1|Sharp %x2|Constant %x3|Root %x4",
X2CLM1, yco-=BUTH, BUTW2, BUTH, &pd->falloff_type, 0.0, 0.0, 0, 0, "Falloff type");
yco = PANEL_YMAX;
@@ -4334,7 +4334,7 @@ static void material_panel_material_volume(Material *ma)
uiDefButF(block, NUM, B_MATPRV, "Step Size: ",
X2CLM1, yco-=BUTH, BUTW2, BUTH, &(ma->vol_shade_stepsize), 0.001, 100.0, 10, 2, "Step");
uiBlockEndAlign(block);
-
+
yco = PANEL_YMAX;
uiDefButF(block, NUMSLI, B_MATPRV, "Density: ",