diff options
author | Philipp Oeser <info@graphics-engineer.com> | 2020-06-17 06:32:45 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-06-17 06:43:20 +0300 |
commit | 3ff976976215a632067efd15ddb74a64fba061fb (patch) | |
tree | 2e31c425258fcfdc6694a3bded57564687753894 | |
parent | f9be5374ac19c3fb5f105a09ab5f7a397b00b1a1 (diff) |
Fix T76041: Low contrast dirty vertex colors with loose geometry
Add option to normalize vertex colors.
-rw-r--r-- | release/scripts/startup/bl_operators/vertexpaint_dirt.py | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/release/scripts/startup/bl_operators/vertexpaint_dirt.py b/release/scripts/startup/bl_operators/vertexpaint_dirt.py index 7024582ad30..62ef3cb34b5 100644 --- a/release/scripts/startup/bl_operators/vertexpaint_dirt.py +++ b/release/scripts/startup/bl_operators/vertexpaint_dirt.py @@ -32,7 +32,7 @@ def get_vcolor_layer_data(me): return lay.data -def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean, dirt_only): +def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean, dirt_only, normalize): from mathutils import Vector from math import acos import array @@ -74,14 +74,14 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean, tot_con = len(con[i]) if tot_con == 0: - continue + ang = pi / 2.0 # assume 90°, i. e. flat + else: + vec /= tot_con - vec /= tot_con - - # angle is the acos() of the dot product between normal and connected verts. - # > 90 degrees: convex - # < 90 degrees: concave - ang = acos(no.dot(vec)) + # angle is the acos() of the dot product between normal and connected verts. + # > 90 degrees: convex + # < 90 degrees: concave + ang = acos(no.dot(vec)) # enforce min/max ang = max(clamp_dirt, ang) @@ -104,8 +104,12 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean, vert_tone[j] /= len(c) * blur_strength + 1 del orig_vert_tone - min_tone = min(vert_tone) - max_tone = max(vert_tone) + if normalize: + min_tone = min(vert_tone) + max_tone = max(vert_tone) + else: + min_tone = clamp_dirt + max_tone = clamp_clean tone_range = max_tone - min_tone @@ -181,6 +185,11 @@ class VertexPaintDirt(Operator): description="Don't calculate cleans for convex areas", default=False, ) + normalize: BoolProperty( + name="Normalize", + description="Normalize the colors, increasing the contrast", + default=True, + ) @classmethod def poll(cls, context): @@ -198,6 +207,7 @@ class VertexPaintDirt(Operator): self.dirt_angle, self.clean_angle, self.dirt_only, + self.normalize, ) return ret |