UV project in geometry nodes

Hello, I have instances distributed on the mesh islands and I want to project mesh UVMap coordinates to the instances.

Answer is here: UV project in geometry nodes - Blender Stack Exchange

But, is there any way to achieve this without the realizing the instances? I have distributed thousands of instances on the mesh islands and I want to opacity mask parts of the instances crossing the mesh island borders (performance without booleans). I can achieve this by creating a map range of the bounding box min max of the entire area and then in shader editor get the texture coordinate > object and then same map range. But this technique stop working when instances are large and mesh islands too close to each other. Many Thanks!

Hi, you can’t alter an instance geometry, that includes any geometry attribute. So you won’t be able to mask parts of the instances unless you realize them -you could however sample the UV coordinate from the closest element (ie the point it’s instanced on) and store it on the instance domain, and use that somehow, perhaps it would help. It depends on the specifics.

2 Likes

Thanks Hadriscus, yes this is I figured out already, if possible, it is about some workaround, I still cannot figure out, with my poor knowledge;) So far I can project to all instances 2D flat constructed mapping from the bounding box size and this sort of works… but… still too fresh in blender…

K, so I’m guessing you made it to here:


But I’m not understanding the bit about the islands? Please elaborate.

Thanks.

1 Like

too late here now, leaving tomorrow, will check on friday, but replies from you lead to solution, thanks!

Hello Skilz, I am definitely not there at all, in similar scene I got it sort of working, but still I cannot find the way how automaticaly get the correct scaling and in the different scenario (you will understand now what was that bit about the islands and masking) I cannot make the rotation working;( Thanks!

file:
UV_opacityzero.blend (2.0 MB)

OK, I think I understand now what you are trying to achieve… getting the scale is similar to getting the rotation. It relies on sampling the UV coordinates and getting the lengths of xy components:


image
…multiplying by inverse of sample vector lengths.
image
I can get rough approximation using these very small deltas but things still mess up where geometry crosses islands:
image
…like on Suzanne’s eyes here. (nm I was being an idiot and didn’t wire up the rotation from the distribute on points - fixed)

Anyway… I have to go to bed and have a long day tomorrow… Will try look into this more this weekend.

5 Likes

Skilz, I realized the issue with my rotations was I flipped few islands after the unwrap, minor issues with the rotations sometimes appear, but for these not detailed meshes it works quite OK. You developed good method for masking grass and other small instances along the edges! Thanks!

UV_opacityzero2.blend (1.4 MB)

Hello Skilz,
this method is perfect. Blender is amazing. This gives an opportunity using milions of instances and quite heavy geometry. Only thing can be better if there is in the future some way to expose the SDF/volume or some kind of the distance texture to the shader editor that can be used with the instances regardles of their resolution and without realizing them as rendertime boolean (corona distance, vray distance, octane clipping material, octane object data and volume to 3d texture, unreal engine sdf…). Anyway even this is good enough for this use, I am just wondering, is there any possibility to improve the result precision? In the geonode tree I offset the island borders and adjusted the mapping there, so I am avoiding the crossing border issues, but still in some positions the sampling is not perfect. Thanks!

8k texture masked + heavy instance test:



uv sampling + island border mapping adjustment:

small imperfections at some positions:

1 Like

Higgsas’ inset may help with adjusting island borders:

Good luck.

Thanks - I need to go out in the uv space doing the same in 3d and then set 2d uv back to 3d - so using the same sorcerrers edge offset, I do not think there is an issue with the borders after this, showed the image as the proof (at least I hope…) in the “masked booleans 02” you see the second island I am raycasting to, the offset black border is slightly wider than the instance size. Wondering where these small errors coming from. Is this the nature of sampling - it might be not precise?


or this might be some uv stretching issue as I dragged some verts slightly in the uv editor after unwrap to get the ridge valley (black gap with the problematic tiles)?

…ok that issue again probably on my side, seems to me it was uv stretching, not obvious on the base mesh but pronounced to instances…