# How can i lock my gradient on scaled meshes ?

**URL:** <https://forums.unrealengine.com/t/how-can-i-lock-my-gradient-on-scaled-meshes/486504>\
**Category:** Rendering\
**Tags:** resolution-scale, unreal-engine, question\
**Created:** [July 22, 2021, 11:55am UTC](https://forums.unrealengine.com/t/how-can-i-lock-my-gradient-on-scaled-meshes/486504 "2021-07-22T11:55:14Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![InkGear](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@InkGear](https://forums.unrealengine.com/u/InkGear)\
**Post date:** [July 22, 2021, 11:55am UTC](https://forums.unrealengine.com/t/how-can-i-lock-my-gradient-on-scaled-meshes/486504/1 "2021-07-22T11:55:14Z")

</div>

Hi first of all english is not native language.  
I would like my gradient stay always at the top of my cube.  
I don’t want him to be influenced by an enlargement, currently this my material.

 ![344687-sans-titre.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/3/b/73b7d2db5fb7d1177aae6ffb5f02ee570c723309.png)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [July 22, 2021, 12:56pm UTC](https://forums.unrealengine.com/t/how-can-i-lock-my-gradient-on-scaled-meshes/486504/2 "2021-07-22T12:56:29Z")

</div>

You can lock the gradient to the object:

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/5/9/159f04d7ebc25d0f6ac8f88a3fea24797fee3195.jpeg "Object Space Gradient in UE4") ](https://www.youtube.com/watch?v=4NqpGPjMi8I)

---

<div class="post-metadata">

**Author:** ![InkGear](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@InkGear](https://forums.unrealengine.com/u/InkGear)\
**Post date:** [July 22, 2021, 2:54pm UTC](https://forums.unrealengine.com/t/how-can-i-lock-my-gradient-on-scaled-meshes/486504/3 "2021-07-22T14:54:04Z")

</div>

Thanks you but I don’t know how can I apply this in my gradient

 ![344691-sans-titre.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/7/8/27851e25bad394941fc9798ef2b285ed542d3ed0.png)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [July 22, 2021, 5:30pm UTC](https://forums.unrealengine.com/t/how-can-i-lock-my-gradient-on-scaled-meshes/486504/4 "2021-07-22T17:30:00Z")

</div>

I haven’t watched the vid for a while, but he shows you how to apply a gradient to an object, and that gradient will scale with the object. That’s what you want, right?

---

<div class="post-metadata">

**Author:** ![InkGear](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@InkGear](https://forums.unrealengine.com/u/InkGear)\
**Post date:** [July 22, 2021, 9:10pm UTC](https://forums.unrealengine.com/t/how-can-i-lock-my-gradient-on-scaled-meshes/486504/5 "2021-07-22T21:10:49Z")

</div>

I hope this picture can explain what I want

 ![344709-sans-titre-1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/9/0/190ebfb93ce1ba9fa0502553a1c592a1a96bf43c.png)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [July 23, 2021, 7:05am UTC](https://forums.unrealengine.com/t/how-can-i-lock-my-gradient-on-scaled-meshes/486504/6 "2021-07-23T07:05:01Z")

</div>

Ok, so this isn’t a material problem, you just don’t want the top of the cube to get too big?

---

<div class="post-metadata">

**Author:** ![InkGear](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@InkGear](https://forums.unrealengine.com/u/InkGear)\
**Post date:** [July 23, 2021, 9:08am UTC](https://forums.unrealengine.com/t/how-can-i-lock-my-gradient-on-scaled-meshes/486504/7 "2021-07-23T09:08:07Z")

</div>

yes, I want an uniform gradient

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [July 23, 2021, 10:43am UTC](https://forums.unrealengine.com/t/how-can-i-lock-my-gradient-on-scaled-meshes/486504/8 "2021-07-23T10:43:54Z")

</div>

Then you just have to not scale the cube on that axis. Am I missing something here?

---

<div class="post-metadata">

**Author:** ![InkGear](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@InkGear](https://forums.unrealengine.com/u/InkGear)\
**Post date:** [July 23, 2021, 11:59am UTC](https://forums.unrealengine.com/t/how-can-i-lock-my-gradient-on-scaled-meshes/486504/9 "2021-07-23T11:59:31Z")

</div>

I want to keep the scale of my gradient when I change the scale of my cube

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [July 23, 2021, 12:06pm UTC](https://forums.unrealengine.com/t/how-can-i-lock-my-gradient-on-scaled-meshes/486504/10 "2021-07-23T12:06:20Z")

</div>

Ok, that’s a world aligned material, which is what you have.

---

<div class="post-metadata">

**Author:** ![InkGear](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@InkGear](https://forums.unrealengine.com/u/InkGear)\
**Post date:** [July 24, 2021, 11:26am UTC](https://forums.unrealengine.com/t/how-can-i-lock-my-gradient-on-scaled-meshes/486504/11 "2021-07-24T11:26:05Z")

</div>

How can I do that ?

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [July 24, 2021, 11:58am UTC](https://forums.unrealengine.com/t/how-can-i-lock-my-gradient-on-scaled-meshes/486504/12 "2021-07-24T11:58:07Z")

</div>

This is your basic world aligned material:

 ![344784-screenshot-2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/2/e/c2e60eb21a7d08a8a80a5c11bdf7ffa5f797327b.jpeg)

When you scale the object, nothing happens to the material:

![344785-ezgifcom-gif-maker.gif](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/8/1/f81c4658124408028b6afb92e498f2d8cfd2eb09.gif)

---

<div class="post-metadata">

**Author:** ![InkGear](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@InkGear](https://forums.unrealengine.com/u/InkGear)\
**Post date:** [July 24, 2021, 12:01pm UTC](https://forums.unrealengine.com/t/how-can-i-lock-my-gradient-on-scaled-meshes/486504/13 "2021-07-24T12:01:00Z")

</div>

Yes I know this node but it is only for a T2D texture. It’s not compatible with a linear gradient

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [July 24, 2021, 12:22pm UTC](https://forums.unrealengine.com/t/how-can-i-lock-my-gradient-on-scaled-meshes/486504/14 "2021-07-24T12:22:16Z")

</div>

Here’s one that works just for the Z faces:

 ![344786-screenshot-3.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/6/5/a6551fd2c6fd61e25edea0b58f78c88ffd714f19.jpeg)

![344787-ezgifcom-gif-maker1.gif](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/e/3/9e344028d71424b27693cd5c649e462cd7d0f7a8.gif)

If you want it to work on all faces, you need to write the other 2 sides. Don’t think you can do it with those world position functions.

---

<div class="post-metadata">

**Author:** ![InkGear](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@InkGear](https://forums.unrealengine.com/u/InkGear)\
**Post date:** [July 30, 2021, 4:53pm UTC](https://forums.unrealengine.com/t/how-can-i-lock-my-gradient-on-scaled-meshes/486504/15 "2021-07-30T16:53:25Z")

</div>

Thanks you a lot it’s working and how can i do this with a constant 3 vector ?

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [July 30, 2021, 4:56pm UTC](https://forums.unrealengine.com/t/how-can-i-lock-my-gradient-on-scaled-meshes/486504/16 "2021-07-30T16:56:41Z")

</div>

That I’m not sure of…
