View Full Version : Another Wilbur Question

Greason Wolfe
03-18-2010, 01:36 PM
I've been experimenting with the math function, and having a bit of success, which doesn't particularly mean anything at this point. More specifically, I've been looking at the function defined for creating islands and, in turn, trying to figure out if there is a way to create craters along the same line, i.e. with that random shape rather than being perfectly (or near perfectly) round and with an increasing slope steepness towards the rim. I've wracked my brain on this, but, sad to say, I'm not much of the programming type (save for a little html and javascript), so if anyone has a clue how I might go about this, it would be great.


03-18-2010, 04:37 PM
Have you tried the crater() function in Wilbur? It generates perfectly round craters, but applying it to an existing random field with a multiply operation will give you something like what you describe (see attachment). If you want the rim distance to wander a bit then I'd have to put back in the fbm function that you could use to modify the crater function argument.

Internally, the crater() function looks like

if (arg <= RimDist)
return pow((sin(1.5*M_PI+arg/RimDist*M_PI)+1)*0.5,BowlSteep)*(RimHeight-BowlBase)+BowlBase;
return (1-(arg-RimDist)/(1-RimDist))*RimHeight;

A wilbur function that does the same should look like
if (le(arg,RimDist),pow((sin(1.5*pi+arg/RimDist*pi)+1)*0.5,BowlSteep)*(RimHeight-BowlBase)+BowlBase,(1-(arg-RimDist)/(1-RimDist))*RimHeight)
with appropriate expressions substituted for the named arguments (for example, arg replaced with r/4, RimDist replaced with 0.5, and so on).

Greason Wolfe
03-19-2010, 10:22 AM
Much appreciated waldronate (and look, I spelled it right this time!!!). I was going through the documentation last night at work and may have come up with another solution as well, based on a selected area. I'll give both a try and see which one works out the best. The ultimate goal is to create an open cavern of sorts with some roughness in what would be the "bowl" area. If the solution I came up with last night works out well, I'll be sure to forward it to you, or post it here for reference.


P.S. Is there an easy way to clear out unused formulas in the math function area of the Calculate Heightfield dialogue, or am I stuck with a list that keeps growing and growing and growing . . . .

03-19-2010, 11:00 AM
The list should stop growing at 16 items.

Greason Wolfe
03-19-2010, 12:35 PM
16 Items, Aye.

As a brief update, the function I came up with last night works almost exactly as I had hoped it would. Unfortunately, it is wholly dependent on a series of selected areas and a progressive series of iterations. I'm just not seeing any way to create it as a generic function, and I'll post it in a bit, if you are interested in playing with it. I just need to define a few variables (in words) such that they make sense.


Greason Wolfe
03-19-2010, 02:03 PM
As promised, here's the function I came up with;



M(aximum)D(esired)H(eight) is equal to the the user's desire
M(aximum)R(adius) is equal to the pixel distance from dead-center to the furthest possible point
E(levation)A(djustment) is the largest prime factor of MR that halves with each progressive iteration of the function.

* the extra "+1"s are to ensure that the curval is raised by at least 1 unit with each pass of the function

The idea is to create a crater-like effect of which the rim shape can be defined by the user as a selection mask. Unfortunately, to maximize the effect requires that both the selection mask and math function be re-defined by the user with each progressive application. It's not very pretty, it's probably more complicated than it needs to be, but, with the bare minimum experience I have in "programming," I'm fairly pleased with myself for coming up with this solution. Heck, I might even write up a tutorial on it, if you're interested in adding it to the growing number of tutorials on the Wilbur software page.

I've included before and after renders by Terragen as an example of the results. I only went through 6 iterations and applied way too much blur between iterations, so the results aren't particularly easy to see unless you view the images side by side at full size, but it should give you a good idea of where I'm headed with this.


Bah, just ignore the explanation of those variables, I fudged something in trying to convert it to an explainable format. As soon as I straighten things out, I'll edit both the function and the explanation.

Greason Wolfe
03-19-2010, 04:34 PM
Okay, let me try this again, and, hopefully, it will make more sense . . . (yeah right :D )

As promised, here's the function I came up with (with the values I am applying);


In more of a variable defined format, it looks something like this;



MDH - Maximum Desired Height (defined by user)

MR - Maximum Radius (from dead center to furthest point, rounded to nearest even value)

LPFMR - Largest Prime Factor of Maximum Radius (optimally should be 1/16th of MR)

SA - Slope Adjustment (used to bring up the result of LPFMR/MR to the nearest value below 1)

EA - Elevation Adjustment (used to create more aggressive elevation additions, increases with each iteration, starts at a value of 1)

Now I'll do my best to explain what I've done.

I've nested one "if" statement in another.

The inner "if" statement compares the intended replacement value to the maximum value as defined by the user. If the replacement value exceeds the maximum desired value, then the point is set at the maximum desired value. Otherwise, it is set at the replacement value.

The outer "if" statement does almost the same thing, but bypasses the inner "if" statement if the current value of the point is already at the maximum desired value.

The replacement value is calculated as a factor of the radius at the given point as compared to the maximum possible radius of the terrain as a whole. With each iteration, the replacement values should get increasingly aggressive to the point that we end up with vertical (or near vertical) slopes. By using selection masks, we can further control where the values are replaced and, in effect, create crater or plateau-like effects of nearly any shape with a little bit of patience. Since Wilbur doesn't have a loop function (that I can tell, anyhow), this function is wholly dependent on using selection masks to control where the replacement values can occur, and seems to work best with series of increasingly larger or smaller selections with each iteration.

There is probably an easier (read that as cleaner, less complicated) way to implement this function, but I'll leave that to your professional consideration, as I am quite the amateur with this whole function/programming thing.


03-20-2010, 11:18 AM
Wolfe, that shot on the left looks amazingly like real rock or dirt.!! If you looking for something subterranean, I think you nailed it there. The "walls" even look like sheared stone. :)

Very well done. Have some rep for:
A - Producing a shot like that
B - producing the code to do it :) (my HTML and Java is no where near understanding it ;) )

