# NME How to determine Instance Location, in front, or behind Y=0 Plane?

I’m trying to read the individual locations of Instance in a Thin Instance, while they are each being animated with an NME.
Depending on whether the instances sit in Front or Behind a Plane (Mona Lisa plane Z=0), I want to then color the Instance Blue or Red to differentiate between their locations.

I’m so close with the nodes but I’m missing something for the coordinate system with NME. What am I doing wrong?
@PirateJC this is probably a quick one for you!

My Node Material Editor: https://nme.babylonjs.com/#19BCL7#5

@HirangaG can you send the playground with this Node Material hooked up in it.

I think the main issue is that you’re passing the wrong value into the “find location of each instance” frame.

You want the world position, not the world position relative to the view matrix (which is what you currently have)

Send the playground our way and I’ll take a look

1 Like

Hi HirangaG,

First of all, this is a very cool node material! If you have a Playground showing it in action, I’d love to see that.

Without seeing it in action, it’s a little difficult to know for sure what I’m looking at, but it looks like the position you’re using for your red/blue comparison is the same as the one going to your vertex output, which appears to be in clip space (i.e., the vertex position after multiplication through the world-view-projection matrix). This is the correct value for vertex output, but I don’t think that’s where you want to do your Z comparison. (Looks like PirateJC just beat me to it, but I’ll finish my thought anyway. ) If your plane is just the XY plane, then I think all you need to do is do the Z comparison in object space, i.e. before multiplying by any of the world/view/projection matrices, something like this. Hope this helps, and best of luck!

1 Like

Hey team! please see attached! I’ma get some shut eye before the sun comes up!

It has taken a while, and a village thus far

1 Like

That’s super cool! And yes, I think the Z-in-object space thing will produce the effect you’re looking for.

2 Likes

Oohhh I took it out of the world space. I’m learning! Thank you!!