2
$\begingroup$

Hello I've read a few threads on this but i havent found anything with my specific issue. I want to try colouring my mesh based on specific Z values. So for example if its above 10 I want it to be red. At the moment I'm colouring it via the colour ramp method but as you can see in the attached image it only colours relatively. I dont know if theres a better way to edit the colour ramp to what I want? Because at the moment I dont understand why theres such a small segment of my mesh coloured orange. Or if theres a script I could use to colour it? Any help would be appreciated. Thank you

enter image description here

$\endgroup$
3
  • $\begingroup$ blender.stackexchange.com/questions/5491/… $\endgroup$ Jul 15, 2021 at 12:26
  • $\begingroup$ Thanks for sharing that, i've read this therad earlier it isnt exactly what im looking for im afraid $\endgroup$ Jul 15, 2021 at 12:31
  • $\begingroup$ You just need to plug a Vector math node between the Texture Coordinate and the Separate XYZ and set the operation to Scale, then play with the value. Or a math node set to multiply after the separate xyz $\endgroup$
    – Gorgious
    Jul 15, 2021 at 12:56

2 Answers 2

5
$\begingroup$

The Color Ramp operates in the 0-1 range.

enter image description here

To use a ramp to control color over the entire height of an object, no matter the size, use the Generated coordinate space.

enter image description here

If the actual Z height is important to what you're trying to do, you can use a Math node to divide the value coming out of Separate XYZ and bring them down to something the Color Ramp can operate on.

enter image description here

The same could be done with Map Range, it might be easier to control for values below 0 this way, or you could use a Mapping node to move up or down on the Z-axis.

enter image description here

$\endgroup$
7
  • $\begingroup$ Hey! You edited yours to copy mine. $\endgroup$
    – TheLabCat
    Jul 15, 2021 at 13:16
  • $\begingroup$ I saw your answer pop up as I was writing and knew we were going to have to fight to the death. $\endgroup$ Jul 15, 2021 at 13:19
  • $\begingroup$ well, I have felt the frustration of trying to write an answer to a question and then see someone else was already answering it. In the real world, people usually don’t have this problem. I’ll withdraw my answer. $\endgroup$
    – TheLabCat
    Jul 15, 2021 at 13:23
  • 1
    $\begingroup$ No, I think you should leave it, that is good info $\endgroup$ Jul 15, 2021 at 13:26
  • 1
    $\begingroup$ @ZargulTheWizard no need to withdraw any answers.There is no harm in having more than one answer to the same question, especially well composed ones. Maybe they go about it in a different ways or with nuanced details that make them valuable to someone. Never let your work go to waste. $\endgroup$ Jul 15, 2021 at 14:00
4
$\begingroup$

The fact is that the Color Ramp takes values from 0 to 1, but your mesh goes from like -11 Z to 6 Z. The first color stop on the ramp is green, so anything below zero on the Z axis will be green.

I recommend using a Map Range node to fix this. Set the From Min and From Max to the lowest Z position and highest Z position on the mesh, respectively, and then leave the To Min and To Max at 0 and 1. Connect the geometry Z value to the Map Range input value, and send the mapped output value into the Color Ramp node.

In the meantime, you may want to use a Vector Transform node to convert Point Vector from World to Object. That way, no matter how the position or rotation of the land may change, the texture will stay stuck to it (the Geometry position input is in the World space starting off).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.