Shader Problem: Need help accessing center point of Foliage Instance inside material

Hi I’m having an issue with the foliage shader that I’m working on. I’m try to create a shader that expresses seasonal die-off of foliage (most plants don’t stay healthy and green during winter). I have the general color blending and what not done, but I’m having an issue with the vertex shader. I believe I need to access either the Object Position or Pivot Point nodes, but either they’re not working or I’m using them incorrectly as they refer to a point far off in the void away from my landscape. I’ve tried using the transform nodes, but the result did not differ.

What I want to do with the vertex shader is to have the plant leafs pull in towards the plant stem (on the X and Y axis) and shrivel up as they die off. I would also like to have the leafs “lay” on (or near) ground level as well as the plant slumps so I “think” the Pivot Point node is what I need to figure out how to use.

Here’s a video that shows what I have so far as well as a pic of the important part of the material shader. The mesh / main material is from an asset pack off the market so I believe I’m not aloud to show the rest of the material (though it shouldn’t be needed).

Pic of material nodes affecting world offset:

Thanks in advance to anyone who can help.

To get position of your instance in world space, you would need to use transform position material expression local space->absolute world space with input of (0,0,0).
I’m not sure, but I believe you had to do that in vertex shader(by passing it via custom UV, or using interpolator node as of 4.16) to make it work.

I figured it out.

Had to subtract Object Position from the Absolute World Position which gave me an offset, then had to subtract that offset from (0,0,0) to get my local (relative) pivot point offset from the current vertex being iterated over.

For some reason attempting to use the transform node (from world to local) did not work on Object Position or Absolute World Position.

I used what Deathrey stated above to feed different nodes (with different transforms applied) into the Custom UVs, then used the custom UVs to feed data into the Debug nodes to show a numerical representation of the nodes I was feeding into the UVs … I got several “unexpected” values and even worse is how some things worked on instances, but not static meshes (and vice versa).

Now I get to go play with more numbers to see what kind of stuff I can come up with :slight_smile: