Drawing in VR

Draw on 2d surface



In Project setting, tick support UV from hit result, restart now
image.png

Create a Material named MTl_DrawingSurface
Open it, add Parameter 2d on emissive color, rename as DrawTexture
image.png

Create another Material, name as Mtl_DrawingBrush

Add Vector Parameter node, rename as Color
Attach to Emissive, change to red color
image.png


Create Drawing Surface BP:


Create BP class Actor, name as DrawingSurface
Open it, Add component Plane, rotate 90 degree and scale up, change material to Drawingsurface
image.png

Go to Construction Script, create as follow (rename last variable as Render Target)

image.png
change clear color to white (as a default color before drawing anything on surface)
image.png

Connect sequence 1 as follow
for create drawing:
image.png
For Overwrite created material, see the changed made on plane:
image.png
Overall:
image.png

Create Material instance nodes to 3rd sequence output for Drawing Brush:


image.png

Increase width and height of render target node to 1024
image.png

Create a new function called DrawBrush, create input vairlables Size (how big the brush) and Location (where to draw on render target)

image.png

Create nodes as follow (to allocation screen position with the brush):
image.png
Split struct pin on the “-” node, as well as Draw material Screen Size, end draw canvas to render target as follow:
image.png

Drag the BP plane in the scene

Call the Draw function in VR Pawn:


Open in VR pawn, Get InputAction TriggerRight and Event Tick
Remark: type To vector float for node input from Multiphy

image.png


Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.