Getting an average color from a Texture Sample

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.

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:

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:

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,


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.

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:

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

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?

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.