Planetside Software Forums

General => Terragen Discussion => Topic started by: jubuttib on September 28, 2009, 07:46:54 pm

Title: A complete newbie humbly asking for assistance with masks
Post by: jubuttib on September 28, 2009, 07:46:54 pm
(Having trouble posting this thing, I hope I didn't accidentally do a triple post, or worse...)

Hello folks. I'm new to the forums and very new to Terragen 2, only been using it for a few days. I've learned a lot and continue to get better, but there still are things I can't wrap my mind around.

For example masks. At the moment I'm trying to create the island where our RPG adventure is located and I'm having trouble. I have the outline of the island as a black and white 8-bit bmp image (included, though in another format for bandwith reasons), and would like to be able to generate a power fractal terrain and limit it using the image as a mask, so that the world is completely flat, except for the white bits. I've tried to add it as an image map shader (saw it somewhere on the forums, I have been trying to figure this out on my own =), but that gives me really weird results, not to mention taking WAY much longer to render (usually it's done in under two minutes, with this it takes around an hour, at least). I've attached one picture of what happens, taken mid-render. Note that I haven't done anything to the default colors, I have no idea where those black regions on the mountaintops in the render come from. I've been searching through the forums but either I just can't find it or I don't know the terminology well enough to search for the right keywords. Could someone point me to a step-by-step solution or at least give me some pointers, I'm really strugling with this thing?

PS. I've tried alternative ways to accomplish this and I've had limited success using the following procedure:
1. Use the image as a normal heightfield.
2. Add "Adjust vertical" operator to the heightfield and use it to raise the ground up a few hundred meters.
3. Add a power fractal terrain to get some shape.
4. Add a lake node to act as the ocean. Raise it so the coastline is somewhat ok, then fiddle with the displacement offset of the fractal terrain, trying to get rid of the almost inevitable "lakes" that form because the fractal terrain generates values under 0.

With this I run into a few problems. One is that raising the displacement offset often also raises the coastline, which makes adjusting the water level pointless. What I need is a way to force the coastline to stay at a certain predetermined level and everything inland to be above that level. That and I still have no clue how to control where the water is, one of the tutorial did mention that it can be masked so it doesn't appear where you don't want it to.

Second is scaling. Of course I can make it small and just adjust everything accordingly, but if I want to make it 1:1 scale, then we run into problems. The island is quite large, around 500 by 550 km or something like that, and resizing the heightfield to those proportions causes pretty horrific effects, since the heightfield doesn't follow the curvature of the planet. So at least some edges look horrible, usually all.

And lastly (and this is more because of me not knowing how to use the software than anything else) the shape of the terrain. Most of the island is pretty much your average rolling hills and stuff like that. No problem, I can create that easily. This being an RPG-game though there have to be mountains and whatnot in some places. And like I've said before, I have no idea how to control where these appear. I know how to make decent mountains, but how can I limit where they appear? The mountainous areas on the island are marked on the map I'm using as a source, so I can easily trace the outlines and make masks of them, equal in size to the main island mask if necessary. I just don't know how to use the mask to control where the mountains appear.

Oh yeah, I just remembered something. The various villages and towns have already been placed on the map and, unless I'm seriously lucky, most of them will end up in places where no sane human would build a town. How would I go about leveling out some areas of the map so that they'd look at least vaguely habitable?

