[Bf-blender-cvs] [aa43c13] cycles_point_density: Particle color influence option for particle textures.

Lukas Tönne noreply at git.blender.org
Sat Apr 4 14:24:43 CEST 2015


Commit: aa43c13c3ea2b41fca6bf75696b4357355b584a4
Author: Lukas Tönne
Date:   Thu Mar 26 19:12:35 2015 +0100
Branches: cycles_point_density
https://developer.blender.org/rBaa43c13c3ea2b41fca6bf75696b4357355b584a4

Particle color influence option for particle textures.

This color is currently only displayed in the viewport (when enabling
"Texture" color mode in the Display settings). It will be used for
controlling the smoke color when using particles for smoke emission.

Conflicts:
	source/blender/blenkernel/intern/particle.c
	source/blender/editors/space_view3d/drawobject.c
	source/blender/makesdna/DNA_particle_types.h
	source/blender/makesdna/DNA_texture_types.h
	source/blender/makesrna/intern/rna_particle.c

===================================================================

M	release/scripts/startup/bl_ui/properties_texture.py
M	source/blender/blenkernel/BKE_particle.h
M	source/blender/blenkernel/intern/particle.c
M	source/blender/editors/space_view3d/drawobject.c
M	source/blender/makesdna/DNA_particle_types.h
M	source/blender/makesdna/DNA_texture_types.h
M	source/blender/makesrna/intern/rna_particle.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py
index a48e062..56b409d 100644
--- a/release/scripts/startup/bl_ui/properties_texture.py
+++ b/release/scripts/startup/bl_ui/properties_texture.py
@@ -1148,6 +1148,7 @@ class TEXTURE_PT_influence(TextureSlotPanel, Panel):
             factor_but(col, "use_map_life", "life_factor", "Lifetime")
             factor_but(col, "use_map_density", "density_factor", "Density")
             factor_but(col, "use_map_size", "size_factor", "Size")
+            factor_but(col, "use_map_particle_color", "particle_color_factor", "Color")
 
             col = split.column()
             col.label(text="Physics:")
@@ -1179,7 +1180,8 @@ class TEXTURE_PT_influence(TextureSlotPanel, Panel):
 
         layout.separator()
 
-        if not isinstance(idblock, ParticleSettings):
+        show_blend_settings = (not isinstance(idblock, ParticleSettings)) or tex.use_map_particle_color
+        if show_blend_settings:
             split = layout.split()
 
             col = split.column()
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index 27eeb09..5c245c9 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -110,6 +110,7 @@ typedef struct ParticleTexture {
 	float damp, gravity, field;           /* used in physics */
 	float length, clump, kink_freq, kink_amp, effector;  /* used in path caching */
 	float rough1, rough2, roughe;         /* used in path caching */
+	float color[3];
 } ParticleTexture;
 
 typedef struct ParticleSeam {
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 5d553f5..faebc69 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -3370,6 +3370,11 @@ static int get_particle_uv(DerivedMesh *dm, ParticleData *pa, int face_index, co
 		pvalue = texture_value_blend(def, pvalue, value, texfac, blend);      \
 	} (void)0
 
+#define SET_PARTICLE_TEXTURE_RGB(type, prgb, texfac)                          \
+	if ((event & mtex->mapto) & type) {                                       \
+		texture_rgb_blend(prgb, rgba, prgb, value, texfac, blend);            \
+	} (void)0
+
 #define CLAMP_PARTICLE_TEXTURE_POS(type, pvalue)                              \
 	if (event & type) {                                                       \
 		if (pvalue < 0.0f)                                                    \
@@ -3382,6 +3387,11 @@ static int get_particle_uv(DerivedMesh *dm, ParticleData *pa, int face_index, co
 		CLAMP(pvalue, -1.0f, 1.0f);                                           \
 	} (void)0
 
+#define CLAMP_PARTICLE_TEXTURE_RGB(type, prgb)                                \
+	if (event & type) {                                                       \
+		CLAMP3(prgb, 0.0f, 1.0f);                                              \
+	} (void)0
+
 static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSettings *part, ParticleData *par, int child_index, int face_index, const float fw[4], float *orco, ParticleTexture *ptex, int event, float cfra)
 {
 	MTex *mtex, **mtexp = part->mtex;
@@ -3391,6 +3401,7 @@ static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSetti
 	ptex->ivel = ptex->life = ptex->exist = ptex->size = ptex->damp =
 	ptex->gravity = ptex->field = ptex->time = ptex->clump = ptex->kink_freq = ptex->kink_amp =
 	ptex->effector = ptex->rough1 = ptex->rough2 = ptex->roughe = 1.0f;
+	ptex->color[0] = ptex->color[1] = ptex->color[2] = 1.0f;
 
 	ptex->length = 1.0f - part->randlength * psys_frand(psys, child_index + 26);
 	ptex->length *= part->clength_thres < psys_frand(psys, child_index + 27) ? part->clength : 1.0f;
@@ -3439,6 +3450,7 @@ static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSetti
 			SET_PARTICLE_TEXTURE(PAMAP_KINK_AMP, ptex->kink_amp, mtex->kinkampfac);
 			SET_PARTICLE_TEXTURE(PAMAP_KINK_FREQ, ptex->kink_freq, mtex->kinkfac);
 			SET_PARTICLE_TEXTURE(PAMAP_DENS, ptex->exist, mtex->padensfac);
+			SET_PARTICLE_TEXTURE_RGB(PAMAP_COLOR, ptex->color, mtex->pacolfac);
 		}
 	}
 
