# Ray Casting a Texture in Material Editor

**URL:** <https://forums.unrealengine.com/t/ray-casting-a-texture-in-material-editor/2364991>\
**Category:** World Creation\
**Tags:** unreal-engine, question\
**Created:** [February 28, 2025, 7:25pm UTC](https://forums.unrealengine.com/t/ray-casting-a-texture-in-material-editor/2364991 "2025-02-28T19:25:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Evohc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Evohc](https://forums.unrealengine.com/u/Evohc)\
**Post date:** [February 28, 2025, 7:25pm UTC](https://forums.unrealengine.com/t/ray-casting-a-texture-in-material-editor/2364991/1 "2025-02-28T19:25:58Z")

</div>

I am trying to figure out if I can basically use a float3 vector to control the projection angle of a world aligned texture mask. The main goal I had in mind was to make a mask to lerp in moss onto certain objects in the scene, like trees and rocks, and make the moss grow from say the north-west side of the objects, with the opposite side of the objects not having any moss. I thought for sure this would be possible, but all of my attempts at doing it myself, or finding a tutorial online have failed. Any help with this would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![Frenetic](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/frenetic/32/1142542_2.png) [@Frenetic](https://forums.unrealengine.com/u/Frenetic)\
**Post date:** [February 28, 2025, 7:36pm UTC](https://forums.unrealengine.com/t/ray-casting-a-texture-in-material-editor/2364991/2 "2025-02-28T19:36:50Z")

</div>

Use the vector as the alpha for a LERP to blend between your base-texture-set and the moss-texture.

Triplanar, XY-projection, UVs don’t matter here as you are not mixing the UVs but the textures.

---

<div class="post-metadata">

**Author:** ![Evohc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Evohc](https://forums.unrealengine.com/u/Evohc)\
**Post date:** [March 3, 2025, 2:36pm UTC](https://forums.unrealengine.com/t/ray-casting-a-texture-in-material-editor/2364991/3 "2025-03-03T14:36:32Z")

</div>

Sorry for the late reply to this, but I think I need to re-word my question a little. Firstly, thank you @Frenetic for attempting to answer my question, but this wasn’t quite what I was trying to explain.

To re-word this, many of you are probably familiar with the idea of using a Material Collection to globally control wind direction in a scene via a float3 parameter. Well, I’m basically looking for the same thing, only it controls the direction of a texture mask being projected at any object with this logic within it’s master material. For example, I could have the texture only showing on the north-west side of an object, with maybe a 20 degree downward angle as well.

I hope this makes it more clear what I am looking for, if it’s possible to do in the first place. Thanks again.

---

<div class="post-metadata">

**Author:** ![Frenetic](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/frenetic/32/1142542_2.png) [@Frenetic](https://forums.unrealengine.com/u/Frenetic)\
**Post date:** [March 3, 2025, 3:07pm UTC](https://forums.unrealengine.com/t/ray-casting-a-texture-in-material-editor/2364991/4 "2025-03-03T15:07:41Z")

</div>

Something like this? +X → Forward in Unreal, so assume that is ‘north’.

> **Mask**
>
> ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/0/6/60643ddd328737cb393bebd08d334f77a5844d65.jpeg)

> **Mix**
>
> ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/0/d/30d2a08b0f86bbb5615ee414e26bd3c9bb2da67a.jpeg)

There is no reason you cannot use the MPC or whatever to store/set that vector you want to blend across, it’s just 4 numbers in the end. You could also use a custom primitive data element when spawning the meshes and add some variability that way.

---

<div class="post-metadata">

**Author:** ![Evohc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Evohc](https://forums.unrealengine.com/u/Evohc)\
**Post date:** [March 3, 2025, 3:54pm UTC](https://forums.unrealengine.com/t/ray-casting-a-texture-in-material-editor/2364991/5 "2025-03-03T15:54:43Z")

</div>

Thank you so much @Frenetic, this gets me very close to what I’m after. I just need to work out how to use the MPC instead of the VertexNormalWS node. Then it will be just what I’m after.

---

<div class="post-metadata">

**Author:** ![Evohc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Evohc](https://forums.unrealengine.com/u/Evohc)\
**Post date:** [March 4, 2025, 2:48pm UTC](https://forums.unrealengine.com/t/ray-casting-a-texture-in-material-editor/2364991/6 "2025-03-04T14:48:42Z")

</div>

Ok, so using a “HeightLerp” node, I could figure out how to connect my “Moss\_Direction” MPC. However, as viewable in the image below, I was able to make it work perfectly to what I was after using the “WorldAlignedBlend” node. Thanks again for the help!

 ![UE5-MossDirection01](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/b/d/9bdc6b5fc21fd63dba7ad303608b3924286a957f.jpeg)

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [April 3, 2025, 2:49pm UTC](https://forums.unrealengine.com/t/ray-casting-a-texture-in-material-editor/2364991/7 "2025-04-03T14:49:39Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
