RenderTargets Erase Question

So Rendertargets.

I’m making a thing where you can paint a model. I have different shapes, colors, brush sizes, all sorts of things. I’m going to add stickers next, but the one thing I can’t figure out is creating an eraser.

Has anyone figured this out when it comes to Rendertargets? Whenever I look up Clearing Rendertargets I only see the one big clear, where it erases the whole thing. Is there something I’m missing?

I do have various way-too complicated ideas, but I feel like there must be a way to make part of the rendertarget translucent with your brush texture…hmm.

Thank you!

I have a similar use case, but the meshes are all small fairly small and one color to start (it’s a 3d coloring book type concept) so I can just reset the material on the whole mesh and it works fine. I was casually considering mark-level erasure but the line of thought hadn’t developed any further than painting over what was there with the default material color. I’m pretty green with 3D stuff and game engines though so i’d be super interested to see how you or anyone else might tackle this.

1 Like

Would saving off a copy of the RT work? Either save the original RT at the start, or save at intervals, and paint that saved RT image back into the current RT result to erase, revealing the ‘saved’ pixels?

1 Like

Saving a copy of the current version sounds like a good way to make an undo button too! That’s a great start. And if it was a normal canvas it would be the perfect erase.

On the model I have it so you can update a big chunk of the primary, secondary or tertiary color, like a paint bucket tool. So maybe everytime you do it saves a version of that base material…then make that the color of the brush tool, THEN maybe make the brush be in world space instead of a normal texture coordinate material? And then you can try to make a brush’s alpha just the normal brush with size and shape?

I’ll try it out and let you guys know how it goes! Thank you @Kproudfoot That is such a great starting point!

Okay, an update for @DrewADesign

I am kind of dumb sometimes haha, and didn’t really understand what a RenderTarget was. It’s just a texture 2D So this is what you can do.

Make a second RenderTarget that is an alpha for a lerp, and then when you get your parameters from your brush make sure you’re saving two brush materials, one will just always either black or white in color. If you’re erasing you’re adding white, if you’re adding color you’re adding black. Otherwise the location and shape of the brush should be the same.

I am making a second brush right now, and haven’t tested it more. But I’m thinking that this will be a simple solution for an eraser.

Ah yeah that makes sense!

1 Like