Download

Sample texture at specific x/y ?

Basically a world mapped texture is being used to drive stuff in wpo.
This works well enough generally speaking. Nifty, fast. Etc.

What I would like to do is change it so that the sample is in a precise x/y location instead of whatever is under each vertex.

To explain it more practically.
imagine a 10cm cube.
This cube is placed in a mesh where the origin is at 0,0,0
the cube itself is shifted by 25cm x/y

The pivot of the cube, or geometry center is therefore at 25cm x 25cm y in world space.

The world’s space texture being sampled is a gradient used to shift the z of the verticis in WPO.

Issue.
the cube is shifted following the gradient.

I would want the cube to shift following the value found at geometry’s center (which is determined mathematically and unimportant to the use case).
The result would be it goes up without a slant.

Needs to happen within shader.
I’m sure it’s possible, I probably am either unaware of the nodes needed or need to look into hlsl custom for this too…

any suggestions?

Oh… before some goes “dha, just use x/y as the UV”…
This needs to be able to happen on multiple cubes contained in the same mesh.
I can’t lock the value being read to a single specific x/y but need a way to tell what that value is at that XY…

For what it’s worth, because eventually someone will end up here via Google.

(shifted texture UV + (Object Pivot - WPO) + (texture size/2) ) / texture size -> Mask RG feed to UV, happy sampling.