diff options
author | Matt Ebb <matt@mke3.net> | 2008-10-22 05:31:46 +0400 |
---|---|---|
committer | Matt Ebb <matt@mke3.net> | 2008-10-22 05:31:46 +0400 |
commit | 652e4b5225cc88d7bc74dfe092d60a8363ef3189 (patch) | |
tree | c5db813623395967538650fe685917e8b09f5124 /source | |
parent | 6f656f6482adfa93b010b364cac41a449b8fdc91 (diff) |
Point Density:
Replaced 'Sharp' falloff with 'Soft'. This falloff type has
a variable softness, and can get some quite smooth results.
It can be useful to get smooth transitions in density when
you're using particles on a large scale:
http://mke3.net/blender/devel/rendering/volumetrics/pd_falloff_soft.jpg
Also removed 'angular velocity' turbulence source - it
wasn't doing anything useful atm
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/texture.c | 1 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_texture_types.h | 8 | ||||
-rw-r--r-- | source/blender/render/intern/source/pointdensity.c | 19 | ||||
-rw-r--r-- | source/blender/src/buttons_shading.c | 12 |
5 files changed, 26 insertions, 16 deletions
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 33b824623fa..6f58e054f69 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -875,6 +875,7 @@ PointDensity *BKE_add_pointdensity(void) pd= MEM_callocN(sizeof(PointDensity), "pointdensity"); pd->radius = 0.3f; pd->falloff_type = TEX_PD_FALLOFF_STD; + pd->falloff_softness = 2.0; pd->source = TEX_PD_PSYS; pd->point_tree = NULL; pd->point_data = NULL; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 4af54832221..8f005e99053 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7908,6 +7908,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main) tex->pd->noise_fac = 1.0f; tex->pd->noise_influence = TEX_PD_NOISE_STATIC; } + if (tex->pd->falloff_softness < 1.0f) + tex->pd->falloff_softness = 2.0f; } } diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h index 95f61e73c79..c51311bb621 100644 --- a/source/blender/makesdna/DNA_texture_types.h +++ b/source/blender/makesdna/DNA_texture_types.h @@ -131,9 +131,10 @@ typedef struct PointDensity { short flag; short falloff_type; + float falloff_softness; float radius; short source; - short pdpad[3]; + short pdpad; struct Object *object; /* for 'Object' or 'Particle system' type - source object */ short psys_cache_space; /* cache points in worldspace, object space, ... ? */ @@ -425,7 +426,7 @@ typedef struct TexMapping { /* falloff_type */ #define TEX_PD_FALLOFF_STD 0 #define TEX_PD_FALLOFF_SMOOTH 1 -#define TEX_PD_FALLOFF_SHARP 2 +#define TEX_PD_FALLOFF_SOFT 2 #define TEX_PD_FALLOFF_CONSTANT 3 #define TEX_PD_FALLOFF_ROOT 4 @@ -441,8 +442,7 @@ typedef struct TexMapping { /* noise_influence */ #define TEX_PD_NOISE_STATIC 0 #define TEX_PD_NOISE_VEL 1 -#define TEX_PD_NOISE_ANGVEL 2 -#define TEX_PD_NOISE_TIME 3 +#define TEX_PD_NOISE_TIME 2 #endif diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index f7c6767fcd8..5f2c6153384 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -107,10 +107,6 @@ static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, Pa pd->point_data[i*3 + 0] = state.vel[0]; pd->point_data[i*3 + 1] = state.vel[1]; pd->point_data[i*3 + 2] = state.vel[2]; - } else if (pd->noise_influence == TEX_PD_NOISE_ANGVEL) { - pd->point_data[i*3 + 0] = state.ave[0]; - pd->point_data[i*3 + 1] = state.ave[1]; - pd->point_data[i*3 + 2] = state.ave[2]; } } } @@ -252,6 +248,7 @@ typedef struct PointDensityRangeData float squared_radius; float *point_data; float *vec; + float softness; short falloff_type; } PointDensityRangeData; @@ -265,8 +262,8 @@ void accum_density(void *userdata, int index, float squared_dist) density = dist; else if (pdr->falloff_type == TEX_PD_FALLOFF_SMOOTH) density = 3.0f*dist*dist - 2.0f*dist*dist*dist; - else if (pdr->falloff_type == TEX_PD_FALLOFF_SHARP) - density = dist*dist; + else if (pdr->falloff_type == TEX_PD_FALLOFF_SOFT) + density = pow(dist, pdr->softness); else if (pdr->falloff_type == TEX_PD_FALLOFF_CONSTANT) density = pdr->squared_radius; else if (pdr->falloff_type == TEX_PD_FALLOFF_ROOT) @@ -302,6 +299,7 @@ int pointdensitytex(Tex *tex, float *texvec, TexResult *texres) pdr.point_data = pd->point_data; pdr.falloff_type = pd->falloff_type; pdr.vec = vec; + pdr.softness = pd->falloff_softness; noise_fac = pd->noise_fac * 0.5f; /* better default */ if (pd->flag & TEX_PD_TURBULENCE) { @@ -329,13 +327,16 @@ int pointdensitytex(Tex *tex, float *texvec, TexResult *texres) texres->tin = density; - //texres->tr = vec[0]; - //texres->tg = vec[1]; - //texres->tb = vec[2]; + + + BRICONT; return TEX_INT; /* + texres->tr = vec[0]; + texres->tg = vec[1]; + texres->tb = vec[2]; BRICONTRGB; texres->ta = 1.0; diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c index 72a396d63be..7e4298b4b6b 100644 --- a/source/blender/src/buttons_shading.c +++ b/source/blender/src/buttons_shading.c @@ -738,7 +738,7 @@ static void texture_panel_pointdensity(Tex *tex) 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; + if(uiNewPanel(curarea, block, "Point Density", "Texture", PANELX, PANELY, PANELW, PANELH+25)==0) return; uiSetButLock(tex->id.lib!=0, ERROR_LIBDATA_MESSAGE); if(tex->pd==NULL) { @@ -758,8 +758,14 @@ static void texture_panel_pointdensity(Tex *tex) uiDefBut(block, LABEL, B_NOP, "Falloff:", X2CLM1, yco-=BUTH, BUTW2, BUTH, 0, 0, 0, 0, 0, ""); - uiDefButS(block, MENU, B_REDR, "Standard %x0|Smooth %x1|Sharp %x2|Constant %x3|Root %x4", + uiBlockBeginAlign(block); + uiDefButS(block, MENU, B_REDR, "Standard %x0|Smooth %x1|Soft %x2|Constant %x3|Root %x4", X2CLM1, yco-=BUTH, BUTW2, BUTH, &pd->falloff_type, 0.0, 0.0, 0, 0, "Falloff type"); + if (pd->falloff_type == TEX_PD_FALLOFF_SOFT) { + uiDefButF(block, NUM, B_REDR, "Softness: ", + X2CLM1, yco-=BUTH, BUTW2, BUTH, &(pd->falloff_softness), 1.0, 1024.0, 10, 2, "The intensity of the falloff"); + } + uiBlockEndAlign(block); yco -= YSPACE; @@ -782,7 +788,7 @@ static void texture_panel_pointdensity(Tex *tex) yco -= YSPACE; if (pd->source == TEX_PD_PSYS) { - uiDefButS(block, MENU, B_REDR, "Noise Influence %t|Static %x0|Velocity %x1|Angular Velocity %x2", + uiDefButS(block, MENU, B_REDR, "Noise Influence %t|Static %x0|Velocity %x1", X2CLM1, yco-=BUTH, BUTW2, BUTH, &(pd->noise_influence), 0.0, 0.0, 0, 0, "Noise Influence"); } } |