Results 1 to 22 of 22

Thread: 3D Fractal Landscape

  1. #1
    Join Date
    Jan 2007
    Location
    Tennessee
    Posts
    642
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default 3D Fractal Landscape

    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)

  2. #2
    Join Date
    Feb 2009
    Location
    Irvine, CA
    Posts
    2,873
    Mentioned
    8 Post(s)
    Quoted
    138 Post(s)

    Default

    Aw no Simba? =(

    I looked at the youtube video, it looks like this fractal business has amazing potential.

  3. #3
    Join Date
    Jan 2007
    Location
    Tennessee
    Posts
    642
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    No simba =(
    With my last script I tried to make it into a simba script, but It's just a lot easier for me with scar.

  4. #4
    Join Date
    Feb 2009
    Location
    Irvine, CA
    Posts
    2,873
    Mentioned
    8 Post(s)
    Quoted
    138 Post(s)

    Default

    Quote Originally Posted by almost View Post
    No simba =(
    With my last script I tried to make it into a simba script, but It's just a lot easier for me with scar.
    What's missing? I'm guessing it's because you use a form.

    Also, you should take me to bandos some time soon

  5. #5
    Join Date
    Jan 2007
    Location
    Tennessee
    Posts
    642
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    It can be done there are just a couple minor issues with simba forms.

    And yes I would like to test out my new gear at bandos =)

  6. #6
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Yay now let's make a Simba/Scar RPG!

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  7. #7
    Join Date
    Jan 2007
    Location
    Tennessee
    Posts
    642
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    It shouldn't be too hard.
    I just need to think of a game where randomly forming terrain would be cool.

  8. #8
    Join Date
    Feb 2009
    Location
    Irvine, CA
    Posts
    2,873
    Mentioned
    8 Post(s)
    Quoted
    138 Post(s)

    Default

    Quote Originally Posted by almost View Post
    It shouldn't be too hard.
    I just need to think of a game where randomly forming terrain would be cool.
    SRLCraft! (Like minecraft, you know?)

  9. #9
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Quote Originally Posted by almost View Post
    Blah blah blah.
    Blah blah blah
    randomly forming terrain would be cool.

    Like randomly generated or randomly/constantly changing? (I hope the second option)

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  10. #10
    Join Date
    Feb 2006
    Posts
    3,044
    Mentioned
    4 Post(s)
    Quoted
    21 Post(s)

    Default

    I'm unable to get Form popup for those settings :S

    ~Home

  11. #11
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Great work, almost!!

  12. #12
    Join Date
    Oct 2006
    Location
    MI USA
    Posts
    3,166
    Mentioned
    6 Post(s)
    Quoted
    11 Post(s)

    Default

    Very Interesting


  13. #13
    Join Date
    Jan 2007
    Location
    Tennessee
    Posts
    642
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Like randomly generated or randomly/constantly changing? (I hope the second option)
    Either one.
    You could keep track of the heights and change them as it goes.

    I'm unable to get Form popup for those settings :S
    Did you move your mouse all the way to the the right wall of the form?
    Is the window maximized?
    What screen resolution are you using?
    If all else fails go to line 614 and set Panel.Visible to true instead of false.

  14. #14
    Join Date
    Feb 2006
    Posts
    3,044
    Mentioned
    4 Post(s)
    Quoted
    21 Post(s)

    Default

    Quote Originally Posted by almost View Post
    Either one.
    You could keep track of the heights and change them as it goes.


    Did you move your mouse all the way to the the right wall of the form?
    Is the window maximized?
    What screen resolution are you using?
    If all else fails go to line 614 and set Panel.Visible to true instead of false.
    Haha, i did all those Still no works. Is there something with my scar :P

    ~Home

  15. #15
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Which version of SCAR did you use, almost?
    I got 3.25 RC, and can't get it to work :/

  16. #16
    Join Date
    Jan 2007
    Location
    Tennessee
    Posts
    642
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    I'm using 3.21 but I'll get a newer version and check it out.

  17. #17
    Join Date
    Jan 2011
    Location
    Denver, CO
    Posts
    1,351
    Mentioned
    2 Post(s)
    Quoted
    72 Post(s)

    Default

    Quote Originally Posted by Flight View Post
    Yay now let's make a Simba/Scar RPG!
    It's been done before

    http://villavu.com/forum/showthread.php?t=33693

  18. #18
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    Quote Originally Posted by Echo_ View Post
    Brings back memories. :<

  19. #19
    Join Date
    Jan 2007
    Location
    Tennessee
    Posts
    642
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    I downloaded the newest version of SCAR I saw on Freddy's website (3.22) and it works fine

  20. #20
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Quote Originally Posted by Echo_ View Post
    Bleh. I think I like Almost's landscape much better.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  21. #21
    Join Date
    Apr 2007
    Posts
    3,152
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    he never even came close to finishing it. It wasnt even at the rpg point yet. This is cool. Though. Especially in the preview pictures, i totally thought that the trees and sky were pictures that you had copied. I totally thought that fractals were only useful for weird graphic abstract things.
    SCAR Tutorials: The Form Tutorial | Types, Arrays, and Classes
    Programming Projects: NotePad | Tetris | Chess


  22. #22
    Join Date
    Jan 2007
    Location
    Tennessee
    Posts
    642
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    The deeper you go the more applications you find for fractals.
    I'm starting to wonder what you CAN'T relate to a fractal.
    Also the sample pictures have squares that are maybe 4 - 9 pixels each, but a language like c could render a unique color for each individual pixel.

    So has anyone actually gotten the script to work yet?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •