问题描述
我正在使用Unity 5.4进行项目.在此项目中,块彼此相邻堆叠.
I'm working on a project, using unity 5.4.In this projects blocks are stacked next to eachother.
但是,会出现一些令人讨厌的怪异线条.同样在Android上这些行比在PC上发生的频率更高.为了说明目的,我添加了图像和视频.请放大图片以清楚地看到我说的那一行.
However there appear some annoying weird lines. Also on android theseline occur more often than on PC.For illustration purposes I added an image and video.Please zoom in on the picture to see, the line I'm speaking of, clearly.
任何人都可以提供解决方案以消除这种麻烦.预先感谢.
Could anyone please provide a solution to get red of this nuissance.Thanks in advance.
文献:
块对齐代码段:
for (int x = 0; x < xSize; x++)
for (int z = 0; z < zSize; z++)
{
Vector3 pos = new Vector3(x, -layerDepth, z);
InstantiateBlock(pos);
}
视频链接: https://youtu.be/5wN1Wn51d_Y
推荐答案
您有对象接缝!
当对象之间存在物理或感知间隙时,会发生这种情况.
This occurs when there is a physical or perceived gap between objects.
有多种原因.
这可能是因为您将多维数据集的位置设置为int
,但是它们具有浮点尺寸.这种现象的症状通常是当相机靠近物体时没有白缝,然后由于浮点的不精确性,当您离物体越来越远时,它们会逐渐出现. 更多.
This could be because you are setting the position of the cubes to int
's but they have floating point dimensions. The symptom for this is usually no white seams when the camera is close to the objects, and then they gradually appear as you get further away due to floating point imprecision. More.
如果在纸上3 == 1/3 * 3
考虑以下内容,这在数学上是正确的,但是使用浮点数,1/3 == 0.333333...
和随后的3 * 0.333333... == 0.999999...
BINGO!物体之间的随机间隙!
If you consider the following on paper 3 == 1/3 * 3
this is mathematically correct, however using floats, 1/3 == 0.333333...
and subsequently 3 * 0.333333... == 0.999999...
BINGO! random gap between objects!
那么如何解决?使用浮点数计算对象的位置.例如,new vector3(1,1,1);
应该是new vector3(1f,1f,1f);
.有关此内容的更多信息,请尝试此 SOP.
So how to solve? Use floats to calculate the positions of your objects. new vector3(1,1,1);
should be new vector3(1f,1f,1f);
- for example. For further reading on this try this SOP.
如果在对象上使用纹理,请尝试将纹理的环绕模式"从环绕"更改为夹紧",或者尝试增大纹理填充.
If you are using textures on your objects, try changing the Wrap-Mode of your texture from wrap to clamp, or try upping the texture padding.
这是阴影中的像素的任意模式,当它们应该真正点亮或不点亮时.
This is the arbitrary patterns of pixels in shadow when they should really be lit or NOT lit.
在Unity中...转到光源,然后增加Shadow Type > shadow Bias
,我建议将默认值0.05加倍,然后继续操作直至固定.您不想将这个值提高到最大值,因为...
In Unity... go to your light source and then increase the Shadow Type > shadow Bias
I would suggest doubling the default value of 0.05 and then continue so until fixed. You don't want to crank this value to max because...
这篇关于怪异的线3D Unity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!