diff options
author | Jeroen Bakker <jeroen@blender.org> | 2022-10-04 12:17:20 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2022-10-04 12:17:20 +0300 |
commit | 140d32d36206572dea9708b2df6f3b535c12b2f9 (patch) | |
tree | 3a4c37f348230b2d21bf048306fcd0f3407a1fa5 /source/blender/gpu/shaders | |
parent | 85f96255b25bbabb8e53d4183adea66a312a4742 (diff) |
Add support for projected falloff.
Diffstat (limited to 'source/blender/gpu/shaders')
3 files changed, 42 insertions, 4 deletions
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 1a834ff6516..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 @@ -18,9 +18,7 @@ GPU_SHADER_CREATE_INFO(sculpt_paint_image_compute) .push_constant(Type::INT, "pixel_row_offset") .push_constant(Type::IVEC2, "paint_step_range") .compute_source("sculpt_paint_image_comp.glsl") - .typedef_source("GPU_sculpt_shader_shared.h") - .define("BRUSH_TEST_SPHERE") - .do_static_compilation(true); + .typedef_source("GPU_sculpt_shader_shared.h"); GPU_SHADER_CREATE_INFO(sculpt_paint_image_merge_compute) .local_group_size(1, 1, 1) @@ -29,3 +27,21 @@ GPU_SHADER_CREATE_INFO(sculpt_paint_image_merge_compute) .compute_source("sculpt_paint_image_merge_comp.glsl") .typedef_source("GPU_sculpt_shader_shared.h") .do_static_compilation(true); + +/* -------------------------------------------------------------------- */ +/** \name Brush variations + * \{ */ + +GPU_SHADER_CREATE_INFO(sculpt_paint_test_sphere).define("BRUSH_TEST_SPHERE"); +GPU_SHADER_CREATE_INFO(sculpt_paint_test_circle).define("BRUSH_TEST_CIRCLE"); + +#define SCULPT_PAINT_FINAL_VARIATION(name, ...) \ + GPU_SHADER_CREATE_INFO(name).additional_info(__VA_ARGS__).do_static_compilation(true); + +#define SCULPT_PAINT_TEST_VARIATIONS(name, ...) \ + 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 2a43b3c8ebc..e85e894a25b 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 @@ -5,8 +5,10 @@ bool SCULPT_brush_test(PaintBrushTestData test_data, vec3 co, out float dist) { -#ifdef BRUSH_TEST_SPHERE +#if defined(BRUSH_TEST_SPHERE) return SCULPT_brush_test_sphere(test_data, step_data, co, dist); +#elif defined(BRUSH_TEST_CIRCLE) + return SCULPT_brush_test_circle(test_data, step_data, co, dist); #else dist = 0.0; return true; diff --git a/source/blender/gpu/shaders/sculpt_paint/sculpt_paint_image_lib.glsl b/source/blender/gpu/shaders/sculpt_paint/sculpt_paint_image_lib.glsl index bb6529fe966..159e24112d8 100644 --- a/source/blender/gpu/shaders/sculpt_paint/sculpt_paint_image_lib.glsl +++ b/source/blender/gpu/shaders/sculpt_paint/sculpt_paint_image_lib.glsl @@ -7,6 +7,26 @@ bool SCULPT_brush_test_sphere(PaintBrushTestData test_data, return dist <= step_data.radius; } +float plane_point_side_v3(vec4 plane, vec3 co) +{ + return dot(co, vec3(plane)) + plane.w; +} + +vec3 closest_to_plane_normalized_v3(vec4 plane, vec3 co) +{ + float side = plane_point_side_v3(plane, co); + return (vec3(plane) * -side) + co; +} + +bool SCULPT_brush_test_circle(PaintBrushTestData test_data, + PaintStepData step_data, + vec3 co, + out float dist) +{ + vec3 proj = closest_to_plane_normalized_v3(step_data.plane_view, co); + return SCULPT_brush_test_sphere(test_data, step_data, proj, dist); +} + void SCULPT_get_row_pos_and_delta(vec3 co1, vec3 co2, vec3 co3, |