# 2D Texture Array with Triplanar Projection

**URL:** <https://forums.unrealengine.com/t/2d-texture-array-with-triplanar-projection/1187009>\
**Category:** World Creation\
**Tags:** unreal-engine, question\
**Created:** [June 2, 2023, 6:40pm UTC](https://forums.unrealengine.com/t/2d-texture-array-with-triplanar-projection/1187009 "2023-06-02T18:40:55Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hipshootah](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hipshootah/32/1201114_2.png) [@Hipshootah](https://forums.unrealengine.com/u/Hipshootah)\
**Post date:** [June 2, 2023, 6:40pm UTC](https://forums.unrealengine.com/t/2d-texture-array-with-triplanar-projection/1187009/1 "2023-06-02T18:40:55Z")

</div>

Hello!

I am stuck on an issue with using a 2D texture array with triplanar projection. The issue comes in with the inputs that a texture 2D needs versus a texture 2d array. Traditional triplanar relies on using 2D textures for each axis (X, Y, and Z) separately, and with our 2D texture array we use Z to index the sample. Is there anyway I can get this to work?

According to research, I need to use the index of the array texture to retrieve the appropriate texture data for each axis during the projection calculation.

Here is what I have so far:

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/5/a/75a4066d61fb6ba7886ec4222660e949b9a1e50f.jpeg "Unreal 5.2 - Issue with Triplanar Projection using 2D Texture Arrays") ](https://www.youtube.com/watch?v=7qU8YDQO3NQ)

---

<div class="post-metadata">

**Author:** ![Hipshootah](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hipshootah/32/1201114_2.png) [@Hipshootah](https://forums.unrealengine.com/u/Hipshootah)\
**Post date:** [June 5, 2023, 7:21pm UTC](https://forums.unrealengine.com/t/2d-texture-array-with-triplanar-projection/1187009/2 "2023-06-05T19:21:27Z")

</div>

Perhaps I should state the intention of this conversion. I am setting up a master material with multiple layers. If I am not mistaken, we can use 2d texture arrays to store textures more efficiently as opposed to simply using the textures (Albedo, Normal, etc.) per layer. I have managed to convert Cellbombing to use the 2D Texture Array, though it seems odd numbered samples have an offset for some reason.

---

<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:** [June 5, 2023, 7:27pm UTC](https://forums.unrealengine.com/t/2d-texture-array-with-triplanar-projection/1187009/3 "2023-06-05T19:27:16Z")

</div>

Hi Hipshootah,

There’s a more efficent way to do tri-planar with only one texture sample per texture - that may actually just fix your issue, check out:

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/a/c/cacc9758a84a4bca80bb4cb26b3814abea5b3b05.jpeg "Single Sample Seamless Tri-Planar Mapping (UE5)") ](https://www.youtube.com/watch?v=dFApswlwsRc)

---

<div class="post-metadata">

**Author:** ![Hipshootah](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hipshootah/32/1201114_2.png) [@Hipshootah](https://forums.unrealengine.com/u/Hipshootah)\
**Post date:** [June 5, 2023, 7:39pm UTC](https://forums.unrealengine.com/t/2d-texture-array-with-triplanar-projection/1187009/4 "2023-06-05T19:39:45Z")

</div>

So I am over thinking it an just remake the dang material 🤣 I remember watching this video a few weeks ago, but I am returning to landscapes this week and going over what I have done so far. I think I get it now haha

---

<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:** [June 5, 2023, 7:42pm UTC](https://forums.unrealengine.com/t/2d-texture-array-with-triplanar-projection/1187009/5 "2023-06-05T19:42:09Z")

</div>

You could well be onto something with the TextureArrays though - I haven’t played with them at all…

---

<div class="post-metadata">

**Author:** ![Hipshootah](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hipshootah/32/1201114_2.png) [@Hipshootah](https://forums.unrealengine.com/u/Hipshootah)\
**Post date:** [June 7, 2023, 3:29pm UTC](https://forums.unrealengine.com/t/2d-texture-array-with-triplanar-projection/1187009/6 "2023-06-07T15:29:38Z")

</div>

Okay, I see what you are saying for sure. Had to keep watching the video to digest everything haha. We can use a single sample for the whole thing. You say “sample a runtime virtual texture” as opposed to using just a scalar parameter to set the index?

---

<div class="post-metadata">

**Author:** ![Hipshootah](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hipshootah/32/1201114_2.png) [@Hipshootah](https://forums.unrealengine.com/u/Hipshootah)\
**Post date:** [June 9, 2023, 6:11pm UTC](https://forums.unrealengine.com/t/2d-texture-array-with-triplanar-projection/1187009/7 "2023-06-09T18:11:28Z")

</div>

Okay so I updated the material to use the single sample method you provided. Now I am having trouble with the output of texture 2d array parameter, which is translating to the same issue of missing Z data I believe 🥲

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/1/1/a11c756057cd55116104b73f966e41d2fb13f940.jpeg "Part One") ](https://www.youtube.com/watch?v=qBl9W08xyBg)

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/0/f/50fb6160b3820ebd52a0804aaa9ebe4e12e2b43e.jpeg "Part Two") ](https://www.youtube.com/watch?v=xQPyxZ3Y0Pk)

Going to keep playing with it and researching, I will post anymore updates I find.

---

<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:** [June 9, 2023, 6:56pm UTC](https://forums.unrealengine.com/t/2d-texture-array-with-triplanar-projection/1187009/8 "2023-06-09T18:56:35Z")

</div>

Hi Hipshootah,

It looks like your axis to vector part is not quite right:

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/e/d/1eda7da0503abea24342434518960d9decbd71a7.jpeg)

---

<div class="post-metadata">

**Author:** ![Hipshootah](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hipshootah/32/1201114_2.png) [@Hipshootah](https://forums.unrealengine.com/u/Hipshootah)\
**Post date:** [June 9, 2023, 9:53pm UTC](https://forums.unrealengine.com/t/2d-texture-array-with-triplanar-projection/1187009/9 "2023-06-09T21:53:30Z")

</div>

I tried opening the image you posted in a separate tab with no luck, it is super blurry 🤣 I will go back and rewatch the video now that my head is clear. I did manage to figure it out a solution to my issue though, which I will post below!

Have to make 3 edits because my grammar is wack sometimes.

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/b/e/7be3f31b2abc416ce5fddf5ea5171e492fffc37a.jpeg "Part Three - Solution") ](https://www.youtube.com/watch?v=N6hpbGA-Nig)

I just want to say thanks again for your work, you really helped me work through this. Cheers!

---

<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:** [June 9, 2023, 10:29pm UTC](https://forums.unrealengine.com/t/2d-texture-array-with-triplanar-projection/1187009/10 "2023-06-09T22:29:36Z")

</div>

No problem!

Yeah I snapped that from the video so double the amount of blur… I couldn’t really see your one in detail either, but was going by the colors of the nodes. It looks like you’ve put the first inputs in the correct places for the Additions (also, it looks like your 3rd channel is an add rather than a multiply, could just be the blur though) but wiring them into the make float3 the wrong way around:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/e/8/5e8b5d0be9e2b50d838e348ae1a29e1798a1ce8d.jpeg)

My version is a bit of a mess, but at least it’s not blurry:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/1/1/b11c782a0e66e6361b7dfcc02e778d3a8ee59501.png)

---

<div class="post-metadata">

**Author:** ![Hipshootah](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hipshootah/32/1201114_2.png) [@Hipshootah](https://forums.unrealengine.com/u/Hipshootah)\
**Post date:** [June 9, 2023, 10:31pm UTC](https://forums.unrealengine.com/t/2d-texture-array-with-triplanar-projection/1187009/11 "2023-06-09T22:31:29Z")

</div>

You are awesome, thank you for your time and explanations! I will check it out.

---

<div class="post-metadata">

**Author:** ![Hipshootah](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hipshootah/32/1201114_2.png) [@Hipshootah](https://forums.unrealengine.com/u/Hipshootah)\
**Post date:** [June 10, 2023, 5:02pm UTC](https://forums.unrealengine.com/t/2d-texture-array-with-triplanar-projection/1187009/12 "2023-06-10T17:02:30Z")

</div>

I have no idea what is going on now lmao

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/b/6/ab663f8734e45b960c179ec956acd48244609a4c.jpeg "Triplanar - What am I doing wrong?") ](https://www.youtube.com/watch?v=_XieCNlz_og)

---

<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:** [June 10, 2023, 8:23pm UTC](https://forums.unrealengine.com/t/2d-texture-array-with-triplanar-projection/1187009/13 "2023-06-10T20:23:02Z")

</div>

Try swapping these:

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

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/b/7/8b73bad639166b412dd38e9a63941dac878bc7f4.jpeg)

---

<div class="post-metadata">

**Author:** ![Hipshootah](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hipshootah/32/1201114_2.png) [@Hipshootah](https://forums.unrealengine.com/u/Hipshootah)\
**Post date:** [June 11, 2023, 4:31pm UTC](https://forums.unrealengine.com/t/2d-texture-array-with-triplanar-projection/1187009/15 "2023-06-11T16:31:58Z")

</div>

Okay after some review, I discovered my TransformVector was inverted. Correct solution:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/4/4/644831636730d1c6d64125f0a164a42c017abd1f.png)

Fixed the weird shadow produced from the normal map. Cheers!

---

<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:** [July 11, 2023, 4:32pm UTC](https://forums.unrealengine.com/t/2d-texture-array-with-triplanar-projection/1187009/16 "2023-07-11T16:32:56Z")

</div>

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