[Bf-blender-cvs] [4ce8b5ca015] temp-texture-painting-gpu: Fix incorrect barycentric coords.
Jeroen Bakker
noreply at git.blender.org
Fri Sep 30 15:50:29 CEST 2022
Commit: 4ce8b5ca015602f5c62188029502cd8a1f60fff7
Author: Jeroen Bakker
Date: Fri Sep 30 08:24:51 2022 +0200
Branches: temp-texture-painting-gpu
https://developer.blender.org/rB4ce8b5ca015602f5c62188029502cd8a1f60fff7
Fix incorrect barycentric coords.
===================================================================
M source/blender/gpu/shaders/sculpt_paint/sculpt_paint_image_comp.glsl
M source/blender/gpu/shaders/sculpt_paint/sculpt_paint_image_lib.glsl
===================================================================
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 ce1caece01c..2c3a2351e6c 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
@@ -16,14 +16,14 @@ void main()
SCULPT_get_row_pos_and_delta(co1, co2, co3, triangle, row, pos, delta);
- for (int i = 0; i < row_len; i++) {
+ for (int x = 0; x < row_len; x++) {
float distance;
bool test_result = SCULPT_brush_test_sphere(paint_brush_buf.test, pos, distance);
- // pos += delta;
+ pos += delta;
if (!test_result) {
continue;
}
- imageStore(out_img, image_coord + ivec2(i, 0), paint_brush_buf.color);
+ imageStore(out_img, image_coord + ivec2(x, 0), paint_brush_buf.color);
}
}
\ No newline at end of file
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 769ecb06f0d..fef781b973e 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
@@ -9,14 +9,6 @@ bool SCULPT_brush_test_sphere(PaintBrushTestData test_data, vec3 co, out float d
return true;
}
-vec3 interp_v3_v3v3v3(vec3 co1, vec3 co2, vec3 co3, vec3 weights)
-{
- /* TODO(jbakker): there should be a glsl function for this. mat3*vec3?*/
- return vec3(co1.x * weights.x + co2.x * weights.y + co3.x * weights.z,
- co1.y * weights.x + co2.y * weights.y + co3.y * weights.z,
- co1.z * weights.x + co2.z * weights.y + co3.z * weights.z);
-}
-
void SCULPT_get_row_pos_and_delta(vec3 co1,
vec3 co2,
vec3 co3,
@@ -29,10 +21,11 @@ void SCULPT_get_row_pos_and_delta(vec3 co1,
vec3 barycentric_weights = vec3(row.start_barycentric_coord,
1.0 - row.start_barycentric_coord.x -
row.start_barycentric_coord.y);
- pos = interp_v3_v3v3v3(co1, co2, co3, barycentric_weights);
+ mat3 coords = mat3(co1, co2, co3);
+ pos = coords * barycentric_weights;
vec2 next_barycentric = row.start_barycentric_coord + triangle.delta_barycentric_coord;
- barycentric_weights = vec3(next_barycentric, 1.0 - next_barycentric - next_barycentric);
- vec3 next_pos = interp_v3_v3v3v3(co1, co2, co3, barycentric_weights);
+ barycentric_weights = vec3(next_barycentric, 1.0 - next_barycentric.x - next_barycentric.y);
+ vec3 next_pos = coords * barycentric_weights;
delta = next_pos - pos;
}
More information about the Bf-blender-cvs
mailing list