Color sources for point density textures based on mesh vertices

This patch adds support for coloring point density textures based on several mesh vertex attributes.

* Vertex Color: Use a vertex color layer for coloring the point density texture
* Vertex Weight: Use a weights from a vertex group as intensity values. (for Blender Render engine the additional color band is used)
* Vertex Normals: Use object-space vertex normals as RGB values.

The vertex color source enum is stored separately from the particle color source, to avoid invalid values when switching.

Note that vertex colors are technically "corner colors" (MLoop), so each vertex can have as many colors as faces it is part of.
For the purpose of point density the mloop colors are simply averaged, which is physically plausible because corners can be viewed
as multiple points in the same location.
This commit is contained in:
Lukas Tönne
2016-03-24 11:41:44 +01:00
parent 8e9a55f1e5
commit bdae647670
7 changed files with 459 additions and 149 deletions

View File

@@ -830,12 +830,21 @@ class TEXTURE_PT_pointdensity(TextureButtonsPanel, Panel):
col.separator()
col.label(text="Color Source:")
if pd.point_source == 'PARTICLE_SYSTEM':
col.label(text="Color Source:")
col.prop(pd, "color_source", text="")
if pd.color_source in {'PARTICLE_SPEED', 'PARTICLE_VELOCITY'}:
col.prop(pd, "particle_color_source", text="")
if pd.particle_color_source in {'PARTICLE_SPEED', 'PARTICLE_VELOCITY'}:
col.prop(pd, "speed_scale")
if pd.color_source in {'PARTICLE_SPEED', 'PARTICLE_AGE'}:
if pd.particle_color_source in {'PARTICLE_SPEED', 'PARTICLE_AGE'}:
layout.template_color_ramp(pd, "color_ramp", expand=True)
else:
col.prop(pd, "vertex_color_source", text="")
if pd.vertex_color_source == 'VERTEX_COLOR':
if pd.object and pd.object.data:
col.prop_search(pd, "vertex_attribute_name", pd.object.data, "vertex_colors", text="")
if pd.vertex_color_source == 'VERTEX_WEIGHT':
if pd.object:
col.prop_search(pd, "vertex_attribute_name", pd.object, "vertex_groups", text="")
layout.template_color_ramp(pd, "color_ramp", expand=True)
col = split.column()