Ugly edges with multiple image parts in one texture

Hi, I am new to Unity and 3d itself and just playing around with some basics. But now I have a question about of a strange color problem and how to use textures properly. In my scene are only brown cubes, but looking from a special distance and angle the cubes get a green discoloration and I don’t know why or how to fix this. I uploaded a picture to show what I mean (and the unity test project):

discolorated cube

This big cube consists of many small cubes which are instantiated prefabs via a script. The prefab cube has a “dirt” material assigned with a standard diffuse shader and a texture imported with aniso level 1, bilinear filter mode and repeat wrap mode. The material’s tiling and offset properties are set because the texture image has not only a dirt part, but also a green grass part for an other cube for the future. So in the image there are 4x4 quad slots for different terrain types and to my dirt cube there should only be the dirt quad assigned to wich is on position 1x2. That’s why tiling x is 0.25, tiling y 0.25, offset x 0.25 and offset y 0.75. In the preview window everything looks fine for a single dirt cube, no parts of green grass or other colors are visible. If I instantiate the prefab dirt cube, it looks okay. There are no green parts visible, but some edges seems to be white. I figured out that’s because of my white background in the texture image, so I switched it to black and the single cube in unity’s game mode looks fine. So I instantiated a lot of these cubes forming the huge cube shown in the picture above and there are no white edges, only black edges which are not so obviously and the green tint which in turn is. It seems to me, the green is belonging to the grass quad next to the dirt quad in the texture image which is also drawn in the scene, like the white/black background. I tried to fix this with tweaking the material’s tiling and offset properties, but I can’t get rid of this green, nor of the black/white edges. Changing the aniso level of the texture importer from 1 to 2 or the filter mode to trilinear softens the problem, but does not fix it. The only solution is to use one texture for each terrain quad, so there are no other terrain types and colors in the image and no tiling is necessary. But the documentation mentions this should be avoided, so using multiple terrain types for different cubes in one texture image should be the right way. I could try to place all green quads on one side of the texture image and the brown quads on the other surrounded by almost equal looking quad pictures, but there will always be some quads aligned which have different colors, maybe not in this example but later for sure. What can I do to fix this strange discoloration of edges? Is there something I did wrong or misunderstood? Any advise is welcome and thanks for it in advance.

If you want to get a good result with your cube problem you need to do this

Game object> create other> cube

then the should be a folder in the inspector view (when you have clicked on the cube in the hierarchy view) that is called mesh renderer.

then there should be a materials folder then you will see some thing called “element 0”
Now click on Element 0
A box should appear with different matterials all listed. then just select the material you want.

If you are still having problems, just try scaling the box and then when it is the right size just drag it onto an empty prefab

to get an empty prefab just go assets>create>prefab then rescale the prefab.

sorry, i know it alot of information.
hope this helps


Hi Technor,

thank you for your answer, but that is exactly what I did. There is a standard 1x1x1 cube with the dirt material assigned to it in the element 0 slot and saved as a prefab. I instantiate this prefab multiple times via script to create this big cube on start. Unfortunatly this results in such a strange edge color which tints the big cube.

I just tried to scale the prefab as you mentioned, but this didn’t help either. I think it is the same as trying to tweak the tiling of the texture and even with a smaller tiling and a higher offset the green tint stays, same with smaller prefab cubes as advised.