@@ -3448,6 +3460,7 @@ static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSetti
 	CLAMP_PARTICLE_TEXTURE_POS(PAMAP_KINK_FREQ, ptex->kink_freq);
 	CLAMP_PARTICLE_TEXTURE_POS(PAMAP_ROUGH, ptex->rough1);
 	CLAMP_PARTICLE_TEXTURE_POS(PAMAP_DENS, ptex->exist);
+	CLAMP_PARTICLE_TEXTURE_RGB(PAMAP_COLOR, ptex->color);
 }
 void psys_get_texture(ParticleSimulationData *sim, ParticleData *pa, ParticleTexture *ptex, int event, float cfra)
 {
@@ -3464,6 +3477,7 @@ void psys_get_texture(ParticleSimulationData *sim, ParticleData *pa, ParticleTex
 	ptex->ivel = ptex->life = ptex->exist = ptex->size = ptex->damp =
 	ptex->gravity = ptex->field = ptex->length = ptex->clump = ptex->kink_freq = ptex->kink_amp =
 	ptex->effector = ptex->rough1 = ptex->rough2 = ptex->roughe = 1.0f;
+	ptex->color[0] = ptex->color[1] = ptex->color[2] = 1.0f;
 
 	ptex->time = (float)(pa - sim->psys->particles) / (float)sim->psys->totpart;
 
@@ -3534,6 +3548,7 @@ void psys_get_texture(ParticleSimulationData *sim, ParticleData *pa, ParticleTex
 			SET_PARTICLE_TEXTURE(PAMAP_GRAVITY, ptex->gravity, mtex->gravityfac);
 			SET_PARTICLE_TEXTURE(PAMAP_DAMP, ptex->damp, mtex->dampfac);
 			SET_PARTICLE_TEXTURE(PAMAP_LENGTH, ptex->length, mtex->lengthfac);
+			SET_PARTICLE_TEXTURE_RGB(PAMAP_COLOR, ptex->color, mtex->pacolfac);
 		}
 	}
 
@@ -3546,6 +3561,7 @@ void psys_get_texture(ParticleSimulationData *sim, ParticleData *pa, ParticleTex
 	CLAMP_PARTICLE_TEXTURE_POSNEG(PAMAP_GRAVITY, ptex->gravity);
 	CLAMP_PARTICLE_TEXTURE_POS(PAMAP_DAMP, ptex->damp);
 	CLAMP_PARTICLE_TEXTURE_POS(PAMAP_LENGTH, ptex->length);
+	CLAMP_PARTICLE_TEXTURE_RGB(PAMAP_COLOR, ptex->color);
 }
 /************************************************/
 /*			Particle State						*/
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index f14c19d..10de26a 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -5004,6 +5004,12 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
 							case PART_DRAW_COL_ACC:
 								intensity = len_v3v3(pa->state.vel, pa->prev_state.vel) / ((pa->state.time - pa->prev_state.time) * part->color_vec_max);
 								break;
+							case PART_DRAW_COL_TEX: {
+								ParticleTexture ptex;
+								psys_get_texture(&sim, pa, &ptex, PAMAP_COLOR, cfra);
+								copy_v3_v3(ma_col, ptex.color);
+								break;
+							}
 							default:
 								intensity = 1.0f; /* should never happen */
 								BLI_assert(0);
diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h
index 95cb5c8..6e8b043 100644
--- a/source/blender/makesdna/DNA_particle_types.h
+++ b/source/blender/makesdna/DNA_particle_types.h
@@ -436,11 +436,14 @@ typedef enum eParticleChildFlag {
 } eParticleChildFlag;
 
 /* part->draw_col */
-#define PART_DRAW_COL_NONE		0
-#define PART_DRAW_COL_MAT		1
-#define PART_DRAW_COL_VEL		2
-#define PART_DRAW_COL_ACC		3
-
+typedef enum eParticleDrawColorMode {
+	PART_DRAW_COL_NONE		= 0,
+	PART_DRAW_COL_MAT		= 1,
+	PART_DRAW_COL_VEL		= 2,
+	PART_DRAW_COL_ACC		= 3,
+	PART_DRAW_COL_PARENT	= 4,
+	PART_DRAW_COL_TEX		= 5,
+} eParticleDrawColorMode;
 
 /* part->simplify_flag */
 #define PART_SIMPLIFY_ENABLE	1
@@ -606,6 +609,8 @@ typedef enum eParticleTextureInfluence {
 	PAMAP_ROUGH		= (1<<9),
 	PAMAP_LENGTH	= (1<<4),
 	PAMAP_CHILD		= (PAMAP_CLUMP | PAMAP_KINK_FREQ | PAMAP_KINK_AMP | PAMAP_ROUGH | PAMAP_LENGTH),
+	/* color */
+	PAMAP_COLOR		= (1<<14),
 } eParticleTextureInfluence;
 
 #endif
diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h
index af6adbe..523d444 100644
--- a/source/blender/makesdna/DNA_texture_types.h
+++ b/source/blender/makesdna/DNA_texture_types.h
@@ -85,8 +85,7 @@ typedef struct MTex {
 	/* particles */
 	float timefac, lengthfac, clumpfac, dampfac;
 	float kinkfac, kinkampfac, roughfac, padensfac, gravityfac;
-	float lifefac, sizefac, ivelfac, fieldfac;
-	int pad2;
+	float lifefac, sizefac, ivelfac, fieldfac, pacolfac;
 
 	/* lamp */
 	float shadowfac;
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index 029563a..44cbe09 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -1834,6 +1834,11 @@ static void rna_def_particle_settings_mtex(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Length", "Affect the child hair length");
 	RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
 
+	prop = RNA_def_property(srna, "use_map_particle_color", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_COLOR);
+	RNA_def_property_ui_text(prop, "Color", "Affect the particle color");
+	RNA_def_property_update(prop, 0, "rna_Particle_reset");
+
 
 	/* influence factors */
 	prop = RNA_def_property(srna, "time_factor", PROP_FLOAT, PROP_NONE);
@@ -1915,6 +1920,12 @@ static void rna_def_particle_settings_mtex(BlenderRNA *brna)
 	RNA_def_property_ui_range(prop, 0, 1, 10, 3);
 	RNA_def_property_ui_text(prop, "Rough Factor", "Amount texture affects child roughness");
 	RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
+
+	prop = RNA_def_property(srna, "particle_color_factor", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "pacolfac");
+	RNA_def_property_ui_range(prop, 0, 1, 10, 3);
+	RNA_def_property_ui_text(prop, "Particle Color Factor", "Amount texture affects particle color");
+	RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
 }
 
 static void rna_def_particle_settings(BlenderRNA *brna)
@@ -2033,6 +2044,7 @@ static void rna_def_particle_settings(BlenderRNA *brna)
 		{PART_DRAW_COL_MAT, "MATERIAL", 0, "Material", ""},
 		{PART_DRAW_COL_VEL, "VELOCITY", 0, "Velocity", ""},
 		{PART_DRAW_COL_ACC, "ACCELERATION", 0, "Acceleration", ""},
+		{PART_DRAW_COL_TEX, "TEXTURE", 0, "Texture"

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list