Foliage instance position in Material editor

Hi there :slight_smile:

I want to obtain the global position of an instanced mesh from a Procedural Foliage Volume in the material editor.
This is already possible with a hand dropped mesh using the “ObjectPosition” node, but not with a PFV as it returns the PFV’s position instead of the mesh’s.

Question is: How can I achieve this, or perhaps cheat it around, or even just know if it’ll be implemented some day.

Thanks!

There already are many similar threads about this since UE4.9 in 2015 but none seem to get any love or attention :’(
If you’re interested in this, you may follow these other threads as well as upvote (the UP arrow to the left of the question).

To give an idea, I’m trying to achieve this effect on all instances of a PFV. Basically im trying to cheat lighting depth on tree leaves using the distance of the texel from the mesh’s origin.You can notice it works well on hand placed meshes but not on the PFVs placed behind.

If I scale up the values in my SphereMask node it gives this: (the trees way behind are lods with a different material)

And this the basic node operations to get the distance

Try passing object position through custom UVs. It should return per-instance position that way If i’m not mistaken.

It works! Thanks!
Unfortunately not for ObjectBounds neither ObjectOrientation, though. :frowning:

For Object Orientation is just a vector, that is constant through the whole instance. You can just transform (1,0,0) from local to world to get Instance X axis in world space. In case of object bound, it is not really applicable to individual instances.

I love you Deathrey!

I came across this problem recently and didn’t quite get what you meant because UVs are only 2-dimensinal, so I only had the X and Y position. But after I set the “Num custom UVs” to 2 (in the Material settings) I was able to get the Z axis as well.

1 Like

You can use vertex interpolator material expression in newer versions.

1 Like

Oh you’re right. I never heard of that node before. This way it’s cheaper and no UVs will be harmed during the process, thx :wink:

I’ll leave a txt file for easier copy-paste
[link text][2]

Edit: Just to make clear how the setup would be for the sphere mask

265255-instancespheremask.jpg

5 Likes

Best!