diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-07-18 23:36:09 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-07-18 23:49:10 +0300 |
commit | 9b406162490d9ee93e9786350432cdc1563b7bf6 (patch) | |
tree | cf573ef92132c45c7daac221296bfc76bf327628 /source/blender/render | |
parent | 7d10798af22f683a8f55a8c361ad5676bd4160d2 (diff) |
Cycles: Point density texture support
This commit implements point density texture for Cycles shading nodes.
It's done via creating voxel texture at shader compilation time, Not
totally memory efficient, but avoids adding sampling code to kernel
(which keeps render time as low as possible), In the future this will
be compensated by using OpenVDB for more efficient storage of sparse
volume data.
Sampling of the voxel texture is happening at blender side and the
same code is used as for Blender Internal's renderer.
This texture is controlled by only object, particle system and radius.
Linear falloff is used and there's no turbulence. This is because
falloff is expected to happen using Curve Mapping node. Turbulence
will be done as a distortion on the input coordinate. It's already
possible to fake it using nose textures and in the future we can add
more proper turbulence distortion node, which then could also be used
for 2D texture mapping.
Particle color support is done by Lukas, thanks!
Diffstat (limited to 'source/blender/render')
-rw-r--r-- | source/blender/render/intern/source/pointdensity.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index a99cc3c72a2..d2ec5d80c91 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -152,6 +152,7 @@ static void pointdensity_cache_psys(Scene *scene, sim.scene = scene; sim.ob = ob; sim.psys = psys; + sim.psmd = psys_get_modifier(ob, psys); /* in case ob->imat isn't up-to-date */ invert_m4_m4(ob->imat, ob->obmat); @@ -530,6 +531,7 @@ static int pointdensity(PointDensity *pd, mul_v3_fl(vec, 1.0f / num); } + texres->tin = density; if (r_age != NULL) { *r_age = age; } @@ -537,24 +539,14 @@ static int pointdensity(PointDensity *pd, copy_v3_v3(r_vec, vec); } - texres->tin = density; - return retval; } -int pointdensitytex(Tex *tex, const float texvec[3], TexResult *texres) +static int pointdensity_color(PointDensity *pd, TexResult *texres, float age, const float vec[3]) { - PointDensity *pd = tex->pd; - float age = 0.0f; - float vec[3] = {0.0f, 0.0f, 0.0f}; - int retval = pointdensity(pd, texvec, texres, &age, vec); + int retval = 0; float col[4]; - BRICONT; - - if (pd->color_source == TEX_PD_COLOR_CONSTANT) - return retval; - retval |= TEX_RGB; switch (pd->color_source) { @@ -584,8 +576,7 @@ int pointdensitytex(Tex *tex, const float texvec[3], TexResult *texres) } case TEX_PD_COLOR_PARTVEL: texres->talpha = true; - mul_v3_fl(vec, pd->speed_scale); - copy_v3_v3(&texres->tr, vec); + mul_v3_v3fl(&texres->tr, vec, pd->speed_scale); texres->ta = texres->tin; break; case TEX_PD_COLOR_CONSTANT: @@ -593,6 +584,20 @@ int pointdensitytex(Tex *tex, const float texvec[3], TexResult *texres) texres->tr = texres->tg = texres->tb = texres->ta = 1.0f; break; } + + return retval; +} + +int pointdensitytex(Tex *tex, const float texvec[3], TexResult *texres) +{ + PointDensity *pd = tex->pd; + float age = 0.0f; + float vec[3] = {0.0f, 0.0f, 0.0f}; + int retval = pointdensity(pd, texvec, texres, &age, vec); + + BRICONT; + + retval |= pointdensity_color(pd, texres, age, vec); BRICONTRGB; return retval; @@ -698,6 +703,7 @@ void RE_sample_point_density(Scene *scene, PointDensity *pd, texvec[2] += dim[2] * (float)z / (float)resolution; pointdensity(pd, texvec, &texres, &age, vec); + pointdensity_color(pd, &texres, age, vec); copy_v3_v3(&values[index*4 + 0], &texres.tr); values[index*4 + 3] = texres.tin; |