Help required with non-orthodox Terragen usage

Started by fhomps, June 05, 2020, 03:56:11 pm

Previous topic - Next topic

fhomps

Hello everyone,

I am working on a research project for my university and have been fiddling with Terragen for the past few months now. Admittedly, my project is quite weird and may not fit the software's standard usage: I am trying to generate a dataset of realistic pictures of Mars to train a neural network for terrain features detection.
I didn't want to spam the forum with beginner questions, and I think I now have a fair understanding of how Terragen works; still, I am now hitting big roadblocks on several fronts, and I hope you could help me solve them (or at least tell me if I am wasting my time trying to fit a square peg in a round hole!).

For a neural network to train successfully, you need to provide it with "solved" exercises: in this case, I need to give my NN standard pictures of terrain, but also those same pictures rendered differently in a way which explicits what the AI is supposed to look for. This is called a "ground truth". For example, if I were to train my network to detect rocks, I would give it images of this type:



Along with a ground truth of this type (this one I made by hand):



For this to work, I need to be able to render the scene with some elements in starkly different colors; if possible, with completely flat lighting, no shadows, no nothing. Just rocks in red and the rest in green.
Thus my first question: is this possible with Terragen? The closest I have gotten has been luminous surface shaders fed to my fake stones, but even then, no dice, there's still some (pretty!) shadowy effects.

Note that I could still do this with post-treatment of the images and identifying which zones are more red than green or black. This is however not the case for more complicated data; namely, I would like to train my NN to identify slopes. Thus my next question: is it possible to give the terrain a gradient of color (say, from blue to green) which would represent its inclination? For example, flat parts of the ground would be blue, while parts at, let's say, a 45° angle would be green, and parts at 22.5° would be cyan. I think I can achieve an unprecise version of this effect by merging surface shaders with different slope conditions, but I would ideally prefer having a continuous spectrum of color... And if slopes are not possible, altitude (not relative to the normals but to the Y axis) would be a good compromise too. I have been trying to achieve those effects with getAltitude shaders and a few math functions to emulate a linear interpolation, but no dice so far...

And so those are my three questions:
  • Are fully flat colours with not lighting achievable in Terragen?
  • Can you colour terrain according to its slope in a linear manner, using the aforementioned flat lighting?
  • Alternatively, is this possible in regards to the height of the terrain?

Apologies for the wall of text and for any mistakes in my English. Have a good day!

N-drju

As a matter of fact, you can turn the shadows off for every light in the scene as well as for individual objects.

Distribution shader is what you need to set slope and height limits. Afterwards, you can color them in any way you wish.
"This year - a factory of semiconductors. Next year - a factory of whole conductors!"

KlausK

Hello fhomps, first of all: your project doesn`t sound weird at all. Quite interesting, actually.
Second: welcome to the forum! Don`t worry about your English. There are a lot of non-native English people here.
Third: just ask anything TG related - there is almost always someone here willing to answer.

That said, have you looked at "Render Layers" ? Perhaps they might help...

On the "Render" tab you`ll find the "Render layer". Click on the green "plus" button and choose "Create new Render layer".
The text field now reads "Render layer 01". Click on the green "plus" button again and choose "Go to "Render layer 01"".
This will open up a new property window with all Layers and Render Elements and more you can render out as separate picture files.
You can set up groups of objects, lights, if shadows are rendered, hide stuff from the renderer, set clipping distances.
Turn of clouds and atmosphere hide surfaces and more. Depends on how your scenes are build to a some degree what you can get out of it.
At least that kind of setup might simplify the post-work if nothing else works.

To render out the "Render layers" and all the single elements you need to set that up on the "Render" tab - "Sequence/Output" tab as well.
Turn on "Extra output images" and for ease of use "Create subfolders" (which creates a folder for every extra image rendered out).
Then you need to use "Render All To Disk" (I think) to render the extra images out. Else only the beauty/final pass will be rendered (I think).

Good luck and please let`s see some wip as you move on.
CHeers, Klaus
/ ASUS WS Mainboard / Dual XEON E5-2640v3 / 64GB RAM / NVIDIA GeForce GTX 1070 TI / Win7 Ultimate

Hannes

If I understood correctly, what you want to do, I'd say, it's quite easy.
If you have your scene the way you want, disable all atmospheres, sunlight and environment light, and go to Renders/GI Settings. Use a value of 0 for GI cache detail and GI sample quality, because you don't need to have GI here. Thus it renders faster.

Then assign a shader (default shader or surface layer, doesn't matter) to your terrain, and use the color you want for luminosity. In the default shader it's recommended to use a black base color, and in the surface layer turn off "Apply color", if you use self illumination i. e. luminosity.

Do the same for a fake stones shader.

If you want different colors for your terrain depending on slope or height, put a surface layer with the chosen color for luminosity behind the first shader, that colors your terrain, and adjust the altitude- or slope constraints.

You can also mask the second color by other shaders. The distance shader for example (see second image).

Hannes

...and welcome to the forum of course!!!! ;)

KlausK

Why didn`t I think of that?!? haha :P

Thanks Hannes...so, that`s how you do this kind of stuff.
CHeers, Klaus
/ ASUS WS Mainboard / Dual XEON E5-2640v3 / 64GB RAM / NVIDIA GeForce GTX 1070 TI / Win7 Ultimate

fhomps

Well, that was quicker than expected!

Thank you very much for the infos. I've managed to generate a nice ground truth for the rock positions:



