3
$\begingroup$

I am making a modular road system where I want to apply an asphalt material with white road markings on many different roads (objects).

Now I want to be able to apply the same asphalt material to all these objects and then control for each object separately: the location of certain individual white road markings/ if they are full or dashed/ visible or not/ etc.

This way I can make more complex configurations like crossroads etc.

One way to solve this would be to make a different material for each object and use NodeGroups to make it easier. The problem is that I need many different combinations and that it would result in too many different materials to manage in a practical way.

I think the solution would ideally be controllable from within geometry nodes.

I attached the Blender file:

enter image description here

$\endgroup$
3
  • 1
    $\begingroup$ Have you looked into node groups? It will allow you to have the same node group in several materials, and if you need to make some changes it will be replicated in the different materials $\endgroup$
    – moonboots
    Jun 7, 2023 at 10:39
  • $\begingroup$ "...too many different materials to manage in a practical way..." Well, if you have many configurations, you will have many different things of some sort in your scene. What does it matter what those are? What's difficult about managing many materials? $\endgroup$ Jun 7, 2023 at 10:46
  • $\begingroup$ The thing is: with such a system I would have to setup a new material for each new object that I create. I'm trying to find a solution that works like Geometry Nodes, where you can use the same modifier for many different objects and have different results depending on the input parameters that you set. $\endgroup$ Jun 7, 2023 at 11:29

2 Answers 2

3
$\begingroup$

You can use the Martynas' answer, but without custom properties, by switching the Attribute node to Geometry type, then reading a custom attribute just like the u, and v attributes. Then you can save them inside geometry nodes:

The data is duplicated for each vertex, so for many attributes and dense geometries it could add up to something worth optimizing, e.g. this way:

$\endgroup$
8
  • $\begingroup$ Hi Markus, this is awesome! :-) Just what I was looking for. Many thanks! I did a bit of testing with this system. I would probably use maybe 20 of these 'store named attribute' nodes in a row, like so: imgur.com/a/mKhHgux Do you think this would be the most effective method? Would it have an influence on performance like this? $\endgroup$ Jun 8, 2023 at 17:54
  • $\begingroup$ @PieterLéon You will be fine :) $\endgroup$ Jun 8, 2023 at 19:36
  • $\begingroup$ Thanks a lot Markus! Is there a way I can treat you on a virtual (Paypal) drink? :-) $\endgroup$ Jun 11, 2023 at 7:20
  • $\begingroup$ @PieterLéon I have a paypal, but unfortunately I drink neither coffee nor alcohol 😜 $\endgroup$ Jun 20, 2023 at 8:25
  • 1
    $\begingroup$ @MarkusvondBroady Yes, those filters costs money. :-) I bought your edge sharpness tool on your GumRoad for 5 dollar :-) $\endgroup$ Jun 24, 2023 at 8:31
5
$\begingroup$

You can control what happens in a material with custom properties of an object:

enter image description here

This way different objects with different custom properties can look different with the same material.

You can use Python to quickly create custom properties:

import bpy

for o in bpy.context.selected_objects:
    o["SomeBoolProperty"] = True
    o["SomeIntProperty"] = 1
    o["SomeStringProp"] = "Something something"
    o["SomeColor"] = (1,0.2,0.5,1)
    o.id_properties_ui("SomeColor").update(subtype = 'COLOR') 

Setting properties of the custom properties is a bit tricky(at least for me personally). I cannot find documentation for it. Anyway, the properties of custom properties seem to be accessible with object.id_properties_ui() and you update them with update() that has following description : enter image description here

Python Console also gives some helpful error messages: enter image description here

So apparently subtype can be

'NONE', 'FILE_PATH', 'DIR_PATH', 'FILE_NAME', 'BYTE_STRING', 'PASSWORD', 'PIXEL', 'UNSIGNED', 'PERCENTAGE', 'FACTOR', 'ANGLE', 'TIME', 'TIME_ABSOLUTE', 'DISTANCE', 'DISTANCE_CAMERA', 'POWER', 'TEMPERATURE', 'COLOR', 'TRANSLATION', 'DIRECTION', 'VELOCITY', 'ACCELERATION', 'MATRIX', 'EULER', 'QUATERNION', 'AXISANGLE', 'XYZ', 'XYZ_LENGTH', 'COLOR_GAMMA', 'COORDINATES', 'LAYER', 'LAYER_MEMBER'

I think 'COLOR' is the most useful here.

$\endgroup$
7
  • $\begingroup$ Hi Martynas, It is indeed something like this that I am looking for. Thanks! Does this mean I have to create new custom properties for each new object that I create? Would there also be a possibility to control something like this through Geometry Nodes without having to change anything to the properties of each individual object? $\endgroup$ Jun 7, 2023 at 11:26
  • $\begingroup$ Geometry Nodes are more for geometry, it might be useful to work with objects instead of geometry because you might want to re-use object data for repeating elements, but make them look different. You can use Python for creating custom properties quickly if you have a lot of objects. $\endgroup$ Jun 7, 2023 at 12:13
  • $\begingroup$ I updated the answer with an example of how to use Python if needed to avoid tedious work of making properties for every single object. $\endgroup$ Jun 7, 2023 at 13:57
  • $\begingroup$ I don't think wrapping int literal in int() makes sense, after all it's evaluated first before being assigned. type(1) is type(int(1)). float(1) makes more sense to get a float, though 1. is more convenient. $\endgroup$ Jun 7, 2023 at 19:13
  • $\begingroup$ @MarkusvonBroady You are right. $\endgroup$ Jun 7, 2023 at 20:00

You must log in to answer this question.

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