No announcement yet.

Foliage bounding box per instanced mesh

  • Filter
  • Time
  • Show
Clear All
new posts

    Foliage bounding box per instanced mesh

    Hey there!

    Im making a wind shader for some tree meshes and Im using their bounding box to calculate a gradient mask in the Z-axis for bending the entire tree. Sadly though this doesnt work when I paint my trees as foliage instances, since they share the same bounding box. So I was wondering whether or not there is a way to get a bounding box per instanced mesh?

    Im uploading a photo showing the result I want on a cube and what result I get when using the foliage tool, just for clarity


    AFAIK there's no way per-se to get the actual bounding box
    you can however get the instance location (ObjectPivot node), get the instance scale (don't remember the function node name, but it does Vector[1,1,1] -> TransformPosition). then in your tree material instance pass a parameter specifying the tree mesh's Height.
    so with the instance's location and scale (multiplied by the material-specified tree Height), and then comparing with WorldPosition Z, you can get a 0-1 gradient from the tree base to the top.
    Follow me on Twitter!
    Developer of Elium - Prison Escape
    Local Image-Based Lighting for UE4


      Normally you just use vertex paint colors to define all these wind masks, because you may need wind to affect a branch but not the trunk.