As you can see, it looks perfectly similar to the hand-made one. Success!

I am working on implementing Hannes' suggestions regarding the slopes. Right now it's... halfway there. The problem comes from the fact that I haven't found a way to properly separate the displacement shader that I apply on the boulders from the ground itself, and thus there are tiny slopes everywhere. I'll try fixing it tomorrow with merge shaders and a hammer, and come back to you if I fail.



Thanks again - you guys are brilliant!
I'll be sure to put your names in the "special thanks" part of the paper once/if I get there ;)

Dune

To get rid of the smaller slope restricted areas like in your example, be sure to use terrain normal instead of final normal.

Hannes

Be sure, that you apply this small displacement ONLY to the fake stones. It shouldn't appear on the basic terrain.

fhomps

Quote from: Dune on June 08, 2020, 04:13:42 amTo get rid of the smaller slope restricted areas like in your example, be sure to use terrain normal instead of final normal.
That did it, amazing! I thought I'd have to get rid of the small terrain displacement (pebbles and the like) altogether...



It just leaves me wondering what Terragen considers the "terrain" is - according to the wiki it's supposed to be what's computed at the last Compute Terrain, but I tried putting another one after the displacements and found no changes. Weird, but it works for my purposes.

Quote from: Hannes on June 08, 2020, 09:33:24 amBe sure, that you apply this small displacement ONLY to the fake stones. It shouldn't appear on the basic terrain.

I have been trying to do that for a while now actually, in various different ways, with no clear success.
  • If I use the displacement as an input in the "surface shader" slot of the fake stones, the stones' normals are not yet calculated and the result looks wonky;
  • If I use it after the fake stones (and a Compute Terrain), it gets applied to the terrain that was before the fake stones too;
  • If I use it after the fake stones and try to mask it using the fake stone's output, the effect appears to be reduced on the terrain but it's still there, which is weird to me... I searched the forum and someone said to use a distribution shader before the mask but this does not seem to work either.
  • I also tried having no main input to the fake stones, applying the displacement afterwards, then merging with the "main" terrain branch, but this apparently screwed up my heightmap and the terrain had a different altitude all of a sudden.
I think I might be missing something here ^^'. Is there a "standard" way of applying displacement only on stones?

I really should have posted here sooner, I feel like I made more progress in 3 days than in the last 2 months... Thanks again.

Dune

That's it, it takes the normals of the computed terrain, which, with a patch size of 20 is quite soft. If you decrease the patch size to say 1 or even smaller, the small slopes will be more apparent. If you up it to 100 it'll be really soft.

Fake stones have an internal sort of computation to get it to displace laterally as well, so the best way is to add any displacements only to the surface input. But if it gets wonky, work on sizes. For a stone of 1m, max size should not be much larger than 1m. displacement not much more than that either, and you can use an offset (smaller even) to blow the stones up a bit. But don't overdo it.

fhomps

Hello everyone,

A lot has happened since my last post!

Mainly, the focus of the project has shifted a bit. I am now concentrating my efforts on terrain viewed from above, from a flying lander's perspective. Also, looking at pictures from the HiRISE project, I have realized that creating renders of "Mars" is... completely futile, seeing the diversity of the terrain. As such, I am focusing on specific regions, and this has made making progress much, much easier.

But I know what you all want. You want pictures!

Here is a render, in Terragen, of the actual elevation map from the Mawrth Vallis crater (which I found on HiRISE). No atmosphere, no ground coloring, just the terrain.


And here is my entirely procedural terrain render, with the same lighting conditions:


I am super happy with the results! I based my craters on a forum post from here (...which I can't quite find again, for some reason), with some heavy modifications to make them more realistic. If anyone wishes to use them, I've linked my project file. Open-source or bust!

On a side note, I find the blue function nodes so much easier to use than shaders. They do exactly what you want them to do, and have well-defined input and output types - as a programmer, this is much more familiar territory.

I would greatly appreciate any criticism! Now, onto ground colors & atmosphere and I'll be good for a 5000 pictures-strong render session. Lots of fun in perspective.


Have a nice day.

cyphyr

When I was working on the Mars environments for Ad Astra we used both Terragen procedural terrains and tiles made up from HiRise data combined together.
Feathering out the edges of the HiRise height maps and zeroing their relative height gives you the ability to effectively "stamp" real Mars terrain data ontop of procedurally created terrains.

The biggest issue I faced was finding a way to get rid of the scan bands in the original data. The later HiRise data sets are cleaner but the earlier ones suffer from lots of issues and missing data.
www.richardfraser.co.uk
https://www.facebook.com/RichardFraserVFX/
/|\

Ryzen 9 3900X @3.79Ghz, 64Gb (TG4 benchmark 6:20)
i7 5930K @3.5Ghz, 32Gb (TG4 benchmark 13.44)

WAS

Quote from: cyphyr on July 01, 2020, 10:12:31 amThe later HiRise data sets are cleaner but the earlier ones suffer from lots of issues and missing data.
Boy do those earlier ones do. Some of them are really bad and don't even do imager examples justice.

Also, great share. We can always use cool project shares.

mhall

Quote from: cyphyr on July 01, 2020, 10:12:31 amWhen I was working on the Mars environments for Ad Astra
Nice how you just casually dropped that ... ;D Very cool!


And nice results on the craters fhomps! It's not often people drop by and say how much they like the blue nodes ... If you feel like expanding the documentation on any of them, or provide good examples of their use, feel free!