03-20-2010, 04:07 PM
What would this look like from an overhead perspective? The side shots look an awful lot like the sort of step that happens by clipping inside or outside a mask. When I tried to use that expression on a surface, I got everything above 128 showing as Not a Number (-1#IND) and everything below 128 as the original value.

I'm still unclear what you're really trying to get here. One way to make a crater with an arbitrary rim is to:

Draw a selection to represent the rim shape. I used a squarish one so that it would look vaguely like the one in Arizona.
Fill that selection with a mound (Filter>>Fill>>Mound) where the Maximum is less than the minimum. I used 10 for minimum and 0 for maximum.
Apply an exponent to make the crater more bowl-shaped. Filter>>Mathematical>>Exponent with the exponent set to 4 will work.
Invert the selection to work on the outside (Select>>Inverse)
Fill with a mound (Filter>>Fill>>Mound) where the Maximum is less than the minimum. The minimum should be the same as the original fill. I used 10 for minimum and 5 for maximum.
A small exponent here might work as well. Filter>>Mathematical>>Exponent with the exponent set to 1.5 is a good starting point.
Deselect (Select>>Deselect).
Apply an overall bit of noise to make things rougher. Filter>>Noise>>Fractal Noise with an amplitude of 3 and Operation of Add.

Greason Wolfe
03-20-2010, 11:05 PM
@ Korash - Thanks, the sheared stone look is what I'm going for, just trying to tweak the lower levels of the shear to make it slightly more gradual. As for the code . . . to be honest, I'm not really sure what I'm doing either, but I'm giving it my hack-n-slash best. :D

@ waldronate - That explanation almost hit the spot. Let me try to better explain what I am trying to achieve.

I've used your island tutorial (for wilbur) to create an island. I now want to turn the land area of the island into the basin/bowl of a crater (could also be thought of as a cavern floor or even the end result of a caldera collapsing) by turning the water results into quickly steepening land that, in some areas, looks sheared as well. I realize, now, that my function was, to be brutally honest with myself, poorly crafted as I included specific numbers based on the terrain I was working with. But I think the way you explained it there, might have me on the right track. I think, though, that I need to start at the second step as I already have the first step done, theoretically. Once I have the bowl shape along the inner edges of the rim, I can use the Filter>>Fill>>Set Value to flatten the area beyond the rim at the height of the rim, and maybe even add a little bit of that sheared look that I'm trying to achieve. I'll give it a shot and let you know how it goes.

Thanks BUNCHES for all the help.


Okay, here's a sample area of what I'm working with. As you can see, there are some areas of rising elevation that butt up against the walls. These areas aren't the real "problem." The "problem" is in those areas where the wall meets the lower floors of the terrain, creating, for the most part, a right angle between floor and wall. These areas, I'd like to give these areas a slight bit of curvature and haven't really had much luck yet. I tried the method you recommended above, but, for some reason, when I apply the Fill>>Mound method, it fills the entire area with a single value. Anyway, I hope this better illustrates what I'm trying to do.

03-21-2010, 04:11 AM
OK, try this (attachment 1, 4):

Generate a basic terrain by Filter>>Noise>>Fractal Noise with amplitude 100. This way the terrain goes from 0 to 100.
Draw your cliff edge selection.
Filter>>Fill>>Mound with minimum height of 0, maximum height of 2500, and Operation of Add.
Filter>>Height Clip with min of -1 and max of 150. This change will give you steep slopes from the terrain up to 150.
Select>>From Terrain with minimum 150 and maximum 1000 to pick just the upper plateau.
Select>>Deselect to hide the selection.
Filter>>Erosion>>Precipiton-Based with the default parameters to round out the bottom edges of the cliff. Do this again as much as desired.
Select>>Reselect to get your flat upper area selection back.
Filter>>Fill>Set Value with a value of 150 to return the upper area to its flat state.
If desired, Filter>>Noise>>Fractal Noise with Operation Add to get a little interest in the upper part.

Alternatively (attachment 3):

Start with a blank terrain.
Draw your desired edge.
Filter>>Fill>>Mound with Minimum 0, Maximum 10000, click the Edit Profile button, enter 2 for non-linearity, click apply, then OK and OK again to generate an exponential blend between the low and high portion.
Filter>>Height Clip with Min=0, Max=100
Select>>Deselect to hide the selection.
Filter>>Noise>>Fractal Noise with Operation=Add and Amplitude=100.

In the last image (attachment 2) I downloaded a simple maze from http://www.billsgames.com/mazegenerator/ and applied the second technique to it followed by some cheight clipping.

Greason Wolfe
03-21-2010, 07:52 PM
Ahhhh, that, very much, resembles what I'm looking for. I'll give this a shot once I've had a decent amount of sleep, and can actually read the steps without my eyes going all buggy on me. Thanks again, the help is very much appreciated.


Greason Wolfe
03-22-2010, 09:13 AM
So I gave the first method a shot and the results weren't bad, pretty close to what I am looking for. Then I tried it again, using a slightly larger selection for the Mound Fill and ran several rounds of precipitation as well as a bit of incise flow across the whole terrain. Then I applied a slightly smaller selection and ran another few rounds of precipitation to smooth things out just a bit and got even better results. I'll post them shortly, but I think, at least for now, this is as good a "firing solution" as I am gonna get.


Okay, added a couple images here. Image 1 is the top-down view from Wilbur. Image 2 is the Terragen render of the area "circled" in red on the first image.

03-22-2010, 01:16 PM
Heh! I think you have the beginnings of a model for Alan Dean Foster's Horseeye.