RenderLayer Node

Hello Everyone

Im trying to build a materialsetup with support for custom Render-Passes…
such as a AO Pass with custom colors on each material and support for transparent, refractive and reflective elements with bump/normal :eek::cool:
How i would setup this and the other passes in not my problem but i need to access one attribute in my material-nodeeditor for the switching in “RenderLayers”

In other words:

“Material A” in “RenderLayer A” makes a “Combined” Pass
the same “Material A” (with a switch from “RenderLayer B” in “RenderLayer B” makes a custom “AO” Pass
and so on…

i watched a Tutorial about Custom Nodes here…
https://vimeo.com/90065481

…but Python is still way too hard for me to understand…

So my question is:
is it possible to replace the float from the Tutorial with a Boolean Value of the current rendering “RenderLayer”…?

something like:…
if bpy.context.scene.render.layers[“RenderLayer”] is “true” val=1
if bpy.context.scene.render.layers[“RenderLayer B”] is “true” val=1
if bpy.context.scene.render.layers[“RenderLayer C”] is “true” val=1

If someone could kick me in the right direction… awesome!!

Maybe this also could be done easier with a Value-Node and a Scripted-Expression… plz help…
i hope this is even possible…

Can’t be… no one has a hint? I could do it with BAT files and modified sartup.py… but it would be much coooler with a node in the Material… i even think i have a proper function to call…
bpy.context.scene.render.layers = [True for _ in range(20)]
but i still don’t know how to place it in Python…
HELP!

Thanks for your Reply…
This is exactly what i meant…
I try to achieve a Matreial-Setup where i can customize all passes in my own render-layers…
for instance AO; Shadow; Z-Channel but all working for reflection and transparent objects too (with parameter like Roughness, bum and so on…)

If i could get a Node that update a boolean when the next Render-Layer begins to render and the and the next… we could achieve an easy way to do a fully custom multipass pipeline… (no more scene linking… :wink:

I have a concept for a special Material-Setup where all the pass attributes get generated in a automatic way. and some other automatic stuff…

Cuz im a noob in Python i don’t even know where to address that function:
bpy.context.scene.render.layers = [True for _ in range(20)]
i guess that would give me 20 booleans from Render.Layer 1-20
in some lases i read the more advance problem would be to update the Value each time on render.layer change … but i don’t know

If u have an Idea to get that to work … would be perfect… i would need days to work myself into python (which isn’t even a bad idea…but…:wink:

I tired and i failed…

class ObjectPropertiesNode(Node):
bl_idname = ‘RenderLayerNodeType’
bl_label = ‘RenderLayers’

 def ????????(self, context):
     self.outputs["Float"].default_value = self.layerProperty
    self.update ()
    
def update_target_nodes(self):
    for output in self.outputs:
        for link in output.links:
            if link.is_valid:
                # update connected target nodes
                link.to_node.update()
    
 layerProperty = bpy.props.FloatProperty(default=0, update = update_layer)


def init(self, context):
    self.outputs.new('NodeSocketFloat', "Layer")        

def update(self):
            
    for output in self.outputs:
        for link in output.links:
            if link.is_valid:
                
                if output.name == "Layer":
                    output.default_value = self.layerProperty
                    if link.to_socket.type == "Float":
                        link.to_socket.default_value = self.layerProperty
                    
    self.update_target_nodes()

def ??????????????(self):
    self.layerProperty = bpy.context.scene.render.layers = [True for _ in range(20)] 

did someone have an good wiki page for explanation about the def update functions…?
Thanks

Something like that ?



class RenderLayersNode(Node):
    
    '''Render Layers'''
    bl_idname = 'RenderLayersNodeType'
    bl_label = 'Render Layers'
    
    def renderlayers_enum(self,context):
        items = [(layer.name, layer.name, "") for layer in bpy.context.scene.render.layers]
        return items
    
    # === Custom Properties ===
    render_layers = bpy.props.EnumProperty(items = renderlayers_enum, name = "RenderLayer")

    # === Optional Functions ===
    def init(self, context):
        self.outputs.new('NodeSocketFloat', "is_active")
        
    def update(self):
        
        # here you can send the value to the fac value of a mix shader/rgb for example
        pass
        

    # Additional buttons displayed on the node.
    def draw_buttons(self, context, layout):
        
        layout.prop(self, "render_layers")

    
    def draw_label(self):
        return "Render Layers"

Thats awesome…! U are awesome :wink: … I test this as soon as possible and i keep you informed on my progress for that setup (here)…
Oh… did you mind to tel me a good way to install that py?
Do i need to place it in startup? Or do i just install it like an addon? If u have experience to deal with custom nodes, that would might help… But i guess you script is for install … i still did not had the chance to test it out…
Anyway Nice Day :spin:

No, the script is rough and will not work like it is now. Value needs to be sent to the connected nodes and updated correctly when render layer is changed while rendering. I’m not sure Blender will detect it automatically but I think there is handlers for it. I will check for that.