Drawing in-game, in real time

Hello there! I’m working on a little project about drawing, and I wanted to share with you my progress and ask some questions :smiley:

Here’s a video:

(I know, my drawing skills aren’t exactly awesome)

In short, the plane is a Runtime Mesh Component that gets its vertex colors updated every frame. This is done by a C++ function (for performance reasons) that lerps between the brush color and the old vertex color based on the distance to the cursor, the falloff curve (currently linear) and a strength value controlled by the player.

However, I’m running into some obstacles:

First, when painting some colors over others everything looks horrible. Colors shift awkardly and hues appear out of nowhere. I know this is due to the interpolation function I’m using, the FLinearColor::LerpUsingHSV(From, To, Alpha) one. As explained in this article, this might be due to a poor function. Therefore I wan to write my own, but I’m not sure what algorithm to use. Any clues?

Also, when applying a brush it takes in account all vertices of the mesh and their distance. Taking in account only the affected vertices would be much faster. However, I can’t seem to find a function to return the points at certain or lower distance to a given point that don’t require iterating over all the vertices :frowning:

Anyway, I will a color selector and some other stuff while waiting for the Runtime Mesh Component version 2 that will hopefully allow me to paint any mesh, not just a plane :smiley:

Please share your feedback!

This is amazing!

Can you plug this into other material inputs like say, world position offset for a cool snow displacement system?

Yes, of course! And even better: since the mesh vertices are getting updated, you could as well move the vertices themselves :smiley:

Not sure how that would be in terms of performance, but it would certainly look nice

yes. this is pretty amazing thing.

i would love to see this in vr!
any hope you will share the code?