# How do i keep my material from stretching when scaling the mesh its on?

**URL:** <https://forums.unrealengine.com/t/how-do-i-keep-my-material-from-stretching-when-scaling-the-mesh-its-on/2064307>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, editor, Rendering, question, Blueprint\
**Created:** [October 12, 2024, 2:03am UTC](https://forums.unrealengine.com/t/how-do-i-keep-my-material-from-stretching-when-scaling-the-mesh-its-on/2064307 "2024-10-12T02:03:44Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![SophiaWolfie](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sophiawolfie/32/1008648_2.png) [@SophiaWolfie](https://forums.unrealengine.com/u/SophiaWolfie)\
**Post date:** [October 12, 2024, 2:03am UTC](https://forums.unrealengine.com/t/how-do-i-keep-my-material-from-stretching-when-scaling-the-mesh-its-on/2064307/1 "2024-10-12T02:03:44Z")

</div>

This is a texture for a dialogue/comment bubble.  
i need to scale it sometimes because the comments sometimes are bigger.  
When i’m scaling it so the comments fit in, it stretches the outline and looks ugly:  
Is there a way around this?

---

<div class="post-metadata">

**Author:** ![SupportiveEntity](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SupportiveEntity](https://forums.unrealengine.com/u/SupportiveEntity)\
**Post date:** [October 12, 2024, 6:34am UTC](https://forums.unrealengine.com/t/how-do-i-keep-my-material-from-stretching-when-scaling-the-mesh-its-on/2064307/2 "2024-10-12T06:34:00Z")

</div>

Hey there @SophiaWolfie! Often this issue is common for UI elements where you want the edges to remain the same but the center to be able to be scaled without distortion. Generally you would use something known as 9-slicing to cut the UI element into 9 pieces and designate which dimensions can scale and which would need to remain the same.

However the utilities to make this are exclusively in the UI suite, and from the look of things you’re working with a 3D actor. I believe you can still use the UI 9 slice feature if you use a 3D UI widget instead of a plane.

**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.**

Resources for 9 slicing (or 3 slicing) in UE4/5:

> **[9-Slice control in UE4 – Indie Game Development in UE4](https://sgarces.com/?p=215)**

> **[UI Useful Materials | Community tutorial](https://dev.epicgames.com/community/learning/tutorials/6GjP/unreal-engine-ui-useful-materials#uvs-3slice)**
>
> A set of useful materials for UI artists/designers/engineers to utilize in their UMG specific needs

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/c/a/ecad6736dad9b18ff2bf79e35d7de86ed312f0f4.jpeg "HTF do I? Use the Image Widget in UMG") ](https://www.youtube.com/watch?v=nQWD6M6J7r8&t=74s)

---

<div class="post-metadata">

**Author:** ![SophiaWolfie](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sophiawolfie/32/1008648_2.png) [@SophiaWolfie](https://forums.unrealengine.com/u/SophiaWolfie)\
**Post date:** [October 12, 2024, 7:07am UTC](https://forums.unrealengine.com/t/how-do-i-keep-my-material-from-stretching-when-scaling-the-mesh-its-on/2064307/3 "2024-10-12T07:07:17Z")

</div>

Thanks. That seems to be the solution.  
So in theory all i have to do is to do something with this:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/d/8/fd8ef0f32240b47acc68dbd1ae7096aed74e2ce9.png)

Basically create a square mask and make sure the edges are world aligned? Maybe not world aligned? There must be something that keeps the image in the material the same scale, right?  
Interesting how the 3 slice can also be useful for many other cases like UI with patterns below text.

---

<div class="post-metadata">

**Author:** ![RecourseDesign](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/recoursedesign/32/1194503_2.png) [@RecourseDesign](https://forums.unrealengine.com/u/RecourseDesign)\
**Post date:** [October 12, 2024, 9:27am UTC](https://forums.unrealengine.com/t/how-do-i-keep-my-material-from-stretching-when-scaling-the-mesh-its-on/2064307/4 "2024-10-12T09:27:57Z")

</div>

Hi, here’s a simple 9-slice material - it’s not perfect by any means, but may be useful as an example. Scale only works 1.0 or greater

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/0/6/f06ae0cf59df603985fd61434212f3fc882b42e1.jpeg)

---

<div class="post-metadata">

**Author:** ![SophiaWolfie](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sophiawolfie/32/1008648_2.png) [@SophiaWolfie](https://forums.unrealengine.com/u/SophiaWolfie)\
**Post date:** [October 12, 2024, 10:21am UTC](https://forums.unrealengine.com/t/how-do-i-keep-my-material-from-stretching-when-scaling-the-mesh-its-on/2064307/5 "2024-10-12T10:21:31Z")

</div>

Awesome. Thanks so much.

I have it here:

---

<div class="post-metadata">

**Author:** ![SophiaWolfie](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sophiawolfie/32/1008648_2.png) [@SophiaWolfie](https://forums.unrealengine.com/u/SophiaWolfie)\
**Post date:** [October 12, 2024, 10:47am UTC](https://forums.unrealengine.com/t/how-do-i-keep-my-material-from-stretching-when-scaling-the-mesh-its-on/2064307/6 "2024-10-12T10:47:26Z")

</div>

I noticed it doesnt work properly in ISM. I assume because the object Scale doesn’t work for ISM? Idk exactly if thats the issue.

I made some searches looking for how to get ISM instance scale. Found another post where you show a solution, but you use instancebounds and i dont have this node in UE4:

> [@Calculating the screen size of a foliage instance using object bounds?](https://forums.unrealengine.com/t/calculating-the-screen-size-of-a-foliage-instance-using-object-bounds/1275886/13):
>
> None of the scale values reflect the instance either, the transform matrix is the same - almost back to square one. Even stranger is that it has stopped working in the ISMs and HISMs! (I’m sure I didn’t change the code either, but it does now act as I thought it has in the past at least) There’s something I saw in the UE code which seemed to get the InstanceManager and Instance Index and find the transform from there - I’ll take a look at that this evening… Otherwise - you could add UVs to th…

---

<div class="post-metadata">

**Author:** ![RecourseDesign](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/recoursedesign/32/1194503_2.png) [@RecourseDesign](https://forums.unrealengine.com/u/RecourseDesign)\
**Post date:** [October 12, 2024, 6:53pm UTC](https://forums.unrealengine.com/t/how-do-i-keep-my-material-from-stretching-when-scaling-the-mesh-its-on/2064307/7 "2024-10-12T18:53:58Z")

</div>

That should work with both ISMs and HISMs - just not with foliage. I wasn’t able to find a way to get the scale for foliage instances in 4.27.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/a/0/5a0b1df355537b0c223f538ecedf0795535e6824.jpeg)

---

<div class="post-metadata">

**Author:** ![SophiaWolfie](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sophiawolfie/32/1008648_2.png) [@SophiaWolfie](https://forums.unrealengine.com/u/SophiaWolfie)\
**Post date:** [October 12, 2024, 10:23pm UTC](https://forums.unrealengine.com/t/how-do-i-keep-my-material-from-stretching-when-scaling-the-mesh-its-on/2064307/8 "2024-10-12T22:23:49Z")

</div>

In the HISM and ISM that is returning the scale of the whole mesh, not the specific instances meshes  
I tried tweaking it around with what i saw from my searches.  
And I made it work with the Custom UV with some trial and error:  
However, the instance 0 always bugs, so I just scale it to 0, 0, 0 and dont use it.  
Other than this the alternative is to use Per Instance Custom Data Value, and send in the scale to the material that way.

---

<div class="post-metadata">

**Author:** ![RecourseDesign](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/recoursedesign/32/1194503_2.png) [@RecourseDesign](https://forums.unrealengine.com/u/RecourseDesign)\
**Post date:** [October 13, 2024, 1:02am UTC](https://forums.unrealengine.com/t/how-do-i-keep-my-material-from-stretching-when-scaling-the-mesh-its-on/2064307/9 "2024-10-13T01:02:41Z")

</div>

Oh, nice! I haven’t seen that approach before.

It looks the index 0 issue is from the rotation (Transforming to WorldSpace), rotate another index and it exhibits the same behavior.

You can fix that by changing the Transform going to the Debug Node to “Tangent Space-\>World Space” and add an “Abs” node:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/d/4/cd46e1855b7a24732647e302949a20e0205599e7.jpeg)

---

<div class="post-metadata">

**Author:** ![SophiaWolfie](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sophiawolfie/32/1008648_2.png) [@SophiaWolfie](https://forums.unrealengine.com/u/SophiaWolfie)\
**Post date:** [October 13, 2024, 1:17am UTC](https://forums.unrealengine.com/t/how-do-i-keep-my-material-from-stretching-when-scaling-the-mesh-its-on/2064307/10 "2024-10-13T01:17:57Z")

</div>

Thanks this completely fixes it 🙏🙏

---

<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:** [November 12, 2024, 1:18am UTC](https://forums.unrealengine.com/t/how-do-i-keep-my-material-from-stretching-when-scaling-the-mesh-its-on/2064307/11 "2024-11-12T01:18:13Z")

</div>

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