# WPO Lookat

**URL:** <https://forums.unrealengine.com/t/wpo-lookat/1871465>\
**Category:** Rendering\
**Tags:** unreal-engine, question\
**Created:** [May 24, 2024, 8:29pm UTC](https://forums.unrealengine.com/t/wpo-lookat/1871465 "2024-05-24T20:29:07Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![YanVerde](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/yanverde/32/465543_2.png) [@YanVerde](https://forums.unrealengine.com/u/YanVerde)\
**Post date:** [May 24, 2024, 8:29pm UTC](https://forums.unrealengine.com/t/wpo-lookat/1871465/1 "2024-05-24T20:29:07Z")

</div>

Hi,  
I’m looking into a way to make a lookat in material with normal recalculation ideally.  
Would like to feed in the lookat vector, pivot point and maybe the mesh forward.

Anyone have done something like this?

Thanks!

---

<div class="post-metadata">

**Author:** ![jahjah771](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jahjah771](https://forums.unrealengine.com/u/jahjah771)\
**Post date:** [May 25, 2024, 7:51am UTC](https://forums.unrealengine.com/t/wpo-lookat/1871465/2 "2024-05-25T07:51:06Z")

</div>

Hi, Check Rotate vector node and what is inside it. Fix rotate about axis normals node can give you a hint how to recalculate normals.

---

<div class="post-metadata">

**Author:** ![YanVerde](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/yanverde/32/465543_2.png) [@YanVerde](https://forums.unrealengine.com/u/YanVerde)\
**Post date:** [May 27, 2024, 2:16pm UTC](https://forums.unrealengine.com/t/wpo-lookat/1871465/3 "2024-05-27T14:16:31Z")

</div>

Thanks for the pointer, so now I have this which “works”, but the mesh gets kinda squished depending on the look at vector. Goes as far as being completely flat if I have a negative value in the lookat. Any clue more clue?

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/7/2/972f7df30456531d39cdcc589dbd1e6ddec486b3.png)

---

<div class="post-metadata">

**Author:** ![jahjah771](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jahjah771](https://forums.unrealengine.com/u/jahjah771)\
**Post date:** [May 27, 2024, 6:34pm UTC](https://forums.unrealengine.com/t/wpo-lookat/1871465/4 "2024-05-27T18:34:00Z")

</div>

Solved it in a different way, but it works.

 ![Rotate_01](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/d/5/ad5898b1c7b582f064b299115efccf3677642545.png)  
 ![Rotate_02](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/a/8/0a8e1e9a755dd0b02c7f0576c1b747448aa3f256.png)

---

<div class="post-metadata">

**Author:** ![YanVerde](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/yanverde/32/465543_2.png) [@YanVerde](https://forums.unrealengine.com/u/YanVerde)\
**Post date:** [May 28, 2024, 1:13pm UTC](https://forums.unrealengine.com/t/wpo-lookat/1871465/5 "2024-05-28T13:13:16Z")

</div>

ho is there a way to do the blueprint part in the material instead?  
I am going to have thousands of instances using this as HISM, or folliage.  
The target position will be passed as a material parameter collection.

Thanks! 🙂

---

<div class="post-metadata">

**Author:** ![jahjah771](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jahjah771](https://forums.unrealengine.com/u/jahjah771)\
**Post date:** [May 28, 2024, 2:08pm UTC](https://forums.unrealengine.com/t/wpo-lookat/1871465/6 "2024-05-28T14:08:56Z")

</div>

Idk, if unreal pass rotation or quat to shader , than you can potentially retrieve this data in material with custom node.  
You can pass rotation as ISM custom data floats. You can pack rotation as Quaternion (only 4 floats, instead of 3 vectors/9 floats) and unpack it shader.

---

<div class="post-metadata">

**Author:** ![YanVerde](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/yanverde/32/465543_2.png) [@YanVerde](https://forums.unrealengine.com/u/YanVerde)\
**Post date:** [May 30, 2024, 3:53pm UTC](https://forums.unrealengine.com/t/wpo-lookat/1871465/7 "2024-05-30T15:53:15Z")

</div>

I found a way to convert the FindLookAtRotation in HLSL and have a 100% shader based look at (except feeding the look at position)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/c/7/ec7bbac7411d49e3c26d87e876e1534ee9b42282.png)

LookAt Code:

```auto
X = normalize(end-start);
float3 upvector = X.z < 0.9999 ? float3(0,0,1) : float3(1,0,0);
Y = normalize(cross(upvector, X));
Z = cross(X, Y);

return 0;

```

This way you could have a material parameter collection for the target position and update hundreds of instances at almost no tick cost.

---

<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:** [May 30, 2024, 10:35pm UTC](https://forums.unrealengine.com/t/wpo-lookat/1871465/9 "2024-05-30T22:35:35Z")

</div>

I love this place, thanks for sharing.

---

<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:** [June 29, 2024, 10:36pm UTC](https://forums.unrealengine.com/t/wpo-lookat/1871465/10 "2024-06-29T22:36:25Z")

</div>

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