- Home /
VR Drawing
So I am planning on adding a VR drawing feature to my project, but there are a few aspects that I am not sure how to tackle.
So I would like to do a Rec Room style marker that you hold and when the tip touches a surface, it leaves a mark behind, and there is also going to be an easel that the user can draw on, and when saved/applied, it can be used as a texture for other objects.
I understand most of the functions of setting it up, and saving the texture, but the two parts I have no idea about are: What is the best method to use to physically draw lines on things when the marker contacts them and How to save the PNG texture with a transparent background (the parts that are not drawn on remain invisible)
My current idea would be to just instantiate thousands of small colored planes that would then be captured by an ortho camera as a texture, but that would be messy and again, I'm not sure how to get an Alpha background out of that.
If I get it all figured out, I'll be happy to make a quick video tutorial for any future devs! Cheers.
Answer by AaronXRDev · Jul 23, 2019 at 08:49 PM
One of the first things I would look at is using a mesh collider on your canvas and then using RaycastHit.textureCoord to determine the pixel location on the canvas that you hit.
You could then apply your colours to a transparent texture to display it. Finally you could use ImageConversion.EncodeToPNG to export that texture as a transparent PNG.
Hopefully this gets you going in the right direction - I'd love to see what you come up with!