Is there a way to get a colour to match the colour of an adjacent mesh?

Maybe a crazy question, but it there a way to set a colour input to match the colour of the closest material/mesh?

For example, if I had a cube that I wanted to dynamically adopt the colour of the nearest surface - so if it touched a green surface it would be green, if it touched a red surface it would be red.

Asking out of curiosity and because, if it is possible, it would be really useful for making dynamic procedural materials :smile:

Thanks

are you talking about radiosity here ?

happy bl

Hm I don’t think so? (I don’t really know what radiosity is but I gather it’s more to do with light…?)

All I was wondering was if there is a way to set an object’s colour to match the colour of whatever it touches. Like a node set up that samples the colour input from whatever other material colour it comes into contact with!

This not not exactly what your asking about, but maybe when he posts his tut it will leand ideas: Molecules | Blender Physics Simulation

For a similar purpose (material blending between different objects with minimal seams) best I could come up with in blender is to have a master material where all the object materials are in (node groups usage is probably helpful here) and then blend the mixing with dynamic paint or AO (worse solution, as in eevee it changes based on the viewing angle).

I don’t think there’s a easy solution for something like that natively in blender. Something like animation nodes might work in your case.

You could do it with python.

I am pretty sure this wouldnt be difficult with Animation Nodes.

Aha yes I know, but I mean for the colour to change dynamically for use in a procedural material.

For example, if I created a fruit stem and I could set the base of the stem to match the colour of whatever it’s touching then you could create a stem material that anyone could download and it would automatically match the colour of whatever fruit they were making.

I’m starting to think it’s probably too complicated - just thought it would be a cool addition to procedural materials to make them more versatile and easy for the downloader to incorporate into their scene! :sweat_smile:

This is with AO. Plenty of problems with it, but other options require baking or longer set up. Would be nice if there was something like distance fields in blender.

1 Like

what is the group node a bottom?

can you upload a sample file so we can better understand how this works

thanks
happy bl

It’s just the ground plane material in a node group so I could access it in another material. Using object normals with a empty controlling the transforms so they would match up. Only works okay in Cycles though, since eevee AO is too inconsistent.

Can’t share the file since it uses Megascans assets.

so on top of mix shader you have the rock material and on the bottom
the landscape material

and you add some AO in between i guess

happy bl

let me open a new thread to see if possible to do radiosity in cycles
will see if there is a way!

thanks
happy bl

I am not aware of a way to do this with only the shader because you can not pipe other objects into the shader.

You would need something to control a color node or something like that in the shader.
You could do this with python, drivers, animation nodes or something like that but I do not think you can do that with the available shader nodes.

Perhaps you could try it with OSL but hen you lose GPU support which you might not want to lose.

1 Like

It was possible to trace some rays, and get at least the “material_id” from the hitted rays…
But I’ve tested in 2.83 and this is not working now…(material id returns 32603 no matter which index it has). :frowning:

Theoretically, it would be possible to even get the Ci (full closures) from the hits, but afaik this never worked.

1 Like

did a test of radiosity in cycles

is it something like what you want ?

happy bl

How exactly would radiosity be used to achieve the colour matching effect though? (I’m a total noob to this so I really don’t understand what’s going on :sweat_smile:)

it is like objects reflection on other objects = radiosity

but may you need something stronger !

another way might be to add an emission node on your material to get more colors !

happy bl

Ohh right that makes sense, thanks :blush: