Drawing on a material

Hello. I want to draw to a material a simple circle based on the position of my laser pointer.
What I tried to do is get the Location of the Impact Point of the laser to the mesh and send that to the material.

In the material I just calculate the distance between the Impact point and the Pixel Position in World space.

I don’t seem to get the drawing on the left down side. Its rendering ok on the top right side.

I need the 3D position because I Want to draw on 3d objects not just planes.


Hey there @bogdanus! I’m no materials master, but I’ve brought some resources that might help out!

Disclaimer: One or more of these links are unaffiliated with Epic Games. Epic Games is not liable for anything that may occur outside of this Unreal Engine domain. Please exercise your best judgment when following links outside of the forums.

SKM:

and one for static meshes:

1 Like

In general, you don’t “draw into materials” in Unreal.

For the simple case of “show a laser pointer dot,” then a Decal Actor will work just fine. Figure out where the impact point is, and what the impact orientation is, and place a Decal Actor there. Make the Decal be the laser pointer image you want. (You may have to rotate the actor 90 degrees if I remember correctly, because “forward” is X, but “impact normal” is Z, IIRC.)

If you need procedurally generated texture content, then usually the best option is to create a RenderTarget asset, and then tie that to a Texture, that you bind to a Material (or Material Instance.) Then use a Camera to render to that RenderTarget whatever sub-scene you need rendered. (Which can include UMG widgets using a 3D Widget actor.)

1 Like

Thanks for the answers. Really useful information.