Page MenuHome

Shader Nodes: Use layers from evaluated mesh
ClosedPublic

Authored by Martijn Versteegh (Baardaap) on Mon, Jan 23, 8:08 PM.

Details

Summary

The list was populated from the base (unevaluated) object, but now that
Geometry nodes can generate various layers this is impractical..

Diff Detail

Repository
rB Blender

Event Timeline

Martijn Versteegh (Baardaap) requested review of this revision.Mon, Jan 23, 8:08 PM
Martijn Versteegh (Baardaap) created this revision.
Hans Goudey (HooglyBoogly) requested changes to this revision.EditedMon, Jan 23, 8:30 PM

Don't know what's really better here, but I've seen CTX_data_active_object and DEG_get_evaluated_object a bit more in contexts like this. Sticking in RNA completely might be better though i suppose.

Also, could you update the diff title (commit message title) to follow the style guide? i.e. category prefix and no longer than 72 characters

source/blender/nodes/shader/nodes/node_shader_uvmap.cc
25

This can stay at the same scope as before.

This revision now requires changes to proceed.Mon, Jan 23, 8:30 PM
Martijn Versteegh (Baardaap) marked an inline comment as done.Mon, Jan 23, 8:33 PM

The existing code was RNA, so I thought it better to stick to that...

Martijn Versteegh (Baardaap) retitled this revision from Make UVmap shader node use the evaluated object to populate it's list of available UV maps. to Shader Nodes: Make UVmap shader node use the evaluated object.Mon, Jan 23, 8:38 PM
Martijn Versteegh (Baardaap) retitled this revision from Shader Nodes: Make UVmap shader node use the evaluated object to Shader Nodes: Show UV maps from evaluated mesh.

Hmm, thinking about this a bit more, it would probably best to change these nodes too, for consistency:

source/blender/nodes/shader/nodes/node_shader_normal_map.cc:
  26:     PointerRNA obptr = CTX_data_pointer_get(C, "active_object");

source/blender/nodes/shader/nodes/node_shader_tangent.cc:
  29:     PointerRNA obptr = CTX_data_pointer_get(C, "active_object");

source/blender/nodes/shader/nodes/node_shader_uvmap.cc:
  25:     PointerRNA obptr = CTX_data_pointer_get(C, "active_object");

source/blender/nodes/shader/nodes/node_shader_vertex_color.cc:
  21:   PointerRNA obptr = CTX_data_pointer_get(C, "active_object");

Also did those other nodes.

Hans Goudey (HooglyBoogly) accepted this revision.EditedMon, Jan 23, 9:22 PM

Looks good to me. Don't forget to update the title/description. Adding Brecht as a reviewer to make sure he sees this.

Martijn Versteegh (Baardaap) retitled this revision from Shader Nodes: Show UV maps from evaluated mesh to Shader Nodes: Use layers from evaluated mesh.Mon, Jan 23, 9:26 PM
Martijn Versteegh (Baardaap) edited the summary of this revision. (Show Details)

Added 3.5 tag, because it's something which makes the UV as attributes much more useful in geometry nodes.

Brecht Van Lommel (brecht) requested changes to this revision.Tue, Jan 24, 7:52 PM

I don't think the active object is guaranteed to get evaluated by the depsgraph? I think it should fall back to the original object in that case.

This revision now requires changes to proceed.Tue, Jan 24, 7:52 PM

I don't think the active object is guaranteed to get evaluated by the depsgraph? I think it should fall back to the original object in that case.

I tried to trace through DEG_get_evaluated_id() and as far as I can see it just returns the original id if the depsgraph doesn't return an evaluated id. Since PointerRNA dataptr is always of the OB_MESH type DEG_get_evaluated_rna_pointer() will always use that function (DEG_get_evaluated_id() ).

So I'd think it is not needed?

I'll check it again extra thoroughly tomorrow when a bit more awake. But if it indeed works as described above, do you agree a fallback isn't needed?

Looked it over once again, and the fallback to the original id is already present in blender::deg_get_evaluated_id(...) so I don't think it's needed here.

This revision is now accepted and ready to land.Wed, Jan 25, 11:37 PM