[OpenGL] Terrain generation in OpenGL

Monovertex

Formerly Smith_S9
Reaction score
1,461
I have an assignment for college in which I have to generate terrain programatically and display it lighted and also be able to tessellate it. I generated my terrain through Perlin noise and also through the diamond-square algorithm (fractal). During this I encountered some bugs and some of them looked pretty sweet.

You can read and see more of this on my blog here (noise terrain) and here (fractal terrain).

Here are some examples:

2.png


5.png


8.png



And here is the correct fractal-generated terrain:

6.png


If you have any questions about terrain generation related to what I did here, don't be afraid to ask.

Extra info: this is built in C++, using OpenGL, GLEW, freeglut and a wrapper framework provided by our teachers.

I dislike C++, but the focus of this class is on the graphics themselves, algorithms and stuff, and trying to develop in something else would just waste time (learning how to use other libraries, no wrapper framework, etc). So don't give me a hard time about using C++ :D.
 

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,706
Interested in your source code, regardless of how buggy your code reads.

But I never realized that you had to use so many libraries in order to write OpenGL code using C++.

If your class is all about graphics programming, I seriously need to reconsider where I can learn more of this, unless I'm not good enough for it.
 

Accname

2D-Graphics enthusiast
Reaction score
1,463
You dont >have< to use GLEW and GLUT in order to work with OpenGL tom. But it adds a great deal of useful utility functions which you probably dont want to miss out on.
 

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,706
I know, but to mix C++ and OpenGL, you need extra libraries.
 

Monovertex

Formerly Smith_S9
Reaction score
1,461
Not exactly, tom_mai78101. I never tried to code straight in OpenGL using C++, but from what I know and read, you can do that. Only your code will be bloated as hell with low level calls.

Using these frameworks allows us to focus on the algorithms for terrain generation, for example, instead of how to instantiate and control the window, the events on keypresses / mouse moves, etc, etc.

I can provide the source-code, only it's a bit undocumented, as I usually do that when I'm finished. If you prefer, I can give it to you when its finalized, that way you'll have a working project to dig into and it's also going to have more features.

I've added fog and right now I'm creating a quadtree system, in order to create an infinite landscape and cull everything outside the fog cutoff. That way you can go as far as your RAM allows :D.

I don't think anyone can not be good for this. If you can understand vector and matrix math, then the algorithms are not a big deal. For low-level calls, I think you should definitely know the basics, to know what's happening in the backstage, but you should use utility frameworks to make your life easier.
Generally you can find all of this on the Internet, but it's fragmented. My advantage of learning this in a class is that someone collected the information and organized it, so we were able to learn faster.
If you want to learn OpenGL fast, then I recommend taking a course. However, you can also do it by yourself.

I can give you the PDFs of our laboratories (practical classes, as opposed to courses where there's theory only), but they are in Romanian :(.
 

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,706
Other than courses, do you have a list of textbooks that you're using to educate yourself with? Not recommendations from you, but actual textbooks used in your classes.

I can provide the source-code, only it's a bit undocumented, as I usually do that when I'm finished. If you prefer, I can give it to you when its finalized, that way you'll have a working project to dig into and it's also going to have more features.

Guess I'll be waiting for a while...

I can give you the PDFs of our laboratories (practical classes, as opposed to courses where there's theory only), but they are in Romanian :(.

Sad.
 

Monovertex

Formerly Smith_S9
Reaction score
1,461
Other than courses, do you have a list of textbooks that you're using to educate yourself with? Not recommendations from you, but actual textbooks used in your classes.

I'll be honest, I only went one time to the course (as opposed to the laboratories) and I have no idea what textbooks she suggested xD. I'll ask around and come back to you on this subject.

Guess I'll be waiting for a while...

No, the deadline is on Sunday, I'll finish today or tomorrow.

Our homeworks have 2-week deadlines, so what you see now I started last Sunday. I'm close to finishing it.


Yes, sorry about that :/. I'll see if the course slides are in English, not sure about that.
 

Monovertex

Formerly Smith_S9
Reaction score
1,461
And it's finally finished. Check it out:


Also, see the blog post.

@Tom, as soon as I finish documenting the code (I have to do that for the assignment anyway), I'll send you a link to get the source.

EDIT: Here is a GitHub repository with the source: https://github.com/monovertex/fractal-terrain. I'm providing this as is, with what will probably be minimal support. It's there just so other can learn something from it and it probably has downsides in optimization. If you're interested in the actual Visual Studio 2013 project, drop me a PM.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top