Page MenuHome

Patch for T60011: switch shader list in Eevee shows Cycles list
Needs ReviewPublic

Authored by Vaishnav S (padthai) on Jan 15 2019, 7:11 AM.

Details

Summary

I made a separate list of shader nodes for eevee; works fine now

Diff Detail

Event Timeline

Philipp Oeser (lichtwerk) requested changes to this revision.Jan 18 2019, 9:59 AM

Thx for this!

This however will then exclude some cycles shaders [when you are working in cycles].

So I guess we could either:

  • keep separate lists for cycles and eevee [this should check for context.scene.render.engine on each occasion the list is used], or
  • keep them all in one list, add specular there [and live with the fact that not all shaders in the list are actually supported by the partucular engine...]

The first choice seems a bit cleaner [though a bit more work]

Note there are more nodes that differ from one engine to the other [e.g. Shader to RGB]; ideally these would be handled as well [though this could be added later as well]
For a nice overview see https://docs.blender.org/manual/en/dev/render/eevee/materials/nodes_support.html
[I also wanted to check if it is possible to extract supported nodes dynamically for each engine, so we dont have to keep these lists at all -- but this could also be done at a later stage]

If you want to work on this, you are very welcome [otherwise I can also update the Diff accordingly]

This revision now requires changes to proceed.Jan 18 2019, 9:59 AM

Really the proper solution is for node wrangler not to duplicate the lists we already have in nodeitems_builtins.py, and instead use nodeitems_utils to loop over categories and nodes.

I think I'd like to have a go at this, thanks.

Vaishnav S (padthai) updated this revision to Diff 13261.EditedJan 19 2019, 2:17 PM

Made separate lists for shaders and converters. The Shader To RGB node and the Specular node can be switched to now, and the rest of the cycles nodes work as well. Please have a look at the changes.

@Vaishnav S (padthai): please excuse the delay again (now reserved some time to look into addon-related reports...)

Two things before looking deeper:
(1) current patch doesnt apply to master [is this possibly based off of a previous version?] (e.g. list(eevee_shaders_shader_nodes_props) is not in current master code)
(2) as @Brecht Van Lommel (brecht) mentioned, it would be really best to use nodeitems_utils to loop over categories and nodes. Are you willing to look into this? (I'm available to help out in case of issues...)

sorry again for the inconvenience caused by replying late here...

Vaishnav S (padthai) updated this revision to Diff 14137.

Sorry for uploading the wrong patch, some of the required code wasn't included in it.
I've also moved the Ambient Occlusion node from shaders to input, like it is in Blender.

Thanx for updating and sorry again for the delay, looked into this again, and while this would work, it would really be good to not add more code [in regards to cycles vs. eevee], but use functionality already provided in nodeitems_utils.
This is ensured to be up to date (uses the builtin lists and polls from nodeitems_builtins) and is already taking care of returning the right nodes depending on renderengine, shading/compositing/texture nodetree etc...

Sooo, we can get rid of all these lists in nodewrangler:

list(shaders_input_nodes_props) +
list(shaders_output_nodes_props) +
list(shaders_shader_nodes_props) +
list(shaders_texture_nodes_props) +
list(shaders_color_nodes_props) +
list(shaders_vector_nodes_props) +
list(shaders_converter_nodes_props) +
list(shaders_layout_nodes_props) +
list(compo_input_nodes_props) +
list(compo_output_nodes_props) +
list(compo_color_nodes_props) +
list(compo_converter_nodes_props) +
list(compo_filter_nodes_props) +
list(compo_vector_nodes_props) +
list(compo_matte_nodes_props) +
list(compo_distort_nodes_props) +
list(compo_layout_nodes_props) +
list(blender_mat_input_nodes_props) +
list(blender_mat_output_nodes_props) +
list(blender_mat_color_nodes_props) +
list(blender_mat_vector_nodes_props) +
list(blender_mat_converter_nodes_props) +
list(blender_mat_layout_nodes_props) +
list(texture_input_nodes_props) +
list(texture_output_nodes_props) +
list(texture_color_nodes_props) +
list(texture_pattern_nodes_props) +
list(texture_textures_nodes_props) +
list(texture_converter_nodes_props) +
list(texture_distort_nodes_props) +
list(texture_layout_nodes_props)

and instead get them from nodeitems_utils. For example, this could be used to get shading shader nodes [you dont have to worry about cycles/eevee]:

for cat in nodeitems_utils.node_categories_iter(context):
    if cat.identifier == 'SH_NEW_SHADER':
        for item in [it for it in cat.items(context) if isinstance(it, nodeitems_utils.NodeItem)]:
            op = layout.operator(NWSwitchNodeType.bl_idname, text=item.label)
            op.to_type = item.nodetype

or check output of a test operator

1import bpy
2import nodeitems_utils
3
4def main(context):
5
6 for cat in nodeitems_utils.node_categories_iter(context):
7 print("%s %s" % (cat.name, cat.identifier))
8 for item in cat.items(context):
9 if isinstance(item, nodeitems_utils.NodeItem):
10 print(" %s %s" % (item.nodetype, item.label))
11 nodetype = getattr(bpy.types, item.nodetype, None)
12
13
14class SimpleOperator(bpy.types.Operator):
15 """NodeItems utils example"""
16 bl_idname = "nodes.nodeitems_utils_example"
17 bl_label = "NodeItems utils example"
18
19 @classmethod
20 def poll(cls, context):
21 return True
22
23 def execute(self, context):
24 main(context)
25 return {'FINISHED'}
26
27
28def register():
29 bpy.utils.register_class(SimpleOperator)
30
31
32def unregister():
33 bpy.utils.unregister_class(SimpleOperator)
34
35
36if __name__ == "__main__":
37 register()
[this automatically adapts when you change renderengines, or are in compositing, etc...]

Let me know if there is anything blocking from getting this patch updated to use this...

@Philipp Oeser (lichtwerk) you can make the necessary changes. worked on it for a while but failed (python isn't my strong suit). Sorry for the delay in informing you