8
$\begingroup$

I am trying to scatter a textured object with Geometry Nodes. After applying Geometry Nodes, my objects lose the texture coordinates.

Is there any way to get UV maps on these scattered objects?

enter image description here

$\endgroup$
3
  • 1
    $\begingroup$ This is a known limitation currently. See developer.blender.org/T86653 and developer.blender.org/T85962 $\endgroup$
    – Gorgious
    Jun 21, 2021 at 9:32
  • $\begingroup$ You could use "Make instances real" under Object Menu > Apply >Make instances Real... You will have an object per cube so, then you need to join them with CTRL + J $\endgroup$
    – Emir
    Jun 21, 2021 at 12:14
  • $\begingroup$ I see, it works with attribute. But still want to have a solution to pass UV into regular texture coordinate. $\endgroup$ Jul 24, 2022 at 10:18

5 Answers 5

9
$\begingroup$

With Blender 3.1.2+ the bug has been fixed.

The UV maps created in your objects will be processed correctly in the shader if they were previously instantiated with Geometry Nodes.

enter image description here

However, as soon as you use the Realize Instances node in the geometry nodes, you have to reattach the UV map with the Attribute node in the shader.

enter image description here

$\endgroup$
1
$\begingroup$

This is what worked for me:

  1. create a custom material on Instance, use Attribute for UV with a custom string 'UVOutput'

  2. create a custom geonode on Instance, use its UV map as input and output to 'UVOutput' -- this is to convert uv data to attribute data format in Blender

  3. Make sure UV input string is consistent as the UV setting of the Instance object (this gets confusing if you have multiple objects)

All is explained in the graph, hope this is helpful

enter image description here

$\endgroup$
1
  • $\begingroup$ This was the answer for me. Cheers! $\endgroup$ Dec 13, 2022 at 5:49
1
$\begingroup$

I think I have a really good solution, expanding from @totegamma's response in this POST

import bpy

# Get the active object
obj = bpy.context.active_object

# Duplicate the object (USING COPY SO TO NOT AFFECT ORIGINAL MODEL)
duplicate_obj = obj.copy()
duplicate_obj.data = obj.data.copy()
bpy.context.collection.objects.link(duplicate_obj)

# Set the context
bpy.context.view_layer.objects.active = duplicate_obj

# Apply the modifier
with bpy.context.temp_override(object=duplicate_obj):
    bpy.ops.object.modifier_apply(modifier=duplicate_obj.modifiers[0].name)
    
# Add UV Slot 
bpy.ops.mesh.uv_texture_add()

# Pass Attributes to Layers (totegamma)
attrUV = duplicate_obj.data.attributes["UVMap"].data
targetObjUV = duplicate_obj.data.uv_layers[0].data

for i, elem in enumerate(targetObjUV):
    elem.uv = attrUV[i].vector

If anyone needs clarification let me know, but this should:

*Apply FIRST modifier (you can edit "duplicate_obj.modifiers[0]" to be 1, 2, etc)
*Add UVMap Slot
*Copy UV data from attributes to the actual UV Map 
$\endgroup$
0
$\begingroup$

Using a similar technique in principle to this:

Assign vertex group in Geometry Nodes (v3.3)

You can split edges, save your vertex positions, and then move them to their UV coordinates:

Then add a UV Project modifier:

Set the chosen camera to orthographic, projection scale to 1, position it at $(0.5, 0.5, 0)$ coordinates. Finally, add another geonodes setup restoring the positions and merging split edges:

It's worth to note if the original geometry had some split edges, this technique loses that information - I have an idea how one could restore that information, but it probably deserves a new question "How to split edges and then merge only those that were split?".

$\endgroup$
1
  • 1
    $\begingroup$ This is a wild solution I love it! $\endgroup$
    – globglob
    Nov 8, 2022 at 11:09
0
$\begingroup$

I found alternative dirty solution to create UV on realized instances. Its based on splitting object by normals what can be used as a seam. Hope its not magically working only for me :)

sources: https://www.youtube.com/watch?v=02XNGOVpSV4&t=445s&ab_channel=Entagma https://www.youtube.com/watch?v=wVhThuzRDIk&t=740s&ab_channel=JohnnyMatthews

enter image description here

enter image description here

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .