UV/texture geometry node texel density?

Hello,

When an object is scaled by a geometry-nodes setup (like a cube for example).

The UVs of the object are stretched because it keeps the 1:1 scale of the islands

But do you know a way to do a system like “texel density” to adjust the UV scale to the scaled size of the cube ?

Calculate your UVs in Geometry Nodes too, based on the object’s dimensions.

(Keep in mind that geonodes-based UV editing is currently bugged. If you output your 2d vector into “UVMap” attribute, the program converts it from normal UVs into “generic attribute” which is no longer visible for shaders and UV editor. So your shader must use Attribute node with “UVMap” name specified in it in place of texture coordinates)

Hello

Thanks for your answer,

Actually, I don’t know how to calculate the UVs into the geometry nodes.

I’m using a cube primitive (geometry node primitive) and then I inject the UVs data with an attribute node into the shader (uv_map).

Like on this print-screen :

I join the blend file :

SteppedTransform-InstanceUVScale.blend (1.1 MB)

Thanks for your help

SteppedTransform-InstanceUVScale (1).blend (1.1 MB)
So the math behind calculating UVs is called “modulo operation”. It returns the fractional part of dividing value A to value B, such as 1.5 % 1 = 0.5. If you calculate modulos of x,y,z components of vertex coordinates, and put them back to vector form, this will be equivalent of tiling texture in Object space. Your example required some tweaking though, because even after I used Realize Instances (needed to gave access to instances’ vertex coordinates), they still were treated as having non-uniform scale and I had to look for a way to correct it. Finally, to use this new UV attribute, the output Vector have to be created and the results connected to it

3 Likes

That’s amazing,

Thank you so much for your help !!

So if I understand well in your setup the computation is done after realizing the instances.

So if I apply any transformations below that level the UVs will be “projected” in a kind of world space?

I mean the UVs are like “static”.

Because if I rotate the instances by using the “instance on points” I get that:

I don’t know if it’s possible to apply your setup in an instance level?

Like a more universal system which works for all transformations.

Each transformation in an instance level will trigger the transformations of the UVs

Actually, when I unwrap a mesh outside of geometry node (the “traditional way”), each islands has the right proportions in relation with the texture.

That’s what I would to achieve.

Order of operations matters. The UV calculation is based on vertex coordinates, and Instances do not have them, so rotating on Instance stage is going to break the UVs. Rotation should be performed on the mesh. That means it goes after both Realize Instances (converts instances to mesh) and Capture Attribute node which was used to capture Position input for purposes of UV calculation (it will store positions as generic attribute of vertices, meaning it wont be recalculated by transformation)

2 Likes

Ho thank you very much!

I will study all that tonight :slight_smile: