1
$\begingroup$

I'm using dynamic paint to simulate a marker on a paper using true-to-life dimensions. The brush is set to use proximity (distance 0.001) and I notice that the resultant paint is offset a couple vertices to the xy direction.

(1) Is this something that can be fixed? I have tried adjusting it to use mesh for paint, I have adjusted falloff, projection, the brush geometry (cone and sphere), and subdivided the canvas and nothing corrected it.

(2) If this is not something that can be fixed, how can I compensate with the shader? The vertex color node does not have any inputs that I could do a transform on.

Here's a demo of the issue:

enter image description here

$\endgroup$

2 Answers 2

2
$\begingroup$

Shifted paint:

shifted paint

Fixed Paint:

fixed paint

Plane dimensions: 0.1 by 0.1

For the paint to come out correctly, i had to translate the entire brush geometry by 0.001 in every axis before calculating the dynamic paint, then i reverted it after, i did the translations with geometry nodes.

Brush Nodes:

fixer with geometry nodes Translation Geometry Nodes

If your brush has a scale different from one, you will need to divide the translation by the scale:

scaling offset in Geometry Nodes

If your brush has a rotation, you will need to rotate the translation by the inverse rotation of the brush:

rotating translation in Geometry Nodes

In large scales, the offset would be practically imperceptible, but at smaller scales, like a canvas with centimeters, the offset starts to be very visible, some smaller brushes will not even paint the canvas, since the raytrace would start too far from them.

The problem cause, i tested it, but only a single time:

/* a simple hack to minimize chance of ray leaks at identical ray <-> edge locations */
add_v3_fl(ray_start, 0.001f);

This line of code in the file dynamic_paint.c seems to translate raytrace origins by the vector (0.001, 0.001, 0.001) when using a mesh type brush. When i removed it, the expected behaviour appeared.

I tested before and after removing the code line, but did it only one time since Visual Studio doesn't like to build things fast in my PC.

If someone could test it, the code line is in the following method:

/*
* Paint a brush object mesh to the surface
*/
static void dynamic_paint_paint_mesh_cell_point_cb_ex(void *__restrict userdata, const int id, const TaskParallelTLS *__restrict UNUSED(tls))

Here's the file i did for this:

Edit:

I tested again with and without the code line:

Code line present Code line removed

$\endgroup$
0
$\begingroup$

I found that using "Image Sequence" format for the canvas instead of vertex was a far simpler solution that solved this problem (or at least made it easier to work on).

I'll leave this question unanswered as there may be a better solution that someone may find.

$\endgroup$
1
  • $\begingroup$ I used image sequence for dynamic paint and that shift is still there. Really don't know what's going on. $\endgroup$
    – AaronGuo
    Commented May 15, 2023 at 4:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .