I want to distribute several specified colors to a group of objects based on their position in a scene. Each object needs to be a single color and not a blend. I tried using object info location, separate xyz and colorramp but I’m doing something wrong. What node workflows should I look into?
But that’s the right idea, simplest exampe xyz to rgb. Maybe some value mapping?
Hi, to base on location you could do something like this:
You have to clamp the location values in some way, the factor input of the colour ramp goes from 0 to 1.
Note I have added a math divide node, I used this to clamp the location values between 0 and 1 for the colour ramps, (this could have been done with the map range node). My first cubes location is at 0,0,0 and my last at 22, 26.4, 00 I used these values for the divide node.
I used x to drive the Colour and y to drive Value.
Here is the same thing but with the map range node, I also moved my cubes to a different position and compensated with the map range values:
Now my first cube is at -9.5, -14.6, 0 (apx) and my last at 12.5, 11.7, 0 I have used these values for the map range nodes.
This is more controlable
This is a good setup but lacks control since it’s using Random.
Thank you DNorman. This looks like an effective method. I will test this.
You were already on the right track you just needed to clamp the inputs (location values) for the colour ramp.
Output values of the colour ramp can go over 1 by typing in a larger number in the colour value setting.
In this one I have set different values to the greyscale. Note that I have set the last one to 9, so although the colour ramp input has to be clamped to one its output can go over 1.
Thank you so much for your input! It’s back to the basics. That’s a great tip about the output being able to go over 1.
Yes you were right I needed to clamp the inputs. I’m new to this but now it makes sense. I wish there was a method to numerically monitor the output of a node for example Object Info Location to see what the realtime number output is when adjusting objects.
It does seem like I am fighting against the colorramp node sometimes. There is probably a more programmable setup but colorramp is a has an effective controller interface and is quick to use.
Yes I recall a thread where somebody was asking for this feature and thinking that would be useful. Node experts (which I am not!) tend to be very mathematical and seem to know what to expect!
For location you can simply check the location of your objects origin.
Colour ramps are very useful for those of us (like me) who are not so mathematical!
Edit: I promise this is my last thought!
in my first post I said
Just for the record it is not true that the factor input of the colour ramp only accepts values from 0 to 1 but in this use case it is best to clamp to that for predictable results.
You can input an XYZ value of any number positive and negative (-225.4, 1.0, 875.8).
Your thoughts are great don’t hesitate to share. They are relevant to the discussion of distributing color or numbers through space! I would benefit from a better monitoring setup and think we would all learn quicker if we had more analysis nodes. With the current choices we have to test sometimes in roundabout ways. The math is hard for me.
In the example you posted you have colors arranged on the x-axis and brightness arranged on the y-axis. These are mixing through a HSV node. What happens if you want to have different color sets arranged on both the x and y axis? My guess is math nodes with logic are needed to setup x,y coordinate zones and somehow map those.
Hi and thanks for your kind words. I am not very mathematically literate and am not a node expert but they do fascinate me
I think there are many answers to your question as the result will depend on how you combine the outputs of the different colour ramp nodes. For example if you have 2 colour ramps with different colour combinations you could mix them with a colour mix node in different ways (mix, darken, multiply etc etc).
Or you could use the black and white output of the setup I made to control hue instead of value.
The possibilities are pretty much endless, as you say you could also do lots of things with maths nodes afterwards.
And to be honest I did keep on thinking afterwards! The input for the colour ramp factor is interesting as it can combine uv information with the factor value to map colours all over your model. I should investigate more on how much information it actually handles.
Speaking of which there is an incredible nodegroup made by Daniel fox (that I have already recommended many times in other posts) that extends the colour ramps possibilities in a very interesting way:
It gives you input sockets for the position and colour slots of a colour ramp. You can even input an image or a procedual texture into the colour slots allowing you to mix images with a gradient) and the position slots which gets really interesting! This node group has many possibilities that I have yet to explore. If you like colour ramps you will love this one!