# Getting an average color from a Texture Sample

**URL:** <https://forums.unrealengine.com/t/getting-an-average-color-from-a-texture-sample/453836>\
**Category:** Rendering\
**Tags:** unreal-engine, nodes, question\
**Created:** [August 14, 2019, 9:54am UTC](https://forums.unrealengine.com/t/getting-an-average-color-from-a-texture-sample/453836 "2019-08-14T09:54:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ElKaWeh](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ElKaWeh](https://forums.unrealengine.com/u/ElKaWeh)\
**Post date:** [August 14, 2019, 9:54am UTC](https://forums.unrealengine.com/t/getting-an-average-color-from-a-texture-sample/453836/1 "2019-08-14T09:54:56Z")

</div>

Hey there,

I have a problem that may sound simple, but I really struggle to find a solution for this.

So basically I have a texture and want to get rid of it’s structure on distance, while still keeping the average color, with a distance blend.

 ![284985-ue-answer-hub.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/a/e/aae5648e95fa50738adbd6b3c30c8a1339635811.png)

I’ve had multiple ideas how I could achieve this:

First I hoped there may be just a node, that extracts the average color for me, but this doesn’t seem to be the case.  
Then I wanted to blur it, but that doesn’t seem to work that easy as well.

So the plan I’m now following is to tile the texture by a very high value (like 100) until there is no visible structure left.  
Like this:

 ![284986-ue-answer-hub-2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/9/a/39a4d2645368870d34a26454deefc2b1d0f0231b.png)

But how can I put a texture coordinate node _behind_ a texture sample?

I’ve tried to do it like this, but you see whats the problem here:

 ![284987-ue-answer-hub-3.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/c/2/5c2400ebcc7f5f80cfd476f4f45f70129a219649.png)

Is there any way to do that?  
Of course I could just import the Texture Sample twice and put two different texture coordinate nodes in front of them. but that’s not the way I would prefer, because I later want to instance the material and the texture is supposed to be exchangeable. Always having to replace two identical textures wouldn’t be very nice.

Or does anyone of you have a different Idea how I could solve my problem, instead of tiling the texture?

Thanks in advance,

ElKaWeh

---

<div class="post-metadata">

**Author:** ![Deathrey](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Deathrey](https://forums.unrealengine.com/u/Deathrey)\
**Post date:** [August 14, 2019, 10:12am UTC](https://forums.unrealengine.com/t/getting-an-average-color-from-a-texture-sample/453836/2 "2019-08-14T10:12:10Z")

</div>

There isn’t such node and doing it in material is impractical. You would need to calculate the average color elsewhere and pass it as a parameter to the mat.  
The closest you can get is by sampling all texels of texture’s lowest mip and averaging their values.

---

<div class="post-metadata">

**Author:** ![ElKaWeh](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ElKaWeh](https://forums.unrealengine.com/u/ElKaWeh)\
**Post date:** [August 14, 2019, 10:44am UTC](https://forums.unrealengine.com/t/getting-an-average-color-from-a-texture-sample/453836/3 "2019-08-14T10:44:32Z")

</div>

Ok, I have a solution.  
In case anybody else is wondering, here it is:

So instead of importing the texture as a texture sample, I imported it as a parameter texture object now, and fed it into 2 different texture sample nodes. This way I later just have to replace one texture in the instance, but still can apply 2 different texture coordinates.

like this:

 ![284988-ue-answer-hub-4.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/b/6/8b6c4d6585059750b0f054b4e1c7dceb3b97ba2b.png)

---

<div class="post-metadata">

**Author:** ![GehtSieGarNixAn](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/gehtsiegarnixan/32/611835_2.png) [@GehtSieGarNixAn](https://forums.unrealengine.com/u/GehtSieGarNixAn)\
**Post date:** [May 24, 2022, 6:07am UTC](https://forums.unrealengine.com/t/getting-an-average-color-from-a-texture-sample/453836/4 "2022-05-24T06:07:57Z")

</div>

It’s not really an average then is it ? But scaling it down a bunch so the does effectively the same thing is pretty clever

---

<div class="post-metadata">

**Author:** ![WpWhite](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@WpWhite](https://forums.unrealengine.com/u/WpWhite)\
**Post date:** [February 28, 2024, 5:27am UTC](https://forums.unrealengine.com/t/getting-an-average-color-from-a-texture-sample/453836/5 "2024-02-28T05:27:23Z")

</div>

For folks looking at this later, you can also change the mip value to something really high to get the same effect. It should be more performant, I think?

---

<div class="post-metadata">

**Author:** ![EliasWick](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/eliaswick/32/1175208_2.png) [@EliasWick](https://forums.unrealengine.com/u/EliasWick)\
**Post date:** [February 28, 2024, 8:58am UTC](https://forums.unrealengine.com/t/getting-an-average-color-from-a-texture-sample/453836/6 "2024-02-28T08:58:43Z")

</div>

You are correct. Generally, exposing the MipMaps on the texture will allow you to enter a scalar / float value that do the exact same thing but be much more performant as no UV operation is required.
