diff options
-rw-r--r-- | source/blender/makesdna/DNA_texture_types.h | 3 | ||||
-rw-r--r-- | source/blender/render/intern/source/pointdensity.c | 23 | ||||
-rw-r--r-- | source/blender/render/intern/source/volumetric.c | 16 | ||||
-rw-r--r-- | source/blender/src/buttons_shading.c | 4 |
4 files changed, 32 insertions, 14 deletions
diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h index d23672f9284..9c608302b22 100644 --- a/source/blender/makesdna/DNA_texture_types.h +++ b/source/blender/makesdna/DNA_texture_types.h @@ -132,7 +132,6 @@ typedef struct PointDensity { short falloff_type; float radius; - short source; short pdpad[3]; @@ -422,6 +421,8 @@ typedef struct TexMapping { #define TEX_PD_FALLOFF_STD 0 #define TEX_PD_FALLOFF_SMOOTH 1 #define TEX_PD_FALLOFF_SHARP 2 +#define TEX_PD_FALLOFF_CONSTANT 3 +#define TEX_PD_FALLOFF_ROOT 4 /* psys_cache_space */ #define TEX_PD_OBJECTLOC 0 diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index 4422b9fbbdd..c4124fba8bb 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -224,7 +224,6 @@ void free_pointdensities(Render *re) } } - void accum_density_std(void *userdata, int index, float squared_dist, float squared_radius) { float *density = userdata; @@ -249,6 +248,22 @@ void accum_density_sharp(void *userdata, int index, float squared_dist, float sq *density+= dist*dist; } +void accum_density_constant(void *userdata, int index, float squared_dist, float squared_radius) +{ + float *density = userdata; + + *density+= squared_radius; +} + +void accum_density_root(void *userdata, int index, float squared_dist, float squared_radius) +{ + float *density = userdata; + const float dist = squared_radius - squared_dist; + + *density+= sqrt(dist); +} + + #define MAX_POINTS_NEAREST 25 int pointdensitytex(Tex *tex, float *texvec, TexResult *texres) { @@ -267,7 +282,11 @@ int pointdensitytex(Tex *tex, float *texvec, TexResult *texres) BLI_bvhtree_range_query(pd->point_tree, texvec, pd->radius, accum_density_smooth, &density); else if (pd->falloff_type == TEX_PD_FALLOFF_SHARP) BLI_bvhtree_range_query(pd->point_tree, texvec, pd->radius, accum_density_sharp, &density); - + else if (pd->falloff_type == TEX_PD_FALLOFF_CONSTANT) + BLI_bvhtree_range_query(pd->point_tree, texvec, pd->radius, accum_density_constant, &density); + else if (pd->falloff_type == TEX_PD_FALLOFF_ROOT) + BLI_bvhtree_range_query(pd->point_tree, texvec, pd->radius, accum_density_root, &density); + texres->tin = density; /* diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c index 4d138ea8545..5d28540f17a 100644 --- a/source/blender/render/intern/source/volumetric.c +++ b/source/blender/render/intern/source/volumetric.c @@ -152,7 +152,7 @@ void vol_get_emission(ShadeInput *shi, float *em, float *co, float density) do_volume_tex(shi, co, MAP_EMIT+MAP_COL, col, &emission); - em[0] = em[1] = em[2] = emission; + em[0] = em[1] = em[2] = emission * density; VecMulVecf(em, em, col); } @@ -365,13 +365,10 @@ static void volumeintegrate(struct ShadeInput *shi, float *col, float *co, float /* get radiance from all points along the ray due to participating media */ for (s = 0; s < nsteps; s++) { if (s > 0) density = vol_get_density(shi, step_sta); - - /* there's only any point shading here + + /* there's only any use in shading here * if there's actually some density to shade! */ if (density > 0.01f) { - step_mid[0] = step_sta[0] + (stepvec[0] * 0.5); - step_mid[1] = step_sta[1] + (stepvec[1] * 0.5); - step_mid[2] = step_sta[2] + (stepvec[2] * 0.5); /* transmittance component (alpha) */ vol_get_attenuation(shi, tau, step_sta, step_end, density, stepsize); @@ -379,9 +376,10 @@ static void volumeintegrate(struct ShadeInput *shi, float *col, float *co, float tr[1] *= exp(-tau[1]); tr[2] *= exp(-tau[2]); - /* Terminate raymarching if transmittance is small */ - //if ((tr[0] + tr[1] + tr[2] * 0.333f) < 0.01f) continue; - + step_mid[0] = step_sta[0] + (stepvec[0] * 0.5); + step_mid[1] = step_sta[1] + (stepvec[1] * 0.5); + step_mid[2] = step_sta[2] + (stepvec[2] * 0.5); + /* incoming light via emission or scattering (additive) */ vol_get_emission(shi, step_emit, step_mid, density); vol_get_scattering(shi, step_scatter, step_mid, stepsize, density); diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c index 050dae6026e..7a154d084bc 100644 --- a/source/blender/src/buttons_shading.c +++ b/source/blender/src/buttons_shading.c @@ -758,7 +758,7 @@ 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", + uiDefButS(block, MENU, B_REDR, "Standard %x0|Smooth %x1|Sharp %x2|Constant %x3|Root %x4", X2CLM1, yco-=BUTH, BUTW2, BUTH, &pd->falloff_type, 0.0, 0.0, 0, 0, "Falloff type"); yco = PANEL_YMAX; @@ -4334,7 +4334,7 @@ static void material_panel_material_volume(Material *ma) uiDefButF(block, NUM, B_MATPRV, "Step Size: ", X2CLM1, yco-=BUTH, BUTW2, BUTH, &(ma->vol_shade_stepsize), 0.001, 100.0, 10, 2, "Step"); uiBlockEndAlign(block); - + yco = PANEL_YMAX; uiDefButF(block, NUMSLI, B_MATPRV, "Density: ", |