Heightmaps // Terrain Rendering episode #1

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ก.ย. 2024

ความคิดเห็น • 44

  • @sporkspork8556
    @sporkspork8556 หลายเดือนก่อน

    this is a solid introduction and im really grateful that you shared this knowledge , thank you OGLDEV.:))

    • @OGLDEV
      @OGLDEV  หลายเดือนก่อน

      Glad it was helpful!

  • @grengren6421
    @grengren6421 ปีที่แล้ว +2

    You just keep coming out with the hits man. Thanks again!

    • @OGLDEV
      @OGLDEV  ปีที่แล้ว

      You're welcome! Enjoy!

  • @nicuukk1779
    @nicuukk1779 ปีที่แล้ว +2

    Let's goo, been waiting for this 🔥

  • @OGLDEV
    @OGLDEV  ปีที่แล้ว +3

    Clone the sources:
    git clone --recurse-submodules github.com/emeiri/ogldev.git
    If you want to get the same version that was used in the video you can checkout the tag 'TERRAIN1'.
    Build on Linux:
    cd ogldev/Terrain1 && ./build.sh
    Build on Windows:
    Open the Visual Studio solution: ogldev\Windows\ogldev_vs_2022\ogldev_vs_2022.sln
    Build the project TerrainRendering\Terrain1
    Things to try:
    1. In this video I describe how to load the heightmap file from a raw file of floating points.
    It is also common to store heightmaps in gray scale png/jpeg files. Add support for loading such
    files using STB image (more info on STB in the texture mapping tutorial: th-cam.com/video/n8t7nvHCqek/w-d-xo.html
    2. (Advanced) If you take a closer look at the TriangleList class you will find more stuff that can be shared
    between OpenGL and other APIs such as DirectX (both APIs support the same topology types). Refactor the API specific
    stuff (create/bind buffer handles, etc) into a derived class while leaving the common functionality of populating
    the index/vertex vectors in the base class. This will make it ready for future porting to DirectX.

  • @chah1653
    @chah1653 ปีที่แล้ว +3

    You are my hero.

    • @OGLDEV
      @OGLDEV  ปีที่แล้ว +2

      Thanks!

  • @wangyangshi
    @wangyangshi 4 หลายเดือนก่อน

    Good video, simple, clear, step by step. ❤❤

    • @OGLDEV
      @OGLDEV  4 หลายเดือนก่อน

      Thank you! 🙂

  • @CodeParticles
    @CodeParticles ปีที่แล้ว +1

    @OGLDEV, Very advanced my friend! I hope you can also talk about barycentric coordinates for placement of objects and the actual elephant in the room so to speak, generating grids via Tessellation shaders! 👍👍

    • @OGLDEV
      @OGLDEV  ปีที่แล้ว

      Thanks! In this series I'm sticking to the book so it will not include Tessellation since it didn't exist at the time, but will definitely cover it later on, for terrain as well as other usages.

  • @vncubers
    @vncubers ปีที่แล้ว

    thank you for your videos

    • @OGLDEV
      @OGLDEV  ปีที่แล้ว

      You're welcome!

  • @coderoyalty
    @coderoyalty ปีที่แล้ว

    I've been waiting...

  • @oraz.
    @oraz. 10 หลายเดือนก่อน

    I can't believe I happened upon this. 🙏

    • @OGLDEV
      @OGLDEV  10 หลายเดือนก่อน

      :-)

  • @vkrak85
    @vkrak85 หลายเดือนก่อน

    Thank you for your helpful video and lesson, though I was wondering what file format should I use for the the heightmap? Can I use the Soil image loading library for reading the heightmap data? Thank you so much 👍

    • @OGLDEV
      @OGLDEV  หลายเดือนก่อน

      You're welcome :-) Do you mean that you want to save the heightmap that was generated by the code? You can use any file format that the library supports (jpg, png, etc). The SOIL library should work ok.

    • @vkrak85
      @vkrak85 หลายเดือนก่อน

      @OGLDEV I mean, can I use greyscale 8 bit image from for example Gimp(or tangram), then load it with gimp, or is the heightmap file a special one that we need to generate ourselves? I ask because I am getting zigzag pattern over terrain and it's not looking correct. Thank you so much for the help and your reply🤝

    • @OGLDEV
      @OGLDEV  หลายเดือนก่อน

      In this series we learn two algorithms for generating random terrains (more in the future). In the first video we create the framework for loading the heightmap from a raw binary file of floating point numbers which is how we store the heightmap in memory. If you want to import a heightmap from a greyscale 8 bit image you can use SOIL to load the file. I assume you will get back a char array and the dimensions. You can then convert this array to an array of floats and render it with the tutorial code. Perhaps SOIL is able to load images directly as floating points and then you can save some of the hassle. Gimp is not part of the process. You can use it if you want to manually modify the heightmap image.

  • @AlbertRyanstein
    @AlbertRyanstein ปีที่แล้ว

    Hi, I saw you on reddit :) This is episode one but it seems you aleady have a lot written such as terrain functions etc.Did you build this code base up in earlier tutorials elsewhere? Or should I just make my own version of this.

    • @OGLDEV
      @OGLDEV  ปีที่แล้ว

      Some of the more generic stuff like textures, shaders, etc is based on the 'OpenGL for beginners' playlist on my channel but if you are already familiar with this stuff you can jump right into the 'Terrain Rendering' series with this episode. All the terrain specific code is created during the series.

  • @zoeherriot
    @zoeherriot ปีที่แล้ว +1

    Pretty sure Trent was in highschool when he wrote that book.

    • @OGLDEV
      @OGLDEV  ปีที่แล้ว +1

      Very true.

  • @PaulMetalhero
    @PaulMetalhero ปีที่แล้ว +1

    Man, your code looks like you live in 1998 🤣
    But your videos are amazing! 👍

    • @OGLDEV
      @OGLDEV  ปีที่แล้ว +1

      Why 1998?

    • @PaulMetalhero
      @PaulMetalhero ปีที่แล้ว

      @@OGLDEV You know, the NULL macros, and some other things like C style casts, etc

    • @OGLDEV
      @OGLDEV  ปีที่แล้ว +3

      I find very little advantage in those two features. I doubt they would make my code cleaner or more robust. And C++ casts are simply ugly so I avoid them.

    • @PaulMetalhero
      @PaulMetalhero ปีที่แล้ว

      @@kishirisu1268 lol

  • @nerijusvilcinskas7851
    @nerijusvilcinskas7851 ปีที่แล้ว

    Any idea why I don't get anything to render after introducing Index Buffer and converting to the triangles instead of points? Was working perfectly up until that point. Could this be related to left/right hand coordinate system?

    • @OGLDEV
      @OGLDEV  ปีที่แล้ว

      Probably not the coordinate system unless you flipped the index order compared to what was working in the non indexed case. There can be multiple problems - not using glDrawElements correctly, forgot to bind the index buffer, indices not referencing the correct vertices, etc. Try to get one point rendered correctly using GL_POINTS and then switch back to triangles and render a single triangle.

    • @nerijusvilcinskas7851
      @nerijusvilcinskas7851 ปีที่แล้ว

      If anyone had the same problem, I found the problem I had: instead of indices.resize() I, for some reason, used indices.reserve()

    • @OGLDEV
      @OGLDEV  ปีที่แล้ว

      Good catch. If you plan to use the [] operator use resize. If you plan to use insert/push_back use reserve.

    • @nerijusvilcinskas7851
      @nerijusvilcinskas7851 ปีที่แล้ว

      @@OGLDEV Thank you so much for such a quick reply!

    • @OGLDEV
      @OGLDEV  ปีที่แล้ว

      @@nerijusvilcinskas7851 You're welcome :-)

  • @AlbertRyanstein
    @AlbertRyanstein ปีที่แล้ว

    hey, i got the book in the ttutorial but trenk, can I go through this to create some terrain or is it too old for only the book and opengl?

    • @OGLDEV
      @OGLDEV  ปีที่แล้ว

      The book uses the old fixed function pipeline. In my videos I'm implementing the algorithms using modern OpenGL and shaders.

    • @AlbertRyanstein
      @AlbertRyanstein ปีที่แล้ว

      @@OGLDEVthanks man, appreciate u getting back. never forget the small man when you're big man in 2024 haha.

    • @OGLDEV
      @OGLDEV  ปีที่แล้ว

      :-)