[Bf-blender-cvs] [3ff97697621] master: Fix T76041: Low contrast dirty vertex colors with loose geometry

Philipp Oeser noreply at git.blender.org
Wed Jun 17 05:48:11 CEST 2020


Commit: 3ff976976215a632067efd15ddb74a64fba061fb
Author: Philipp Oeser
Date:   Wed Jun 17 13:32:45 2020 +1000
Branches: master
https://developer.blender.org/rB3ff976976215a632067efd15ddb74a64fba061fb

Fix T76041: Low contrast dirty vertex colors with loose geometry

Add option to normalize vertex colors.

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

M	release/scripts/startup/bl_operators/vertexpaint_dirt.py

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

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



More information about the Bf-blender-cvs mailing list