x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How can I colour my terrain using a colour gradient based on the elevation?

Hi guys,

This question is rather simple, yet I haven't been able to solve it. I just want to colour my terrain based on its height using an rgb colour gradient. So higher places should be coloured red, lower ones green and even lower ones blue... I blended these colours as seen in the image and I probably have to use the absolute world position and extract the Z- value. Yet i just dont know how to link the colour to the height or even between certain height values. alt text

Product Version: UE 4.17
Tags:
gradient.png (130.0 kB)
more ▼

asked Mar 08 '18 at 05:29 PM in Blueprint Scripting

avatar image

BlueberryFox
13 1 3 10

avatar image Simsaladoo Mar 09 '18 at 02:43 AM

You'll need Lerp!
Use the blue output of world position and divide for color region, using appropriate amounts of +offset for every following lerp, plug one lerp into another lerp into another.

avatar image BlueberryFox Mar 11 '18 at 04:36 PM

Thanks for the reply! You mean i shall lerp each colour one by one with each other? And i plug the Blue output in a divide node which i will then plug into the alpha from each lerp?

avatar image Simsaladoo Mar 12 '18 at 12:44 AM

yup! so off of the same world position you can setup your offsets--for 6 colors youd have 6 subtract nodes with different values to separate the colors in the spectrum, following those a divide node with a value for the length of the fades, then each of those plugging into the alpha lerp.

there's possibly a more optimized way of setting it up, but that should work fine--Ive used this way to make sand wet along the waterline, and less brown as height goes up in a sand material.

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Here's a way to do it using a 1D texture lookup. You take the Z position, subtract the minimum height, divide it by the height range, clamp it in the range (0,1) and use that as UVs for your texture.

alt text

I don't know if BreakOutFloat3Components is preferable versus using a ComponentMask here; both allow you to pick out just the Z channel, and both yield the same stats, but perhaps one is more performant.

heightmapped.png (965.7 kB)
more ▼

answered Mar 12 '18 at 03:03 AM

avatar image

Gavin.Kistner
189 8 13 25

avatar image BlueberryFox Mar 12 '18 at 06:01 PM

This works perfectly! thanks very much for sharing :D

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question