Question regarding tiles and their material

Hello,

I am working on generating a world with a minecraft look.
I was able to generate a 200x200 tiles world, but the performance was slow.
So after combining all the meshes on the objects into one, performance is dramatically up.
I then applied a material to the surface and tiled it so it would have that minecraft tile look.

Now the problem I have is, I amnot sure if it’s possible, but how could I change the look of one tile only, is there a way to draw different materials on 1 object at different locations?

Don’t combine them. Cull the meshes that aren’t on screen and those out of a set render distance for starters. There’s a ton of tricks developers use to optimize performance, and you probably have to do some more research on it to figure them out.

As you already realised, worlds that appear to be made of many individual objects are actually not. Minecraft for example would have to place up to 1616256 = 65536 blocks per chunk. Not even one such chunk would run fluidly. As Panda mentioned, there is a lot of optimizations going into things like that. Usually these games also completely separate the underlying data and the visual representation. For example, imagine a Minecraft chunk as a 3 dimensional array of block ids. This construct is then rendered into as few individual objects as possible. Depending on the approach it may be one single mesh, or it could be one mesh per material. In a 3D world, this only includes actually visible triangles, none of the ones inside the mesh itself. If the mesh needs to be altered, for example because the player destroys a block, the coordinate at which he does so is used to determine the corresponding (block) entry in the 3 dimensional data array. The player then receives this block in their inventory, the corresponding data entry is set to whatever value represents “empty” and the entire chunk is visually re-rendered from scratch. Something along those lines. This usually also involves multi-threading to prevent performance spikes on taxing calculations. Overall, this is a very advanced topic.

So much for voxel based worlds. I never worked with tiles, but if i was to generate a procedurally generated 2D world i would probably heavily rely on a similar approach, since it involves similar problems. The difficulty is decreased here tho, so you may get away with less optimizations and complexity in general, especially if you dont need to alter the mesh after generating it.

I believe Minecraft will render the surface and then create and paint the geometry on interaction using player coordinate vertice quad matching.

They will use one texture as a terrain would, but access the uv points of that texture accordingly. So the player would be known in a cell to interact with a surface and so geometrically morphs that surface and then adds the new uv. Similar in performance in editor terrains as you can raise a mountain from the ground without many hiccups. or modeling software may Introduce vertices at locations and stretch them out.

Minecraft is in effect a dig tool. You dig into mesh and create a nice cube around yourself. Textures align on the uv with low bit images. Everything seems to be some kind of cube.

I think had it used individual cubes you would see these cubes during culling glitch for example loading a game or something. But I believe only surface geometry existed unless created. In area such as cavern.

They probably have one texture with like 45 16 bit images on it. And you reach a cell ask what image it is suppose to be and point the uv to that coordinate.

When generating the mesh, sort them by material and then combine the ones that share the same material. You can either use a single mesh with multiple submeshes, or different meshes (very little performance difference, so it’s just about whatever’s easier for you).

Or this, if you’re going specifically for a minecraft look or you’re OK with all materials using the same shader.