Many months ago I made a fractal drawer and said I was going to work on trying to create one in 3D.
I guess this is what I've got so far.
This script will generate a dynamic 3D landscape. The land, water, clouds, and trees are all made completely from a fractal algorithm.
The code attempts to recreate mother nature, so you will never see the same landscape twice (when rendered in a high detail)
Here are a couple pictures from a certain set of settings, but the possibilities are totally infinite - http://s200.photobucket.com/albums/a...el/Landscapes/
How to use Fractal Landscape
The script was made to adapt to 1024x768 or 800x600 screen resolution (haven't tried any others)
The settings will pop up when you scroll your mouse to the right side of the form.
Here is a rundown on the settings -
Land
Height controls the maximum/minimum heights of the valleys/mountains.
Smoothness controls how jagged/smooth the terrain is.
Detail controls how many individual squares the landscape is made out of.
The number of "squares" to draw is ((2 ^ Detail) + 1) ^ 2
The numbers get big FAST so be careful not to freeze your computer.
5-6 detail is good for testing purposes, and 7-8 is good for a quality rendering.
Sky
Everything in the "Sky" tab works about the same as the land tab.
Height will have a lot to do with how many clouds and how big the clouds are.
Roughness controls how smooth/jagged they will look.
Detail is the same.
Light
Contrast is how much the angle of the square matters in determining its shade.
It is actually a measure of... whatever the opposite of contrast is.
The higher number the more smoothly colored it will be, and the lower the number the more you will see darks/lights.
Intensity is simply how bright everything is.
"Glow under sun" means that it will draw a glowing spot directly underneath wherever the sun is. This is just used to show where the sun is in the "3D world" since it is 2d and can be hard to tell.
By default the sun starts above the middle of the land.
Trees
These can get interesting.
The default settings are quite random, so you may end up with things that don't look much like trees sometimes =P
Detail is how many "generations" of branches to draw. 4 is usually a good number.
Trees is just how many trees to draw.
Branches is how many branches to start out with for the first generation.
Angle is the angle the branches are at. -45 to +45 keeps them pointing upward. 0 to 360 would mean the branches could be pointing in any direction.
Length percent is how long each branch is compared to the branch it is coming off of. 100% would make every branch the same length, 50% would make each branch half as long as the one it is connected to.
Height percent is how far up the branch to go before splitting off into another branch. 100% would make a branch at the end of every branch.
Water
Invisible water means that the water will not be drawn flat, and instead it shows what the land looks like underneath the water.
Sea level is just a height number and the script basically says if it's above that color it green, else color it blue.
Other
Color is self explanatory.
Wire means to draw black around each square.
If you turn color off and wire on you get a wire looking structure.
How it works
None of this is necessary to know to run the program.
It's just for if you are interested in how it works.
Land
The land is generated using the "diamond square algorithm" to create a height map, then the heights (y values) are applied to a grid of squares laid out across the x, z plane.
Sky
The same algorithm is used but instead of creating a height map it creates an "opacity map"
Each square gets assigned an opacity, then that opacity is applied to the color white on top of the color blue.
The more opacity a square has the more blue you will see.
Light
I've been playing with light for a while trying to determine angles in 3D space and this is what I've come up with.
It's not perfect but I haven't found any help or tutorials on this.
You take each square and get its "horizontal angle" and its "vertical angle".
Then you find the center of the square and get the horizontal/vertical angle between that point and the sun.
Now compare the Light's vertical/horizontal angle to the squares vertical/horizontal angle.
The closer the angle is to 90 degrees (perpendicular to each other) the brighter of a shade you will get.
SCAR Code:Luminance:= StrToInt(Intensity.Text) - (Abs(90 - (LVAng - VAng)) / StrToFloat(Contrast.Text)) - (Abs(90 - (LHAng - HAng)) / StrToFloat(Contrast.Text));
Trees
Trees are generated using something called an L-system.
You take a line and then draw lines off of that line.
For every line you draw you determine the 3 "rules" that tell you how to make that line -
The angle of that line off the parent line, how far up the parent line to branch into the new line, and how long the new line is compared to its parent line.
Then apply this rule to the new line created, which creates more lines, then apply the rules to those lines, etc.
Here are some pics of fractals I made by making the tree settings a bit crazy - http://s200.photobucket.com/albums/a...ikel/Fractals/
And that's about it.
Now I'm going to begin turning this into c++ and trying to make a whole fractal planet.
I believe fractals have very high potential for being the future of gaming graphics.
Imagine a game where every time you load a level it looks different.
Levels could create themselves, with only a couple predetermined factors.
I think this is where you stop trying to make graphics LOOK more realistic, and make them BE more realistic.
Also the graphics can be insane... the resolution when using a fractal is infinite.
My script doesn't exactly show the potential, but after watching this video, mind = blown. http://www.youtube.com/watch?v=ggLYTGLS1tk
That is an entire dynamically built planet using fractals (you will see at the end)

