I made a material that paints to a render target using the “Draw canvas to render target” node shown in the image below.
What I want this material to do is only allow for the user to paint over only the red areas of the render target with black, any other color should have no effect. This works fine if I sample the render target at the brush location instead of the texcoord node, but the problem is that this will only paint to the render target if the exact center of the brush hits a red pixel, so the edges of the brush are ignored.
What I would like to do instead is have a smoother way of painting black only on the red present on the RT where each pixel of this material checks if it has a red color under it to determine if it should be black or not. I try to accomplish this by sampling the R channel of the RT and multiplying that with a bounds check to see if the distance between the texcoord and the brush location is within a range that the brush could reach.
I haven’t been able to get this to work no matter what I try, doing a LERP between the RT color and black and using the distance check as the alpha and that just produces a small copy of the RT as my brush stroke which is not what I want.
Does anyone have suggestions on how I can accomplish this? The brush position is being calculated using “Find Collision UV” node from a line trace.