# how to modify / customize a coloramp?

New to blender, coming from engineering discipline and want to learn more about rendering CFD/model results in Blender.

Right now I'm struggling with generating a coloramp for a 3d surface. What I've done is made a random 3d surface to test with, and developed a shading node setup to achieve a coloramp based on the geometry of each vertex. My current shading node setup and render looks like this:

Right now it looks fine and what I think it's doing is scaling the min/max z-values of the geometry to cover the entire coloramp.

What I would like to do is clip the colorramp. For example, to have a min value of -5 and a max value of 5. Anything below -5 will be red, anything above 5 green, anything in between interpolated.

I want to achieve this so I can have a constant coloramp/values between frames if my z-values change.

How can I go about doing this?

• "Right now it looks fine and what I think it's doing is scaling the min/max z-values of the geometry to cover the entire coloramp." That is what the Generated Coordinates do, for absolute positioning in local coordinates use Object, then adjust with Math Node operations. You can also use Vector Mapping to absolute Worldspace coordinates if you have scaled objects – Duarte Farrajota Ramos Apr 17 '20 at 17:36
• Not sure I understand how this helps me. Are you saying I can clip the coloramp by using the local coordinates then math nodes to clip the values ? And how could I replace z values with another array of values? – Derek Eden Apr 17 '20 at 17:42
• More detail pertaining to the OP would be appreciated – Derek Eden Apr 17 '20 at 17:43

## 2 Answers

I'm not sure I follow your second (sub)question, but as far as the first question is concerned:

## Node setup

The important node I think is the Map Range node, which will take the Z-component of the geometry as input (set your desired clamp ranges here) and maps them to [0, 1], which the ColorRamp node requires.

## Result

In this animation, I am changing From Max in the Map Range node. As you can see, all values above From Max get clipped to the upper limit of the ColorRamp.

Hope this helps.

• this absolutely helps and solved my issue..I thank you very much!!! – Derek Eden Apr 17 '20 at 19:27
• my second subquestion (sorry if unclear) is: say I have a mesh with n points..there will be n z-values associated with the points that I can use for a color ramp such as in your solution...now, say I have a list of n values that I want to use instead of the z values for the color ramp, how can I basically replace the geometry -> separate xyz nodes (which basically strips out the z values of the points) with a list of predefined values, maybe they represent temperature, salinity, speed, etc... – Derek Eden Apr 17 '20 at 19:29
• @DerekEden I now understand your second goal clearly. My (perhaps bad) guess is that the most straightforward answer will require some python scripting; at the least, an approach quite different than my answer above. Thus, you may want to consider posting your second goal as a separate question. Edit: Also, my pleasure! These are neat questions! – Jeremy Hilgar Apr 17 '20 at 20:30
• thanks, expect a few more over the next couple days related in some manner to this one :) much appreciated – Derek Eden Apr 17 '20 at 20:44
• if you are able to help... blender.stackexchange.com/questions/174943/… – Derek Eden Apr 18 '20 at 1:48

Following @Duarte advice for absolute positioning, combining 'Object Info' and 'Texture Coordinates', I hope I got it right :)

Don't forget to 'Apply Scale' after scaling your object. Also, check out the 'Max Value' and 'Min Value' nodes feeding the 'Map Range' in order to clamp to the desired Z locations.

• this looks promising as well, I will try this - between the two solutions I'll combine them where necessary – Derek Eden Apr 17 '20 at 20:41
• thank you!!!!!! – Derek Eden Apr 17 '20 at 20:42