SFML community forums

Help => Graphics => Topic started by: underdisk on June 10, 2018, 09:26:48 pm

Title: Chunk rendering
Post by: underdisk 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 :
(https://i.imgur.com/0vBr5O4.png)

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

(https://i.imgur.com/DhfCEhl.png)

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.
Title: Re: Chunk rendering
Post by: eXpl0it3r 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.
Title: Re: Chunk rendering
Post by: underdisk on June 10, 2018, 10:15:24 pm
It's possible to put multiple textures in one VB ?
Title: Re: Chunk rendering
Post by: eXpl0it3r 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. :)
Title: Re: Chunk rendering
Post by: underdisk 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)