#Need help creating a in-game drawing canvas

21 messages · Page 1 of 1 (latest)

winged turret
#

Hey,
I'm getting back into Godot and I'm working on the demo of my project. It is largely based around having a drawing canvas used in-game so that is most of my concern. The problem is, I have no idea how to implement that with Godot. Does anybody have some experience with that or can point me to a useful resource about this topic?

Thank you!

vague oxide
#

You mean like using a pen or brush to draw lines on a surface?

winged turret
#

yes exactly. Possibly I want to extend that to have a few different brushes. Basically a small in-game digital art software

vague oxide
#

If your game is in 2D you can use the Line2D node
If you're drawing in 2D but in a 3D world, you can use Line2D and a subviewport
If you're drawing in 3D... afaik there is no easy way to do it, there are a few Line3D plugins online but I've never used them, or you can build a mesh yourself but that requires knowledge on how meshes are built and it's a pain in the ass to do

winged turret
#

It's going to be in 2D and be seperate from the actual game world. Thanks for your suggestion! I have used Line2D to but I'm unsure if performance wise this would be a good solution, since a new line2d node will be created everytime the pen/mouse button is lifted.

vague oxide
#

There is probably a way to do it with shaders and a single quad (you send the points and lines to the shader and it renders accordingly) but it sounds like a pain as well
But yeah depending on the number of lines you allow, performance will definitely be an issue, especially if your brush texture has transparency

winged turret
#

Uff I have no idea about shaders, but I will look into it. Hmm this will definetly be a big problem for me. There is also the draw functions from CanvasLayer, haven't tested that yet. Then there is set_pixel on an ImageTexture object that may work

golden nova
#

why not write to a texture and display the texture?

vague oxide
golden nova
#

unless you need it to be vector based

winged turret
#

So create a sprite2D with an empty canvas texture (white canvas), create the image texture than draw in the imagetexture and update the sprite texture with the new one?

golden nova
#

well you can just use the same texture

#

but yes

heady smelt
#

Anw, i have a question, how to showing variable real time in debugging?. So that i can know it's work or not

golden nova
#

should make your own topic or ask in #❓┃quick-help

#

but you can use print statements, or the Evaluator under Debugger

heady smelt
#

ohh i see. Sorry, just know im still beginner. "Evaluator"? where?

golden nova
#

so at the bottom where it says Output, Debugger etc click Debugger

#

then at the top of the window that appears click Evaluator, 3rd from the left

heady smelt
#

i found it, then how to use?

golden nova
#

I've never used it but I guess type in the variable you want to watch and click Add