1
\$\begingroup\$

It's just a dirt terrain with grass blocks on the top. (which are just dirt blocks with green tops.)

I sampled a Unity terrain's heightmap, and constructed a voxel terrain based on it, and divided it into chunks, whose meshes then were combined.

Sadly the generated mipmaps are bad, the mipmap change is easily noticeable: first the shade of green changes, then it fully becomes dirt colored.

enter image description here

enter image description here

enter image description here

\$\endgroup\$
11
  • \$\begingroup\$ There are several ways to create blocky terrain in Unity. You might get better answers if you told us how you implemented it. Is it a 3rd party asset? Did you create your own? Did you hack the Unity terrain system to do this? \$\endgroup\$
    – Philipp
    Jan 21 '20 at 9:58
  • \$\begingroup\$ @Philipp I looped through a Unity Terrain's height map, and based on the height, I created columns made out of unit cubes. Then I created chunks from the unit cubes, and then combined the chunks' unit cubes into a single mesh. \$\endgroup\$
    – Tudvari
    Jan 21 '20 at 10:05
  • \$\begingroup\$ So you are saying that all the environment we see on that screenshot is one single mesh? \$\endgroup\$
    – Philipp
    Jan 21 '20 at 10:06
  • 2
    \$\begingroup\$ It could be a mipmapping problem. \$\endgroup\$
    – user253751
    Jan 21 '20 at 10:07
  • 1
    \$\begingroup\$ @Philipp No, a few hundred meshes. The map contains millions of cubes, but the map is divided into multiple XYZ sized chunks, whose cubes are combined, thus 1 chunk = 1 mesh. \$\endgroup\$
    – Tudvari
    Jan 21 '20 at 10:10
1
\$\begingroup\$

The problem appears to be that Unity generates mip maps from your texture without considering the "cell borders" in your textures (how could it at the texture importing stage when it does not yet know how you are going to set up your UV maps?). So the brown parts of the textures bleed into the green parts.

A quick and dirty solution would be to turn off mip map generation, but that will likely result in a performance penalty (and in a scene like that you need any performance you can get) and other kinds of visual artifacts.

So a better solution could be to use three separate texture images - one for the sides of the cubes, one for the top and one for the bottom. That will prevent the mipmap generation algorithm from mixing these textures.

\$\endgroup\$
5
  • \$\begingroup\$ Is that doable in Unity or I have to make a cube in a modelling software, and texture it with 3 different textures files? \$\endgroup\$
    – Tudvari
    Jan 21 '20 at 10:41
  • \$\begingroup\$ @Tudvari Don't you generate procedural meshes anyway? You might want to look into how to do that with more than one material. \$\endgroup\$
    – Philipp
    Jan 21 '20 at 11:39
  • \$\begingroup\$ Hmm, I think making a better model would be better performance wise \$\endgroup\$
    – Tudvari
    Jan 21 '20 at 19:20
  • \$\begingroup\$ Now I created my own model, with padding (the padding is rgba (0,0,0,0)), and now it looks better, but there are still issues, like at mid-distance and at very far away: i.imgur.com/0xoHCUW.png \$\endgroup\$
    – Tudvari
    Jan 22 '20 at 15:44
  • 1
    \$\begingroup\$ @Tudvari It's likely still the same problem: The different zones of your texture bleed into each other when Unity scales the texture down in order to create the mip-maps. To fix this problem, create a model which uses separate materials with separate textures for the top, the sides and the bottom. Use textures which are only one 16x16 square. \$\endgroup\$
    – Philipp
    Jan 22 '20 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.