Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Foliage instance position in Material editor

Hi there :)

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.


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).

https://answers.unrealengine.com/questions/384539/get-foliage-instance-mesh-position.html https://answers.unrealengine.com/questions/192240/instance-foliage-mesh-position.html https://answers.unrealengine.com/questions/449701/foliage-instance-position.html https://answers.unrealengine.com/questions/321400/how-can-i-get-the-properties-of-instance-in-foliag.html

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.alt text

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

And this the basic node operations to get the distance alt text

Product Version: UE 4.12
more ▼

asked Sep 08 '16 at 10:42 AM in Rendering

avatar image

89 4 23 15

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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

more ▼

answered Sep 08 '16 at 03:37 PM

avatar image

7.9k 130 31 293

avatar image RVillani Sep 16 '17 at 11:20 AM

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

avatar image Deathrey Sep 16 '17 at 05:41 PM

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.

avatar image gstyczen Jan 06 '18 at 04:08 AM

I love you Deathrey!

avatar image BOBtheROSS Jan 05 '19 at 05:06 PM

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. I made a screenshot for dummies like me ^^

avatar image Deathrey Jan 05 '19 at 06:54 PM

You can use vertex interpolator material expression in newer versions.

avatar image BOBtheROSS Jan 13 '19 at 03:38 PM

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 ;) alt text I'll leave a txt file for easier copy-paste link text

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question