Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Chunk rendering  (Read 2015 times)

0 Members and 1 Guest are viewing this topic.

underdisk

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Chunk rendering
« on: June 10, 2018, 09:26:48 pm »
Hello people. First I would like to apologize if this is the wrong place to post this (as it's very 'specific')

So.

I'm trying to do an isometric (yes I know it's not the correct term) style engine-thing and i'm also experimenting with the new sf::VertexBuffer class.

I made a simple Cube class, that is able to display a cube or a floor from an input texture.

For example, this is a 'skin' texture :


And here are the results using the CUBE and FLOOR mode :



As you can see this works well. The problem is that I would want them to be able to stack up (to make a full world out of them). For now, the program is using 1 draw call per cube, wich is a lot to consider if I want to make a world.

It would be cool to make a 'Chunk' system, with 1 draw call per chunk. Except I don't know how to do that considering that a chunk can be made of multiple cubes using multiple textures.

So how can a system like this be implemented ? (Ask me if you want me to put some code examples)
Thank you in advance.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Chunk rendering
« Reply #1 on: June 10, 2018, 09:58:53 pm »
So where exactly are you stuck?

To me this sounds like it can be easily done with some math to figure out how to connect the cubes, batch everything into a VB and off it goes.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

underdisk

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: Chunk rendering
« Reply #2 on: June 10, 2018, 10:15:24 pm »
It's possible to put multiple textures in one VB ?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Chunk rendering
« Reply #3 on: June 10, 2018, 10:59:29 pm »
No, but it's possible to have multiple textures in one big texture and set the texture coordinates appropriately, which is the recommended way to go anyways. :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

underdisk

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: Chunk rendering
« Reply #4 on: June 10, 2018, 11:12:26 pm »
Ahhh I see, baking a texture atlas...

Wouldn't that be problematic for a large number of blocks ? (max texture resolution etc)

 

anything