B3.2 geonodes instances color variation problem

Hi all !

Here’s my problem: I make with GN leaves instances over a surface. all works fine but things become impossible when i want to make a per-instance color variation.
Between attributes, properties, GN outputs and many other things i confess i’m lost.

Of course i’m stuck because i don’t know GN enough and this is very frustrating.

What i’d like to do is quite simple: in GN, modulate color with a color ramp attacked by a random-per-instance value, and retrieve the color variation in shader to apply it to each instance.

The blend:
feuilles.blend (2.8 MB)

I wasted the day on this and i’m giving up for today…
If anyone got an idea on how to do this, it would be great ! :smiley:

Thanks and happy blending !

@AlphaChannel I actually have some ideas here but I’m not 100% sure so I’m passing the mic to you :wink:

1 Like

instances, to my knowledge cannot have their own attributes

I would try to do all of the color changing directly in the shader nodes

Blender 3.4

5 Likes

Thanks @AlphaChannel :smiley:

Yes this is what i’d like to do :slight_smile:
And among the legions of things i tried-out, i tried this one too ( store named attrib ) and it seems not to work…

You’re on B3.2 and i suspect the store named attrib node is buggy in 3.2. It works when you choose point in store names attr, and geometry in shader node attribute but this is not what i want as it gives a per vertex color variation similar on all instances.

Could you please confirm or infirm your setup works in B3.2 ? or post the blend ?

EDIT: i got a probably stoopid question but… Are the geo nodes behaviour hardcoded in blender C code ? or are they some script ( python or XML or anything else ) that could be modified after compile time ?

EDIT2: my bad. It is not the GN STORE NAMED ATTRIBUTE that is bugged. It is the shader node ATTRIBUTE that seems unable to retrieve an attribute when in instancer request :frowning:

Im using 3.4 alpha, sorry, its daily builds for me…

In the shader editor you can use the random socket of the object info node to change for example the hue of the leaves, hope this helps.

1 Like

Thx @roobol :slight_smile:

yes i think it is the only way to achieve what i want to do.
I would have preferred to handle the color modulation in the geonodes but as the shader attribute node don’t behaves properly with the instancer parameter i got no choice :confused:

Happy blending !

1 Like

You’re welcome :-))

1 Like

Finally i got something interresting as a hedge billboard :slight_smile:

Thanks to all and happy blending !

2 Likes

That was a very helpful example!

I was trying to print out the color output from Color ramp, but unsuccessfully. The closest value I found for this was “default_value”, but… I need current one instead. Per each instance. Is that possible? Something like following:

import bpy
print("NEW")

# Define the input node name
input_node_name = "VALTORGB"

# Iterate through selected objects
for ob in bpy.context.selected_objects:
    # Check if the object has an active material
    
    if ob.active_material:
        material = ob.active_material
        
        # Check if the material has a node tree
        if material.node_tree:
            node_tree = material.node_tree
            
            # Find the specified input node
            for node in node_tree.nodes:
                #print(node.type)
                if node.type == input_node_name:              
                    print(node.outputs[0].value)      # '.value' is not valid. How to get this value in Python?

Edit.: Ah, I just noticed that after making instances real, all that randomized color variations is not retained… Is possible to make them real without loosing color variation somehow?