3D Texture Paint Plugin

I want to create a plugin to extend Blenders 3D texture painting, it should process the paint result with own code function. I believe this is interesting for many stuff like AI processing. Just click on a bad seam to let the AI fix it…

Does anybody know how to getWhatsUnderTheBrushWhilePainting and pass it back? We can do it with own code or even quick edit by example but those workarounds I already use successfull have limitations against blenders 3D brush and I believe there must be such image already internal for brush processing.

Pseudo code Logic:

import bpy

def on_paint_handler(scene):

brush = bpy.context.tool_settings.image_paint.brush

print(“Brush Class:”, brush.class)

image preprocessed = getWhatsUnderTheBrushWhilePainting

image processed = process(preprocessed) ## dont take care about this, I have this function ready. This could be AI API processing by example…

passBackToBrush(processed) # after own processing let blender continue the paint workflow with the result

bpy.app.handlers.depsgraph_update_post.append(on_paint_handler)

I don’t think you can with Python, you’ll need to go much lower into C++. Python is just a UI and operator wrapper, data manipulation happens in C++

Thank you! So if I understand right, it would not be possible as addon but by modifying Blender source? This would be a cool alterntive to quick edit and allow to create AI brushes or process brush painting with other own functions.
If creators could expose this to api would be cleanest way.

There are some possibilities to get some info (data) about the object under the mouse cursor…

…so on principle this could be used to get the actual position in the texture… but it seems to be a long and stony way to go… so it indeed might be a better idea to dive into the blender C/C+±sources… but this is also not that easy… (as in all greater and complexer projects…)