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:
authorJoseph Eagar <joeedh@gmail.com>2011-05-01 07:57:53 +0400
committerJoseph Eagar <joeedh@gmail.com>2011-05-01 07:57:53 +0400
commit9736061c07491286021b039d1307b3951496cf3b (patch)
tree87a054b6cf014b4170770653bbfc020e1a549b6a /source/blender/render/intern
parent4734a3321516283d1f2557818ddeb155aa34c56b (diff)
=trunk=
Made some improvements to the point density texture. Added support for tweaking the falloff with a custom curve. Also coded new falloff types based on the age or velocity of particles. Also added a test break check to the volumetric shade cache code, to avoid nasty hangups from the preview render (on render, exit, etc).
Diffstat (limited to 'source/blender/render/intern')
-rw-r--r--source/blender/render/intern/include/render_types.h1
-rw-r--r--source/blender/render/intern/source/pointdensity.c38
-rw-r--r--source/blender/render/intern/source/volume_precache.c4
3 files changed, 32 insertions, 11 deletions
diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h
index fd5ea7c789b..cf16211b6d1 100644
--- a/source/blender/render/intern/include/render_types.h
+++ b/source/blender/render/intern/include/render_types.h
@@ -486,6 +486,7 @@ typedef struct VolPrecachePart
float bbmin[3];
float voxel[3];
int working, done;
+ struct Render *re;
} VolPrecachePart;
typedef struct VolumePrecache
diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c
index 7ccf81b7755..d3d3e4d261c 100644
--- a/source/blender/render/intern/source/pointdensity.c
+++ b/source/blender/render/intern/source/pointdensity.c
@@ -47,6 +47,7 @@
#include "BKE_particle.h"
#include "BKE_scene.h"
#include "BKE_texture.h"
+#include "BKE_colortools.h"
#include "DNA_meshdata_types.h"
#include "DNA_texture_types.h"
@@ -69,9 +70,9 @@ static int point_data_used(PointDensity *pd)
int pd_bitflag = 0;
if (pd->source == TEX_PD_PSYS) {
- if ((pd->noise_influence == TEX_PD_NOISE_VEL) || (pd->color_source == TEX_PD_COLOR_PARTVEL) || (pd->color_source == TEX_PD_COLOR_PARTSPEED))
+ if ((pd->noise_influence == TEX_PD_NOISE_VEL) || (pd->falloff_type == TEX_PD_FALLOFF_PARTICLE_VEL) || (pd->color_source == TEX_PD_COLOR_PARTVEL) || (pd->color_source == TEX_PD_COLOR_PARTSPEED))
pd_bitflag |= POINT_DATA_VEL;
- if ((pd->noise_influence == TEX_PD_NOISE_AGE) || (pd->color_source == TEX_PD_COLOR_PARTAGE))
+ if ((pd->noise_influence == TEX_PD_NOISE_AGE) || (pd->color_source == TEX_PD_COLOR_PARTAGE) || (pd->falloff_type == TEX_PD_FALLOFF_PARTICLE_AGE))
pd_bitflag |= POINT_DATA_LIFE;
}
@@ -180,6 +181,7 @@ static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, Pa
}
pd->point_data[offset + i] = pa_time;
+
}
}
}
@@ -331,6 +333,8 @@ typedef struct PointDensityRangeData
float *age;
int point_data_used;
int offset;
+ struct CurveMapping *density_curve;
+ float velscale;
} PointDensityRangeData;
static void accum_density(void *userdata, int index, float squared_dist)
@@ -339,6 +343,15 @@ static void accum_density(void *userdata, int index, float squared_dist)
const float dist = (pdr->squared_radius - squared_dist) / pdr->squared_radius * 0.5f;
float density = 0.0f;
+ if (pdr->point_data_used & POINT_DATA_VEL) {
+ pdr->vec[0] += pdr->point_data[index*3 + 0]; //* density;
+ pdr->vec[1] += pdr->point_data[index*3 + 1]; //* density;
+ pdr->vec[2] += pdr->point_data[index*3 + 2]; //* density;
+ }
+ if (pdr->point_data_used & POINT_DATA_LIFE) {
+ *pdr->age += pdr->point_data[pdr->offset + index]; // * density;
+ }
+
if (pdr->falloff_type == TEX_PD_FALLOFF_STD)
density = dist;
else if (pdr->falloff_type == TEX_PD_FALLOFF_SMOOTH)
@@ -349,21 +362,21 @@ static void accum_density(void *userdata, int index, float squared_dist)
density = pdr->squared_radius;
else if (pdr->falloff_type == TEX_PD_FALLOFF_ROOT)
density = sqrt(dist);
+ else if (pdr->falloff_type == TEX_PD_FALLOFF_PARTICLE_AGE)
+ density = dist*MIN2(pdr->point_data[pdr->offset + index], 1.0f);
+ else if (pdr->falloff_type == TEX_PD_FALLOFF_PARTICLE_VEL)
+ density = dist*len_v3(pdr->point_data + index*3)*pdr->velscale;
- if (pdr->point_data_used & POINT_DATA_VEL) {
- pdr->vec[0] += pdr->point_data[index*3 + 0]; //* density;
- pdr->vec[1] += pdr->point_data[index*3 + 1]; //* density;
- pdr->vec[2] += pdr->point_data[index*3 + 2]; //* density;
- }
- if (pdr->point_data_used & POINT_DATA_LIFE) {
- *pdr->age += pdr->point_data[pdr->offset + index]; // * density;
+ if (pdr->density_curve && dist != 0.0f) {
+ density = curvemapping_evaluateF(pdr->density_curve, 0, density/dist)*dist;
}
*pdr->density += density;
}
-static void init_pointdensityrangedata(PointDensity *pd, PointDensityRangeData *pdr, float *density, float *vec, float *age)
+static void init_pointdensityrangedata(PointDensity *pd, PointDensityRangeData *pdr,
+ float *density, float *vec, float *age, struct CurveMapping *density_curve, float velscale)
{
pdr->squared_radius = pd->radius*pd->radius;
pdr->density = density;
@@ -375,6 +388,8 @@ static void init_pointdensityrangedata(PointDensity *pd, PointDensityRangeData *
pdr->noise_influence = pd->noise_influence;
pdr->point_data_used = point_data_used(pd);
pdr->offset = (pdr->point_data_used & POINT_DATA_VEL)?pd->totpoints*3:0;
+ pdr->density_curve = density_curve;
+ pdr->velscale = velscale;
}
@@ -394,7 +409,8 @@ int pointdensitytex(Tex *tex, float *texvec, TexResult *texres)
if ((!pd) || (!pd->point_tree))
return 0;
- init_pointdensityrangedata(pd, &pdr, &density, vec, &age);
+ init_pointdensityrangedata(pd, &pdr, &density, vec, &age,
+ (pd->flag&TEX_PD_FALLOFF_CURVE ? pd->falloff_curve : NULL), pd->falloff_speed_scale*0.001f);
noise_fac = pd->noise_fac * 0.5f; /* better default */
VECCOPY(co, texvec);
diff --git a/source/blender/render/intern/source/volume_precache.c b/source/blender/render/intern/source/volume_precache.c
index e75ee6ed469..fc3280db771 100644
--- a/source/blender/render/intern/source/volume_precache.c
+++ b/source/blender/render/intern/source/volume_precache.c
@@ -507,6 +507,9 @@ static void *vol_precache_part(void *data)
for (x=pa->minx; x < pa->maxx; x++) {
co[0] = pa->bbmin[0] + (pa->voxel[0] * (x + 0.5f));
+ if (pa->re->test_break && pa->re->test_break(pa->re->tbh))
+ break;
+
/* convert from world->camera space for shading */
mul_v3_m4v3(cco, pa->viewmat, co);
@@ -604,6 +607,7 @@ static void precache_init_parts(Render *re, RayObject *tree, ShadeInput *shi, Ob
pa->done = 0;
pa->working = 0;
+ pa->re = re;
pa->num = i;
pa->tree = tree;
pa->shi = shi;