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
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_texture.h6
-rw-r--r--source/blender/blenkernel/intern/material.c2
-rw-r--r--source/blender/blenkernel/intern/texture.c47
-rw-r--r--source/blender/blenloader/intern/readfile.c7
-rw-r--r--source/blender/blenloader/intern/writefile.c1
-rw-r--r--source/blender/makesdna/DNA_material_types.h8
-rw-r--r--source/blender/makesdna/DNA_texture_types.h30
-rw-r--r--source/blender/render/intern/include/pointdensity.h43
-rw-r--r--source/blender/render/intern/include/render_types.h11
-rw-r--r--source/blender/render/intern/include/renderdatabase.h2
-rw-r--r--source/blender/render/intern/source/convertblender.c18
-rw-r--r--source/blender/render/intern/source/pointdensity.c195
-rw-r--r--source/blender/render/intern/source/renderdatabase.c15
-rw-r--r--source/blender/render/intern/source/texture.c4
-rw-r--r--source/blender/render/intern/source/volumetric.c35
-rw-r--r--source/blender/src/buttons_shading.c61
16 files changed, 391 insertions, 94 deletions
diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h
index cfcae3c44bc..e16ac2d369b 100644
--- a/source/blender/blenkernel/BKE_texture.h
+++ b/source/blender/blenkernel/BKE_texture.h
@@ -39,6 +39,7 @@ struct ColorBand;
struct HaloRen;
struct TexMapping;
struct EnvMap;
+struct PointDensity;
/* in ColorBand struct */
#define MAXCOLORBAND 32
@@ -74,6 +75,11 @@ void BKE_free_envmap(struct EnvMap *env);
struct EnvMap *BKE_add_envmap(void);
struct EnvMap *BKE_copy_envmap(struct EnvMap *env);
+void BKE_free_pointdensitydata(struct PointDensity *pd);
+void BKE_free_pointdensity(struct PointDensity *pd);
+struct PointDensity *BKE_add_pointdensity(void);
+struct PointDensity *BKE_copy_pointdensity(struct PointDensity *pd);
+
int BKE_texture_dependsOnTime(const struct Tex *texture);
#endif
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 04a68d1b1e1..64125d5834e 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -173,8 +173,6 @@ void init_material(Material *ma)
ma->vol_scattering = 1.0f;
ma->vol_absorption_col[0] = ma->vol_absorption_col[1] = ma->vol_absorption_col[2] = 0.0f;
ma->vol_raydepth = 15;
- ma->vol_part_maxnearest = 5;
- ma->vol_part_searchradius = 0.2f;
ma->mode= MA_TRACEBLE|MA_SHADBUF|MA_SHADOW|MA_RADIO|MA_RAYBIAS|MA_TANGENT_STR;
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index bb726887d32..62bab45dd50 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -409,6 +409,7 @@ void free_texture(Tex *tex)
free_plugin_tex(tex->plugin);
if(tex->coba) MEM_freeN(tex->coba);
if(tex->env) BKE_free_envmap(tex->env);
+ if(tex->pd) BKE_free_pointdensity(tex->pd);
BKE_previewimg_free(&tex->preview);
BKE_icon_delete((struct ID*)tex);
tex->id.icon_id = 0;
@@ -470,6 +471,11 @@ void default_tex(Tex *tex)
tex->env->depth=0;
}
+ if (tex->pd) {
+ tex->pd->radius = 0.3f;
+ tex->pd->nearest = 5;
+ }
+
pit = tex->plugin;
if (pit) {
varstr= pit->varstr;
@@ -566,6 +572,7 @@ Tex *copy_texture(Tex *tex)
if(texn->coba) texn->coba= MEM_dupallocN(texn->coba);
if(texn->env) texn->env= BKE_copy_envmap(texn->env);
+ if(texn->pd) texn->pd= BKE_copy_pointdensity(texn->pd);
if(tex->preview) texn->preview = BKE_previewimg_copy(tex->preview);
@@ -859,6 +866,46 @@ void BKE_free_envmap(EnvMap *env)
}
/* ------------------------------------------------------------------------- */
+
+PointDensity *BKE_add_pointdensity(void)
+{
+ PointDensity *pd;
+
+ pd= MEM_callocN(sizeof(PointDensity), "pointdensity");
+ pd->radius = 0.3f;
+ pd->nearest = 5;
+ pd->type = TEX_PD_PSYS;
+ pd->point_tree = NULL;
+
+ return pd;
+}
+
+PointDensity *BKE_copy_pointdensity(PointDensity *pd)
+{
+ PointDensity *pdn;
+ int a;
+
+ pdn= MEM_dupallocN(pd);
+ pdn->point_tree = NULL;
+
+ return pd;
+}
+
+void BKE_free_pointdensitydata(PointDensity *pd)
+{
+ if (pd->point_tree) {
+ BLI_kdtree_free(pd->point_tree);
+ pd->point_tree = NULL;
+ }
+}
+
+void BKE_free_pointdensity(PointDensity *pd)
+{
+ BKE_free_pointdensitydata(pd);
+ MEM_freeN(pd);
+}
+
+/* ------------------------------------------------------------------------- */
int BKE_texture_dependsOnTime(const struct Tex *texture)
{
if(texture->plugin) {
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index e80d2c7ce67..8aa0c8c5d5e 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2475,6 +2475,7 @@ static void lib_link_texture(FileData *fd, Main *main)
tex->ima= newlibadr_us(fd, tex->id.lib, tex->ima);
tex->ipo= newlibadr_us(fd, tex->id.lib, tex->ipo);
if(tex->env) tex->env->object= newlibadr(fd, tex->id.lib, tex->env->object);
+ if(tex->pd) tex->pd->object= newlibadr(fd, tex->id.lib, tex->pd->object);
tex->id.flag -= LIB_NEEDLINK;
}
@@ -2501,6 +2502,10 @@ static void direct_link_texture(FileData *fd, Tex *tex)
memset(tex->env->cube, 0, 6*sizeof(void *));
tex->env->ok= 0;
}
+ tex->pd= newdataadr(fd, tex->pd);
+ if(tex->pd) {
+ tex->pd->point_tree = NULL;
+ }
tex->preview = direct_link_preview_image(fd, tex->preview);
tex->iuser.ok= 1;
@@ -7885,8 +7890,6 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
ma->vol_scattering = 1.0f;
ma->vol_absorption_col[0] = ma->vol_absorption_col[1] = ma->vol_absorption_col[2] = 0.0f;
if (ma->vol_raydepth == 0) ma->vol_raydepth = 15;
- if (ma->vol_part_maxnearest == 0) ma->vol_part_maxnearest = 5;
- if (ma->vol_part_searchradius < 0.001f) ma->vol_part_searchradius = 0.20;
}
}
}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index e53c725867a..c4ae6ef858b 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -1334,6 +1334,7 @@ static void write_textures(WriteData *wd, ListBase *idbase)
if(tex->plugin) writestruct(wd, DATA, "PluginTex", 1, tex->plugin);
if(tex->coba) writestruct(wd, DATA, "ColorBand", 1, tex->coba);
if(tex->env) writestruct(wd, DATA, "EnvMap", 1, tex->env);
+ if(tex->pd) writestruct(wd, DATA, "PointDensity", 1, tex->pd);
write_previews(wd, tex->preview);
}
diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h
index dc23e7fcc6a..5d5ae042950 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -70,13 +70,10 @@ typedef struct Material {
float vol_stepsize, vol_shade_stepsize;
float vol_absorption, vol_scattering;
float vol_absorption_col[3];
- float vol_part_searchradius;
short vol_raydepth;
- short vol_part_maxnearest;
short vol_shadeflag;
- short vol_pad[3];
-
-
+ int volpad;
+
float fresnel_mir, fresnel_mir_i;
float fresnel_tra, fresnel_tra_i;
float filter; /* filter added, for raytrace transparency and transmissivity */
@@ -354,7 +351,6 @@ typedef struct Material {
#define MA_VOL_SHADED 1
#define MA_VOL_ATTENUATED 2
#define MA_VOL_SHADOWED 4
-#define MA_VOL_PARTICLES 8
#endif
diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h
index 111dc08ee02..ed172c24474 100644
--- a/source/blender/makesdna/DNA_texture_types.h
+++ b/source/blender/makesdna/DNA_texture_types.h
@@ -127,6 +127,22 @@ typedef struct EnvMap {
short recalc, lastsize;
} EnvMap;
+typedef struct PointDensity {
+ short flag;
+
+ short nearest;
+ float radius;
+
+ short type;
+ short pdpad[3];
+
+ struct Object *object; /* for 'Particle system' type - source object */
+ short psysindex; /* and object's psys number */
+ short pdpad2[3];
+
+ void *point_tree; /* the kd-tree containing points */
+} PointDensity;
+
typedef struct Tex {
ID id;
@@ -172,6 +188,7 @@ typedef struct Tex {
struct ColorBand *coba;
struct EnvMap *env;
struct PreviewImage * preview;
+ struct PointDensity *pd;
} Tex;
@@ -208,6 +225,8 @@ typedef struct TexMapping {
#define TEX_MUSGRAVE 11
#define TEX_VORONOI 12
#define TEX_DISTNOISE 13
+/* predicting ocean texture for 14 */
+#define TEX_POINTDENSITY 15
/* musgrave stype */
#define TEX_MFRACTAL 0
@@ -385,5 +404,16 @@ typedef struct TexMapping {
#define ENV_NORMAL 1
#define ENV_OSA 2
+/* **************** PointDensity ********************* */
+
+/* type */
+#define TEX_PD_PSYS 0
+#define TEX_PD_OBJECT 1
+#define TEX_PD_FILE 2
+
+/* psys_space */
+#define TEX_PD_PSYS_WORLDSPACE 0
+#define TEX_PD_PSYS_OBJECTSPACE 1
+
#endif
diff --git a/source/blender/render/intern/include/pointdensity.h b/source/blender/render/intern/include/pointdensity.h
new file mode 100644
index 00000000000..9c21cc0c253
--- /dev/null
+++ b/source/blender/render/intern/include/pointdensity.h
@@ -0,0 +1,43 @@
+/*
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Matt Ebb
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef POINTDENSITY_H
+#define POINTDENSITY_H
+
+/**
+ * Make point density kd-trees for all point density textures in the scene
+ */
+
+struct Render;
+struct TexResult;
+
+void make_pointdensities(struct Render *re);
+int pointdensitytex(struct Tex *tex, float *texvec, struct TexResult *texres);
+
+#endif /* POINTDENSITY_H */
+
diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h
index 2db70c460f9..b0003cadb55 100644
--- a/source/blender/render/intern/include/render_types.h
+++ b/source/blender/render/intern/include/render_types.h
@@ -198,8 +198,6 @@ struct Render
ListBase *sss_points;
struct Material *sss_mat;
- struct KDTree *particles_tree;
-
ListBase customdata_names;
struct Object *excludeob;
@@ -347,15 +345,6 @@ typedef struct HaloRen
struct Material *mat;
} HaloRen;
-/* ------------------------------------------------------------------------- */
-
-typedef struct ParticleRen
-{
- struct ParticleRen *next, *prev;
- float co[3]; // location
- // float col[3]; // colour
- // float vec[3]; // direction
-} ParticleRen;
/* ------------------------------------------------------------------------- */
diff --git a/source/blender/render/intern/include/renderdatabase.h b/source/blender/render/intern/include/renderdatabase.h
index 6fcd8576ed9..dc28eae1cc2 100644
--- a/source/blender/render/intern/include/renderdatabase.h
+++ b/source/blender/render/intern/include/renderdatabase.h
@@ -98,8 +98,6 @@ struct HaloRen *RE_inithalo(struct Render *re, struct ObjectRen *obr, struct Mat
struct HaloRen *RE_inithalo_particle(struct Render *re, struct ObjectRen *obr, struct DerivedMesh *dm, struct Material *ma, float *vec, float *vec1, float *orco, float *uvco, float hasize, float vectsize, int seed);
struct StrandBuffer *RE_addStrandBuffer(struct ObjectRen *obr, int totvert);
-struct ParticleRen *RE_cache_particle(Render *re, float *co, int index, float *vec);
-
struct ObjectRen *RE_addRenderObject(struct Render *re, struct Object *ob, struct Object *par, int index, int psysindex, int lay);
struct ObjectInstanceRen *RE_addRenderInstance(struct Render *re, struct ObjectRen *obr, struct Object *ob, struct Object *par, int index, int psysindex, float mat[][4], int lay);
void RE_makeRenderInstances(struct Render *re);
diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c
index 5eac30bf3be..40e9a32d003 100644
--- a/source/blender/render/intern/source/convertblender.c
+++ b/source/blender/render/intern/source/convertblender.c
@@ -103,6 +103,7 @@
#include "envmap.h"
#include "multires.h"
#include "occlusion.h"
+#include "pointdensity.h"
#include "render_types.h"
#include "rendercore.h"
#include "renderdatabase.h"
@@ -1476,9 +1477,8 @@ static void render_new_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mat
static_particle_strand(re, obr, ma, orco, surfnor, uvco, totuv, mcol, totcol, loc, loc1, time, first, line, adapt, adapt_angle, adapt_pix, override_uv);
}
else{
- //har= RE_inithalo_particle(re, obr, dm, ma, loc, NULL, orco, uvco, size, 0.0, seed);
- //if(har) har->lay= obr->ob->lay;
- RE_cache_particle(re, loc, 0, loc1);
+ har= RE_inithalo_particle(re, obr, dm, ma, loc, NULL, orco, uvco, size, 0.0, seed);
+ if(har) har->lay= obr->ob->lay;
}
}
static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem *psys, int timeoffset)
@@ -1705,8 +1705,6 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
if(path_nbr==0)
psys->lattice=psys_get_lattice(ob,psys);
- re->particles_tree = BLI_kdtree_new(totpart+totchild);
-
/* 3. start creating renderable things */
for(a=0,pa=pars; a<totpart+totchild; a++, pa++, seed++) {
random = rng_getFloat(rng);
@@ -2053,8 +2051,6 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
strandbuf->surface= cache_strand_surface(re, obr, psmd->dm, mat, timeoffset);
/* 4. clean up */
- if (re->particles_tree)
- BLI_kdtree_balance(re->particles_tree);
if(ma) do_mat_ipo(ma);
@@ -4417,8 +4413,6 @@ void RE_Database_Free(Render *re)
BLI_freelistN(&re->lampren);
BLI_freelistN(&re->lights);
-
- BLI_kdtree_free(re->particles_tree);
free_renderdata_tables(re);
@@ -4441,6 +4435,8 @@ void RE_Database_Free(Render *re)
end_radio_render();
end_render_materials();
+ free_pointdensities(re);
+
if(re->wrld.aosphere) {
MEM_freeN(re->wrld.aosphere);
re->wrld.aosphere= NULL;
@@ -4890,6 +4886,10 @@ void RE_Database_FromScene(Render *re, Scene *scene, int use_camera_view)
/* ENVIRONMENT MAPS */
if(!re->test_break())
make_envmaps(re);
+
+ /* point density texture */
+ if(!re->test_break())
+ make_pointdensities(re);
}
if(!re->test_break())
diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c
new file mode 100644
index 00000000000..00dbbd34f96
--- /dev/null
+++ b/source/blender/render/intern/source/pointdensity.c
@@ -0,0 +1,195 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * Contributors: Matt Ebb
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "BLI_kdtree.h"
+
+#include "BKE_DerivedMesh.h"
+#include "BKE_global.h"
+#include "BKE_main.h"
+
+#include "DNA_texture_types.h"
+#include "DNA_particle_types.h"
+
+#include "render_types.h"
+#include "texture.h"
+
+
+static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, ParticleSystem *psys)
+{
+ DerivedMesh* dm;
+ ParticleKey state;
+ float cfra=bsystem_time(ob,(float)G.scene->r.cfra,0.0);
+ int i, childexists;
+
+ /* init crap */
+ if (!psys || !ob || !pd) return;
+
+ /* Just to create a valid rendering context */
+ psys_render_set(ob, psys, re->viewmat, re->winmat, re->winx, re->winy, 0);
+
+ dm = mesh_create_derived_render(ob,CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL);
+ dm->release(dm);
+
+ if ( !psys_check_enabled(ob, psys) ){
+ psys_render_restore(ob, psys);
+ return;
+ }
+
+ /* finally do something */
+ pd->point_tree = BLI_kdtree_new(psys->totpart+psys->totchild);
+
+ if (psys->totchild > 0 && !(psys->part->draw & PART_DRAW_PARENT))
+ childexists = 1;
+
+ for (i = 0; i < psys->totpart + psys->totchild; i++) {
+
+ state.time = cfra;
+ if(psys_get_particle_state(ob, psys, i, &state, 0)) {
+ BLI_kdtree_insert(pd->point_tree, 0, state.co, NULL);
+ }
+ }
+
+ BLI_kdtree_balance(pd->point_tree);
+ psys_render_restore(ob, psys);
+}
+
+
+static void cache_pointdensity(Render *re, Tex *tex)
+{
+ PointDensity *pd = tex->pd;
+
+ if (pd->point_tree) {
+ BLI_kdtree_free(pd->point_tree);
+ pd->point_tree = NULL;
+ }
+
+ if (pd->type == TEX_PD_PSYS) {
+ ParticleSystem *psys;
+ Object *ob = pd->object;
+ int i;
+
+ for(psys=ob->particlesystem.first, i=0; i< pd->psysindex-1; i++)
+ psys= psys->next;
+
+ if (!ob || !psys) return;
+
+ pointdensity_cache_psys(re, pd, ob, psys);
+ }
+}
+
+static void free_pointdensity(Render *re, Tex *tex)
+{
+ PointDensity *pd = tex->pd;
+
+ if (pd->point_tree) {
+ BLI_kdtree_free(pd->point_tree);
+ pd->point_tree = NULL;
+ }
+}
+
+
+
+void make_pointdensities(Render *re)
+{
+ Tex *tex;
+
+ if(re->scene->r.scemode & R_PREVIEWBUTS)
+ return;
+
+ re->i.infostr= "Caching Point Densities";
+ re->stats_draw(&re->i);
+
+ for (tex= G.main->tex.first; tex; tex= tex->id.next) {
+ if(tex->id.us && tex->type==TEX_POINTDENSITY) {
+ cache_pointdensity(re, tex);
+ }
+ }
+}
+
+void free_pointdensities(Render *re)
+{
+ Tex *tex;
+
+ if(re->scene->r.scemode & R_PREVIEWBUTS)
+ return;
+
+ for (tex= G.main->tex.first; tex; tex= tex->id.next) {
+ if(tex->id.us && tex->type==TEX_POINTDENSITY) {
+ free_pointdensity(re, tex);
+ }
+ }
+}
+
+#define MAX_POINTS_NEAREST 25
+int pointdensitytex(Tex *tex, float *texvec, TexResult *texres)
+{
+ int rv = TEX_INT;
+
+ PointDensity *pd = tex->pd;
+ KDTreeNearest nearest[MAX_POINTS_NEAREST];
+ float density=0.0f;
+ int n, neighbours=0;
+
+ if ((!pd) || (!pd->point_tree)) {
+ texres->tin = 0.0f;
+ return 0;
+ }
+
+ neighbours = BLI_kdtree_find_n_nearest(pd->point_tree, pd->nearest, texvec, NULL, nearest);
+
+ for(n=1; n<neighbours; n++) {
+ if ( nearest[n].dist < pd->radius) {
+ float dist = 1.0 - (nearest[n].dist / pd->radius);
+
+ density += 3.0f*dist*dist - 2.0f*dist*dist*dist;
+ }
+ }
+
+ density /= neighbours;
+ density *= 1.0 / pd->radius;
+
+ texres->tin = density;
+
+ /*
+ texres->tr = 1.0f;
+ texres->tg = 1.0f;
+ texres->tb = 0.0f;
+
+ BRICONTRGB;
+
+ texres->ta = 1.0;
+
+ if (texres->nor!=NULL) {
+ texres->nor[0] = texres->nor[1] = texres->nor[2] = 0.0f;
+ }
+ */
+
+ BRICONT;
+
+ return rv;
+} \ No newline at end of file
diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c
index 14288167c4a..d44b49cc706 100644
--- a/source/blender/render/intern/source/renderdatabase.c
+++ b/source/blender/render/intern/source/renderdatabase.c
@@ -1041,21 +1041,6 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, float *vec, f
return har;
}
-ParticleRen *RE_cache_particle(Render *re, float *co, int index, float *vec)
-{
- /*
- ParticleRen *pr;
-
- pr= (LampRen *)MEM_callocN(sizeof(ParticleRen),"particleren");
- VECCOPY(pr->co, co);
- BLI_addtail(&re->vol_particles, pr);
- */
-
- BLI_kdtree_insert(re->particles_tree, index, co, NULL);
-
-
-}
-
HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Material *ma, float *vec, float *vec1,
float *orco, float *uvco, float hasize, float vectsize, int seed)
{
diff --git a/source/blender/render/intern/source/texture.c b/source/blender/render/intern/source/texture.c
index 2c143986900..3df53f7041a 100644
--- a/source/blender/render/intern/source/texture.c
+++ b/source/blender/render/intern/source/texture.c
@@ -62,6 +62,7 @@
#include "BKE_ipo.h"
#include "envmap.h"
+#include "pointdensity.h"
#include "renderpipeline.h"
#include "render_types.h"
#include "rendercore.h"
@@ -1216,6 +1217,9 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex,
retval= mg_distNoiseTex(tex, tmpvec, texres);
break;
+ case TEX_POINTDENSITY:
+ retval= pointdensitytex(tex, texvec, texres);
+ break;
}
if (tex->flag & TEX_COLORBAND) {
diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c
index 543c89f6b96..dcff34429b6 100644
--- a/source/blender/render/intern/source/volumetric.c
+++ b/source/blender/render/intern/source/volumetric.c
@@ -128,45 +128,12 @@ static int vol_get_bounds(ShadeInput *shi, float *co, float *vec, float *hitco,
}
}
-/* need to figure out a good default here */
-#define MAX_PARTICLES_NEAREST 50
-float get_particle_density(float *co, float radius, int max_nearest)
-{
- KDTreeNearest nearest[MAX_PARTICLES_NEAREST];
- float density=0.0f;
- int n, neighbours=0;
-
- /* no particles in preview for now -
- * can check for existence of particle kdtree better later on */
- if(R.r.scemode & R_PREVIEWBUTS) return;
-
- neighbours = BLI_kdtree_find_n_nearest(R.particles_tree, max_nearest, co, NULL, nearest);
-
- for(n=1; n<neighbours; n++) {
- if ( nearest[n].dist < radius) {
- float dist = 1.0 - (nearest[n].dist / radius);
-
- density += 3.0f*dist*dist - 2.0f*dist*dist*dist;
-
-
- }
- }
-
- density /= neighbours;
- density *= 1.0 / radius;
-
- return density;
-}
-
float vol_get_density(struct ShadeInput *shi, float *co)
{
float density = shi->mat->alpha;
float col[3] = {0.0, 0.0, 0.0};
- if (shi->mat->vol_shadeflag & MA_VOL_PARTICLES) {
- density += get_particle_density(co, shi->mat->vol_part_searchradius, shi->mat->vol_part_maxnearest);
- }
- else if (shi->mat->flag & MA_IS_TEXTURED) {
+ if (shi->mat->flag & MA_IS_TEXTURED) {
do_volume_tex(shi, co, MAP_ALPHA, col, &density);
}
diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c
index 0cfe469b7da..002c62c1a17 100644
--- a/source/blender/src/buttons_shading.c
+++ b/source/blender/src/buttons_shading.c
@@ -731,6 +731,49 @@ static void texture_panel_voronoi(Tex *tex)
uiDefButF(block, NUMSLI, B_TEXPRV, "W4: ", 10, 10, 150, 19, &tex->vn_w4, -2.0, 2.0, 10, 0, "Sets feature weight 4");
}
+static void texture_panel_pointdensity(Tex *tex)
+{
+ uiBlock *block;
+ PointDensity *pd;
+ short yco=PANEL_YMAX;
+
+ block= uiNewBlock(&curarea->uiblocks, "texture_panel_pointdensity", UI_EMBOSS, UI_HELV, curarea->win);
+ if(uiNewPanel(curarea, block, "Point Density", "Texture", PANELX, PANELY, PANELW, PANELH)==0) return;
+ uiSetButLock(tex->id.lib!=0, ERROR_LIBDATA_MESSAGE);
+
+ if(tex->pd==NULL) {
+ tex->pd= BKE_add_pointdensity();
+ tex->pd->object= OBACT;
+ }
+ if(tex->pd) {
+ pd= tex->pd;
+
+ uiBlockBeginAlign(block);
+ uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_REDR, "Ob:",
+ X2CLM1, yco-=BUTH, BUTW2, BUTH, &(pd->object), "Object that has the particle system");
+
+ if (pd->object->particlesystem.first) {
+ uiDefButS(block, NUM, B_REDR, "PSys:",
+ X2CLM1, yco-=BUTH, BUTW2, BUTH, &(pd->psysindex), 1, 10, 10, 3, "Particle system number in the object");
+ }
+ uiBlockEndAlign(block);
+
+ yco -= YSPACE;
+
+ uiBlockBeginAlign(block);
+ uiDefButF(block, NUM, B_REDR, "Radius: ",
+ X2CLM1, yco-=BUTH, BUTW2, BUTH, &(pd->radius), 0.001, 100.0, 10, 2, "Radius to look for nearby particles within");
+ uiDefButS(block, NUM, B_REDR, "Nearby: ",
+ X2CLM1, yco-=BUTH, BUTW2, BUTH, &(pd->nearest), 2.0, 30.0, 10, 2, "The number of nearby particles to check for density");
+ uiBlockEndAlign(block);
+
+ uiDefBut(block, LABEL, B_NOP, " ",
+ X2CLM2, yco-=BUTH, BUTW2, BUTH, 0, 0, 0, 0, 0, "");
+ }
+
+
+}
+
static char *layer_menu(RenderResult *rr, short *curlay)
{
@@ -1688,7 +1731,7 @@ static void texture_panel_texture(MTex *actmtex, Material *ma, World *wrld, Lamp
/* newnoise: all texture types as menu, not enough room for more buttons.
* Can widen panel, but looks ugly when other panels overlap it */
- sprintf(textypes, "Texture Type %%t|None %%x%d|Image %%x%d|EnvMap %%x%d|Clouds %%x%d|Marble %%x%d|Stucci %%x%d|Wood %%x%d|Magic %%x%d|Blend %%x%d|Noise %%x%d|Plugin %%x%d|Musgrave %%x%d|Voronoi %%x%d|DistortedNoise %%x%d", 0, TEX_IMAGE, TEX_ENVMAP, TEX_CLOUDS, TEX_MARBLE, TEX_STUCCI, TEX_WOOD, TEX_MAGIC, TEX_BLEND, TEX_NOISE, TEX_PLUGIN, TEX_MUSGRAVE, TEX_VORONOI, TEX_DISTNOISE);
+ sprintf(textypes, "Texture Type %%t|None %%x%d|Image %%x%d|EnvMap %%x%d|Clouds %%x%d|Marble %%x%d|Stucci %%x%d|Wood %%x%d|Magic %%x%d|Blend %%x%d|Noise %%x%d|Plugin %%x%d|Musgrave %%x%d|Voronoi %%x%d|DistortedNoise %%x%d|Point Density %%x%d", 0, TEX_IMAGE, TEX_ENVMAP, TEX_CLOUDS, TEX_MARBLE, TEX_STUCCI, TEX_WOOD, TEX_MAGIC, TEX_BLEND, TEX_NOISE, TEX_PLUGIN, TEX_MUSGRAVE, TEX_VORONOI, TEX_DISTNOISE, TEX_POINTDENSITY);
uiDefBut(block, LABEL, 0, "Texture Type", 160, 150, 140, 20, 0, 0.0, 0.0, 0, 0, "");
uiDefButS(block, MENU, B_TEXTYPE, textypes, 160, 125, 140, 25, &tex->type, 0,0,0,0, "Select texture type");
@@ -4272,7 +4315,7 @@ static void material_panel_material_volume(Material *ma)
uiDefButF(block, NUM, B_MATPRV, "Absorption: ",
X2CLM2, yco-=BUTH, BUTW2, BUTH, &(ma->vol_absorption), 0.0, 10.0, 10, 0, "Multiplier for absorption");
uiDefButF(block, COL, B_MATPRV, "",
- X2CLM2, yco-=BUTH, BUTW2, BUTH, &(ma->vol_absorption_col), 0, 0, 0, B_MATCOL, "");
+ X2CLM2, yco-=BUTH, BUTW2, BUTH, ma->vol_absorption_col, 0, 0, 0, B_MATCOL, "");
uiBlockEndAlign(block);
yco -= YSPACE;
@@ -4288,17 +4331,6 @@ static void material_panel_material_volume(Material *ma)
uiDefButF(block, NUM, B_MATPRV, "Scattering: ",
X2CLM2, yco-=BUTH, BUTW2, BUTH, &(ma->vol_scattering), 0.0, 10.0, 10, 0, "Multiplier for scattering");
-
- yco -= YSPACE;
-
- uiBlockBeginAlign(block);
- uiDefButBitS(block, TOG, MA_VOL_PARTICLES, B_MATPRV, "Particles",
- X2CLM1, yco-=BUTH, BUTW2, BUTH, &(ma->vol_shadeflag), 0, 0, 0, 0, "Render global particle cache");
- uiDefButF(block, NUM, B_MATPRV, "Radius: ",
- X2CLM1, yco-=BUTH, BUTW2, BUTH, &(ma->vol_part_searchradius), 0.001, 100.0, 10, 2, "Radius to look for nearby particles within");
- uiDefButS(block, NUM, B_MATPRV, "Nearby: ",
- X2CLM1, yco-=BUTH, BUTW2, BUTH, &(ma->vol_part_maxnearest), 2.0, 30.0, 10, 2, "The number of nearby particles to check for density");
- uiBlockEndAlign(block);
}
static void material_panel_nodes(Material *ma)
@@ -4683,6 +4715,9 @@ void texture_panels()
case TEX_VORONOI:
texture_panel_voronoi(tex);
break;
+ case TEX_POINTDENSITY:
+ texture_panel_pointdensity(tex);
+ break;
}
}
}