I'm sorry if this is a bit too much and I've broken every etiquette rule on the forums, but I really have tried to look for what I need and am just unable to find answers or understand them if I do find them. If I can provide other information that will help then please do ask.
Title: Re: A complete newbie humbly asking for assistance with masks
Post by: Henry Blewer on September 28, 2009, 08:21:47 pm
Can you make a greyscale image of the island. It can be used to generate the hills and mountains. 256 shades of gray would give the start of a great landscape. The highest parts would be white. If it comes out reversed, the image can be inverted.
Title: Re: A complete newbie humbly asking for assistance with masks
Post by: jubuttib on September 28, 2009, 08:36:53 pm
That is a possibility, though it would require an artistic touch, which I unfortunately lack. If I could just use masks to control where to apply different fractal terrains then everything would be set.
Title: Re: A complete newbie humbly asking for assistance with masks
Post by: cyphyr on September 28, 2009, 10:12:17 pm
Err there's an etiquette rule here ? Your fine :) People say all kinds of stuff here.
Welcome to the forum
You've asked a pretty big question there touching on issues I think we've all wrestled with. Have a look at the planet building posts, these often deal with issues about lakes and islands always appearing along coastlines and adding different types of terrain. If your not too far committed down your project might I also suggest a different approach. Rather than start with a map and try to get your terrain to conform to it, create a believable island or continent and make your map from that. (using an orthographic camera several hundred miles up) Then you can place your towns and features in sensible places. If that's a useful approach then I uploaded a "procedural planet creator (http://forums.planetside.co.uk/index.php?topic=7231.0)" you might like to delve into. Its quite complex but nothing too much, look in some of the internal nodes (prefixed with a "+") for an idea of whats going on.
If its not a useful approach then you might have better luck with something like GeoControl (http://www.geocontrol2.com/e_index.htm) that allosw much better terrain generation control. Then you could export the height maps back into terragen and render.
Hope this helps, good luck.
:)
Richard
Title: Re: A complete newbie humbly asking for assistance with masks
Post by: Henry Blewer on September 28, 2009, 10:31:04 pm
There is the 'blend by shader' at the bottom of the heightfield generator. Use an image import. I downloaded the alpha image. When I get the test render done I am currently working on, I'll see what I can do.
Title: Re: A complete newbie humbly asking for assistance with masks
Post by: Henry Blewer on September 28, 2009, 11:44:49 pm
Here is what I did. I applied your alpha image to the heightfield shader by using 'blend by shader' and an image shader. You can alter the coast by using the border blending slider.
The heightfield is generated randomly using the height field generate operator. I hope this has helped you out. Happy rendering!
Title: Re: A complete newbie humbly asking for assistance with masks
Post by: Oshyan on September 29, 2009, 01:24:20 am
At that scale you'll want to use a procedural terrain to fill the outlines of your continent/island. You'll also need to use an Image Map shader so you can use it to mask with (not a heightfield shader), and this also fortunately allows you to use different projection methods that can wrap around the planet better.

I've gone ahead and created a simple scene using your image to mask a procedural terrain. It's attached to this message, and assumes that the image file is in the same folder as the TGD. Take a look and you should be able to understand how to get the basics of what you want. I have used the Alpine Shader because it's easier to avoid negative displacement with it, and I'm using altitude to control your water level. The Alpine Shader creates nice mountains, but obviously if you don't want your whole continent to be mountainous, you'll want to change that.

Creating variation within your island continent will be the biggest challenge, and a lot of others (Nvseal in particular) have done a great deal of work in that regard. Nvseal is working on a commercial (inexpensive) procedural planet pack that, used in combination with your mask, might be ideal.

To get flat spots, you can try using a painted mask for the flat/town areas, the same size as your island continent mask, with the flat bits placed appropriately. Then you'd use that with a Merge Shader to blend between the normal displaced Power Fractal terrain and a smoother, flatter (or completely flat) one. The only issue then would be having incorrect altitudes for the flat bits (imagine a big plateau where your town should be for example). You could try to manually adjust each of these with a Displacement Shader controlled by a Painted Shader, but each one would have to be done individually because the altitude may be higher or lower than you want. This is not by any means the ideal way to do it, it's just "quick and dirty". Hopefully others will chime in with better workflows for the town flat spots, but I've given you a start on the rest at least. :)

Edit: I *knew* there was an easier way that I was overlooking. I just realized that you could use a Power Fractal and just not use altitude to define your water area. Instead use an inverted version of your island mask. There will be negative altitudes inland (Earth has these too, though there would be more in this case), but hopefully not too much near the coast or it would look bad. You might be able to help with this using the coastline adjustments in the Power Fractal Displacement tab.

