[Bf-blender-cvs] [813a940dfaf] temp-texture-painting-gpu: Remove falloffshape variations. Making space for masking.

Jeroen Bakker noreply at git.blender.org
Tue Oct 4 15:23:12 CEST 2022


Commit: 813a940dfafa46e9936b013946ecffcbec7baeb1
Author: Jeroen Bakker
Date:   Tue Oct 4 15:20:32 2022 +0200
Branches: temp-texture-painting-gpu
https://developer.blender.org/rB813a940dfafa46e9936b013946ecffcbec7baeb1

Remove falloffshape variations. Making space for masking.

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

M	source/blender/editors/sculpt_paint/sculpt_intern.h
M	source/blender/editors/sculpt_paint/sculpt_paint_image.cc
M	source/blender/editors/sculpt_paint/sculpt_shaders.cc
M	source/blender/gpu/GPU_sculpt_shader_shared.h
M	source/blender/gpu/shaders/sculpt_paint/infos/sculpt_paint_image_info.hh
M	source/blender/gpu/shaders/sculpt_paint/sculpt_paint_image_comp.glsl
M	source/blender/gpu/shaders/sculpt_paint/sculpt_paint_image_merge_comp.glsl

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

diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index bda3bd53f06..ac7a43e7fc2 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -1882,24 +1882,8 @@ typedef enum BrushVariationFlags {
   BRUSH_TEST_SPHERE = (0 << 0),
   BRUSH_TEST_CIRCLE = (1 << 1),
   BRUSH_TEST_CLIPPING = (1 << 2),
-  BRUSH_VARIATION_FALLOFF_CUSTOM = (BRUSH_CURVE_CUSTOM << 3),
-  BRUSH_VARIATION_FALLOFF_SMOOTH = (BRUSH_CURVE_SMOOTH << 3),
-  BRUSH_VARIATION_FALLOFF_SPHERE = (BRUSH_CURVE_SPHERE << 3),
-  BRUSH_VARIATION_FALLOFF_ROOT = (BRUSH_CURVE_ROOT << 3),
-  BRUSH_VARIATION_FALLOFF_SHARP = (BRUSH_CURVE_SHARP << 3),
-  BRUSH_VARIATION_FALLOFF_LIN = (BRUSH_CURVE_LIN << 3),
-  BRUSH_VARIATION_FALLOFF_POW4 = (BRUSH_CURVE_POW4 << 3),
-  BRUSH_VARIATION_FALLOFF_INVSQUARE = (BRUSH_CURVE_INVSQUARE << 3),
-  BRUSH_VARIATION_FALLOFF_CONSTANT = (BRUSH_CURVE_CONSTANT << 3),
-  BRUSH_VARIATION_FALLOFF_SMOOTHER = (BRUSH_CURVE_SMOOTHER << 3),
-  BRUSH_MAX_VARIATIONS = (1 << 8),
+  BRUSH_MAX_VARIATIONS = (1 << 3),
 } BrushVariationFlags;
-#define BRUSH_VARIATION_FALLOFF_MASK \
-  (BRUSH_VARIATION_FALLOFF_CUSTOM | BRUSH_VARIATION_FALLOFF_SMOOTH | \
-   BRUSH_VARIATION_FALLOFF_SPHERE | BRUSH_VARIATION_FALLOFF_ROOT | \
-   BRUSH_VARIATION_FALLOFF_SHARP | BRUSH_VARIATION_FALLOFF_LIN | BRUSH_VARIATION_FALLOFF_POW4 | \
-   BRUSH_VARIATION_FALLOFF_INVSQUARE | BRUSH_VARIATION_FALLOFF_CONSTANT | \
-   BRUSH_VARIATION_FALLOFF_SMOOTHER)
 struct GPUShader *SCULPT_shader_paint_image_get(BrushVariationFlags variation_flags);
 struct GPUShader *SCULPT_shader_paint_image_merge_get(void);
 
diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_image.cc b/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
index 00759007ccf..9ad88f95fcf 100644
--- a/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
@@ -532,6 +532,11 @@ static void init_paint_brush_test(const SculptSession &ss, PaintBrushData &r_pai
   r_paint_brush.test.symm_rot_mat_inv = ss.cache->symm_rot_mat_inv;
 }
 
+static void init_paint_brush_falloff(const Brush &brush, PaintBrushData &r_paint_brush)
+{
+  r_paint_brush.falloff_shape = brush.curve_preset;
+}
+
 static void init_paint_brush(const SculptSession &ss,
                              const Brush &brush,
                              PaintBrushData &r_paint_brush)
@@ -539,6 +544,7 @@ static void init_paint_brush(const SculptSession &ss,
   init_paint_brush_color(ss, brush, r_paint_brush);
   init_paint_brush_alpha(brush, r_paint_brush);
   init_paint_brush_test(ss, r_paint_brush);
+  init_paint_brush_falloff(brush, r_paint_brush);
 }
 
 struct GPUSculptPaintData {
@@ -654,44 +660,11 @@ static void ensure_gpu_buffers(TexturePaintingUserData &data)
 static BrushVariationFlags determine_shader_variation_flags(const Brush &brush)
 {
   BrushVariationFlags result = static_cast<BrushVariationFlags>(0);
+
   if (brush.falloff_shape == PAINT_FALLOFF_SHAPE_TUBE) {
     result = static_cast<BrushVariationFlags>(result | BRUSH_TEST_CIRCLE);
   }
 
-  BrushVariationFlags curve = static_cast<BrushVariationFlags>(0);
-  switch (brush.curve_preset) {
-    case BRUSH_CURVE_CUSTOM:
-      curve = BRUSH_VARIATION_FALLOFF_CUSTOM;
-      break;
-    case BRUSH_CURVE_SMOOTH:
-      curve = BRUSH_VARIATION_FALLOFF_SMOOTH;
-      break;
-    case BRUSH_CURVE_SPHERE:
-      curve = BRUSH_VARIATION_FALLOFF_SPHERE;
-      break;
-    case BRUSH_CURVE_ROOT:
-      curve = BRUSH_VARIATION_FALLOFF_ROOT;
-      break;
-    case BRUSH_CURVE_SHARP:
-      curve = BRUSH_VARIATION_FALLOFF_SHARP;
-      break;
-    case BRUSH_CURVE_LIN:
-      curve = BRUSH_VARIATION_FALLOFF_LIN;
-      break;
-    case BRUSH_CURVE_POW4:
-      curve = BRUSH_VARIATION_FALLOFF_POW4;
-      break;
-    case BRUSH_CURVE_INVSQUARE:
-      curve = BRUSH_VARIATION_FALLOFF_INVSQUARE;
-      break;
-    case BRUSH_CURVE_CONSTANT:
-      curve = BRUSH_VARIATION_FALLOFF_CONSTANT;
-      break;
-    case BRUSH_CURVE_SMOOTHER:
-      curve = BRUSH_VARIATION_FALLOFF_SMOOTHER;
-      break;
-  }
-  result = static_cast<BrushVariationFlags>(result | curve);
   return result;
 }
 
diff --git a/source/blender/editors/sculpt_paint/sculpt_shaders.cc b/source/blender/editors/sculpt_paint/sculpt_shaders.cc
index 559bbb88882..e9edf1799fc 100644
--- a/source/blender/editors/sculpt_paint/sculpt_shaders.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_shaders.cc
@@ -26,43 +26,6 @@ GPUShader *SCULPT_shader_paint_image_get(BrushVariationFlags variation_flags)
     std::stringstream info_name;
     info_name << "sculpt_paint_image";
     info_name << (variation_flags & BRUSH_TEST_CIRCLE ? "_circle" : "_sphere");
-    BrushVariationFlags curve_falloff = static_cast<BrushVariationFlags>(
-        variation_flags & BRUSH_VARIATION_FALLOFF_MASK);
-    switch (curve_falloff) {
-      case BRUSH_VARIATION_FALLOFF_CUSTOM:
-        info_name << "_custom";
-        break;
-      case BRUSH_VARIATION_FALLOFF_SMOOTH:
-        info_name << "_smooth";
-        break;
-      case BRUSH_VARIATION_FALLOFF_SPHERE:
-        info_name << "_sphere";
-        break;
-      case BRUSH_VARIATION_FALLOFF_ROOT:
-        info_name << "_root";
-        break;
-      case BRUSH_VARIATION_FALLOFF_SHARP:
-        info_name << "_sharp";
-        break;
-      case BRUSH_VARIATION_FALLOFF_LIN:
-        info_name << "_lin";
-        break;
-      case BRUSH_VARIATION_FALLOFF_POW4:
-        info_name << "_pow4";
-        break;
-      case BRUSH_VARIATION_FALLOFF_INVSQUARE:
-        info_name << "_invsquare";
-        break;
-      case BRUSH_VARIATION_FALLOFF_CONSTANT:
-        info_name << "_constant";
-        break;
-      case BRUSH_VARIATION_FALLOFF_SMOOTHER:
-        info_name << "_smoother";
-        break;
-      default:
-        BLI_assert_unreachable();
-    }
-
     printf("%s create shader %s\n", __func__, info_name.str().c_str());
 
     sh_data.paint_image_comp_sh[index] = GPU_shader_create_from_info_name(info_name.str().c_str());
diff --git a/source/blender/gpu/GPU_sculpt_shader_shared.h b/source/blender/gpu/GPU_sculpt_shader_shared.h
index d4ff5b72db0..2b1305ad190 100644
--- a/source/blender/gpu/GPU_sculpt_shader_shared.h
+++ b/source/blender/gpu/GPU_sculpt_shader_shared.h
@@ -51,9 +51,8 @@ struct PaintBrushData {
   float4 color;
   PaintBrushTestData test;
   float alpha;
-  float _pad0;
-  float _pad1;
-  float _pad2;
+  int falloff_shape;
+  float _pad0[2];
 };
 BLI_STATIC_ASSERT_ALIGN(PaintBrushData, 16)
 
diff --git a/source/blender/gpu/shaders/sculpt_paint/infos/sculpt_paint_image_info.hh b/source/blender/gpu/shaders/sculpt_paint/infos/sculpt_paint_image_info.hh
index 838a198a367..97eed0237f4 100644
--- a/source/blender/gpu/shaders/sculpt_paint/infos/sculpt_paint_image_info.hh
+++ b/source/blender/gpu/shaders/sculpt_paint/infos/sculpt_paint_image_info.hh
@@ -35,35 +35,12 @@ GPU_SHADER_CREATE_INFO(sculpt_paint_image_merge_compute)
 GPU_SHADER_CREATE_INFO(sculpt_paint_test_sphere).define("BRUSH_TEST_SPHERE");
 GPU_SHADER_CREATE_INFO(sculpt_paint_test_circle).define("BRUSH_TEST_CIRCLE");
 
-GPU_SHADER_CREATE_INFO(sculpt_paint_falloff_custom).define("BRUSH_CURVE_PRESET 0");
-GPU_SHADER_CREATE_INFO(sculpt_paint_falloff_smooth).define("BRUSH_CURVE_PRESET 1");
-GPU_SHADER_CREATE_INFO(sculpt_paint_falloff_sphere).define("BRUSH_CURVE_PRESET 2");
-GPU_SHADER_CREATE_INFO(sculpt_paint_falloff_root).define("BRUSH_CURVE_PRESET 3");
-GPU_SHADER_CREATE_INFO(sculpt_paint_falloff_sharp).define("BRUSH_CURVE_PRESET 4");
-GPU_SHADER_CREATE_INFO(sculpt_paint_falloff_lin).define("BRUSH_CURVE_PRESET 5");
-GPU_SHADER_CREATE_INFO(sculpt_paint_falloff_pow4).define("BRUSH_CURVE_PRESET 6");
-GPU_SHADER_CREATE_INFO(sculpt_paint_falloff_invsquare).define("BRUSH_CURVE_PRESET 7");
-GPU_SHADER_CREATE_INFO(sculpt_paint_falloff_constant).define("BRUSH_CURVE_PRESET 8");
-GPU_SHADER_CREATE_INFO(sculpt_paint_falloff_smoother).define("BRUSH_CURVE_PRESET 9");
-
 #define SCULPT_PAINT_FINAL_VARIATION(name, ...) \
   GPU_SHADER_CREATE_INFO(name).additional_info(__VA_ARGS__).do_static_compilation(true);
 
-#define SCULPT_PAINT_CURVE_VARIATION(name, ...) \
-  SCULPT_PAINT_FINAL_VARIATION(name##_custom, "sculpt_paint_falloff_custom", __VA_ARGS__) \
-  SCULPT_PAINT_FINAL_VARIATION(name##_smooth, "sculpt_paint_falloff_smooth", __VA_ARGS__) \
-  SCULPT_PAINT_FINAL_VARIATION(name##_sphere, "sculpt_paint_falloff_sphere", __VA_ARGS__) \
-  SCULPT_PAINT_FINAL_VARIATION(name##_root, "sculpt_paint_falloff_root", __VA_ARGS__) \
-  SCULPT_PAINT_FINAL_VARIATION(name##_sharp, "sculpt_paint_falloff_sharp", __VA_ARGS__) \
-  SCULPT_PAINT_FINAL_VARIATION(name##_lin, "sculpt_paint_falloff_lin", __VA_ARGS__) \
-  SCULPT_PAINT_FINAL_VARIATION(name##_pow4, "sculpt_paint_falloff_pow4", __VA_ARGS__) \
-  SCULPT_PAINT_FINAL_VARIATION(name##_invsquare, "sculpt_paint_falloff_invsquare", __VA_ARGS__) \
-  SCULPT_PAINT_FINAL_VARIATION(name##_constant, "sculpt_paint_falloff_constant", __VA_ARGS__) \
-  SCULPT_PAINT_FINAL_VARIATION(name##_smoother, "sculpt_paint_falloff_smoother", __VA_ARGS__)
-
 #define SCULPT_PAINT_TEST_VARIATIONS(name, ...) \
-  SCULPT_PAINT_CURVE_VARIATION(name##_sphere, "sculpt_paint_test_sphere", __VA_ARGS__) \
-  SCULPT_PAINT_CURVE_VARIATION(name##_circle, "sculpt_paint_test_circle", __VA_ARGS__)
+  SCULPT_PAINT_FINAL_VARIATION(name##_sphere, "sculpt_paint_test_sphere", __VA_ARGS__) \
+  SCULPT_PAINT_FINAL_VARIATION(name##_circle, "sculpt_paint_test_circle", __VA_ARGS__)
 
 SCULPT_PAINT_TEST_VARIATIONS(sculpt_paint_image, "sculpt_paint_image_compute")
 
diff --git a/source/blender/gpu/shaders/sculpt_paint/sculpt_paint_image_comp.glsl b/source/blender/gpu/shaders/sculpt_paint/sculpt_paint_image_comp.glsl
index 4fea3dd353d..2f3a4e3e1c8 100644
--- a/source/blender/gpu/shaders/sculpt_paint/sculpt_paint_image_comp.glsl
+++ b/source/blender/gpu/shaders/sculpt_paint/sculpt_paint_image_comp.glsl
@@ -48,7 +48,7 @@ void main()
         }
         // TODO: blend with color...
         float factor = SCULPT_hardness_factor(distance, step_data.hardness, step_data.radius);
-        float curve_factor = SCULPT_

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list