project line trace hit to canvas

Hi,

I use a render texture and a canvas to draw on an object (using this example : CanvasRenderTarget2D Exemple - Rendering - Unreal Engine Forums). Basically, I want to modify the texture of a whiteboard using a pen.
Interaction works fine with mouse coordinates, but as I’m using the project in VR, that’s not useful…

Is there a way to convert a linetrace hit location (3d vector) into a 2D canvas coordinate ?
My pen traces a line onto the board, and I want to convert this hit location to modify the 2D texture of the canvas.
Any idea there ?
Thanks a lot !

Btw is there a way to let the drawing peristent for a while on the render texture ?

Yes there is a way that has been added very recently in UE4 4.13, it’s called Drawing to render target.
They made an entire Twitch Live-stream about it that you can watch: Blueprint Drawing to Render Targets Overview | Live Training | Unreal Engine - YouTube

Hello Teapot Creation

I saw that you were asking how to convert a world location to screen location. I have provide a link to the Blueprint API for a node that does just that as well as a couple others that have similar functions. I hope that this information helps.

World to screen:

Link: Convert World Location To Screen Location | Unreal Engine Documentation

Screen to world:
Link: Convert Screen Location To World Space | Unreal Engine Documentation

Mouse to world:

Link: Convert Mouse Location To World Space | Unreal Engine Documentation

Make it a great day

Thanks a lot, looks like something useful, I’ll check that :slight_smile:

Thank you, I’ll study all that !

Alright I’ve tested with the “World to screen” node. It should work, however the value changes as I rotate the HMD.
Here is my RenderTexture blueprint :

The HitPos variable is the hit point of the trace frome the pen forward vector on the canvas.
Is there a way to make it independant from the player controller, as it seems to interfer with the HMD orientation ?

Absolutely awesome, thanks for that link !