- Oshyan
Title: Re: A complete newbie humbly asking for assistance with masks
Post by: jubuttib on September 29, 2009, 04:13:38 am
Thanks everyone for your quick answers. I just got out of bed (it was actually around 4:00am here when I posted the question) and I'll look through the files if I can learn anything from them.

@cyphyr: We've already played 6 sessions there, I think we're past the point of being able to retcon the whole island. I actually suggested this myself knowing that it'd be the easiest way to solve the problem. =)
Title: Re: A complete newbie humbly asking for assistance with masks
Post by: jubuttib on September 29, 2009, 04:57:05 am
I've made considerable headway, seems that the major thing was that I was plotting the mask "Through Camera". Plan Y helped with that. I've got to the point where I have a landmass that's got some very large scale shapes (I used the Large Scale figures from In-depth: Terrain and water tutorial, will adjust them if necessary) and some rolling hills on top of them, everything pretty subtle. I'm currently working on a mask for the mountains and after I finish that I'll try to add them to the island, I think I've got a pretty good idea how that's going to work. Going to post some renders and perhaps the tgd-file if anyone is interested.

The coastline is under construction, some coastal regions were underwater, so I just masked the water. I'll look into that later. Btw, how does the Adjust coastline bit under Displacement work, what does it do excatly?
Title: Re: A complete newbie humbly asking for assistance with masks
Post by: jubuttib on September 29, 2009, 07:11:54 am
I'm starting to like what I've got at this point, so here's a quick render (still very much WIP though). Parts of the coast are blurry because I've masked the water so it won't show up on the land, and parts of the coast are actually below the waterline. Also included a pic where the water is not masked.

I think that aesthetically I like the water filled one more, it has more of an island feel to it. I think I'll save it for another, later project.
Title: Re: A complete newbie humbly asking for assistance with masks
Post by: jubuttib on September 29, 2009, 07:28:58 am
Seriously, for the next update I want a tickbox for the procedural terrain that says "only generate values above 0". Seriously.
Title: Re: A complete newbie humbly asking for assistance with masks
Post by: Henry Blewer on September 29, 2009, 07:37:50 am
There is a clamp function which will do this. I think it is clamp scalar, but I'm not good using functions yet.
Another way is to use the offset in the power fractal. It's right below the displacement size/scale. The offset will let you raise the height of the powerfractal, so the parts that are below 0 can be adjusted to a height which is acceptable.
Title: Re: A complete newbie humbly asking for assistance with masks
Post by: jubuttib on September 29, 2009, 08:02:31 am
Won't that also raise the parts that are just right at the moment?

I'll look in to the clamp function, that might be what I'm looking for.
Title: Re: A complete newbie humbly asking for assistance with masks
Post by: Tangled-Universe on September 29, 2009, 08:36:01 am
In the powerfractal settings, doesn't the "clamp below black" and "clamp above white" functions do this already?

post below is way more useful :)
Title: Re: A complete newbie humbly asking for assistance with masks
Post by: dandelO on September 29, 2009, 09:50:52 am
You should try Matt's, beautifully simple, terrain clamp function set up that I came across just a couple of days ago... http://forums.planetside.co.uk/index.php?topic=7548.msg80786#msg80786

Just as Matt has used it to cut off the peaks of the hills, you can also use it to stop displacements beneath a set level.
Instead of using the 'clamp scalar's' maximum input, use its minimum input and set the constant scalar to '0'.
No displacement will happen lower than that then.
Title: Re: A complete newbie humbly asking for assistance with masks
Post by: jubuttib on September 29, 2009, 11:14:05 am
Thanks again everyone. I've been looking around for stuff on the clamp, and it seems to fit the bill perfectly. I'll try to work it in.

@dandelO: Yeah, I found that and started to play with it actually. It really is beautiful in it's simplicity.

@Tangled-Universe: I thought it was odd too, then I had an epiphany. Even if it limits the values at 0 or above, it's not enough. If most of the coast is at, say, 10 meters and I set the water level to 9 accordingly, then values under 9 will be underwater. And if I set the water level to 0, then that doesn't really work. So I need to limit the values to about 9 and over for this thing to work as it is.