Hello,
is there a way to get UV coordinates of a texture that is mapped onto tiled planes by using world coordinates - see code below (for surface shader):
I am using contact points (created on collisions) to create rays which will intersect the plane and I would like to change the texture at the point of the collision. However, because of the world projected texture, I cannot get to the right coordinates of the texture to modify it.
float u = (worldX % planeWidth) / planeWidth;
float v = (worldZ % planeDepth) / planeDepth;
That would work with positive worldX and worldZ assuming the first one was aligned to zero (i.e. if it’s 50 wide, they start at 0, 50, 100, 150 etc.). It would take a little more effort to handle negative coordinates or allow for offsets etc. but that’s probably the simplest way to determine a UV from a world position for a texture tiled in world space (afaik).