![]() There are two sollutions for this problem. You cant have more than 1 texture per mesh. However, this approach causes another problem. This makes a single chunk a single object - large enough such that you are not bottlenecked by thousands of drawcalls, but small enough to allow for redrawing the mesh in a reasonable amount of time, if it was changed by the player. In practice this means that you will want to create a mesh, using squares, that puts a square only where a side of a block is exposed to air - and then combine all those squares into a single mesh. What you want to do instead, in order to reduce drawcalls, is create as few single mesh objects as possible. What i'm getting at is this: Block worlds are actually not made up of blocks. Filling a 16x16x256 chunk, like in minecraft, roughly half with single block objects causes the creation of 8*16*256 = 32768 individual block objects, each having its own drawcall. This is the general approach, but it gets a lot more complicated when you consider performance. Then you probably want to scale the output based on the y-coordinate to get, on average, higher values the higher up you are and lower values the lower you are, resulting in a surface with air above and denser terrain below. To generate more reasonable terrain, you then want to mix different noise functions, with different scales and offsets. For example, place a block if the value is below 0.5. That way you get a float value between 0 and 1 per coordinate, based on which you can decide to place a block or not. You use a 3D perlin noise function and sample it using coordinates as input.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |