Here is a video about unity depth shader workarounds:

http://www.burgzergarcade.com/tutorials/game-engines/unity3d/unity-ios-shaderlab-tutorial-10-1-z-fighting

also his tutorial 6.2 and 6.3 are all about depth...

and this unity resource: http://unity3d.com/support/documentation/Components/SL-CullAndDepth.html

Here is a Ton of info about it with 3 solutions:

http://software.intel.com/en-us/articles/alternatives-to-using-z-bias-to-fix-z-fighting-issues/

I have ended with a custom-non-optimal-solution that at least works for me. I add a"ZFighter" component to any GameObject which I want to get a little bit distanced from a back object/wall. This separation is calculated according to Camera distance.

  1. using UnityEngine;
  2. using System.Collections;
  3. public class ZFighter : MonoBehaviour {
  4. // Use this for initialization
  5. private Vector3 lastLocalPosition;
  6. private Vector3 lastCamPos;
  7. private Vector3 lastPos;
  8. void Start () {
  9. lastLocalPosition = transform.localPosition;
  10. lastPos = transform.position;
  11. lastCamPos = Camera.main.transform.position - Vector3.up; // just to force update on first frame
  12. }
  13. void Update () {
  14. Vector3 camPos = Camera.main.transform.position;
  15. if (camPos != lastCamPos || transform.position != lastPos) {
  16. lastCamPos = camPos;
  17. transform.localPosition = lastLocalPosition + (camPos - transform.position) * 0.01f;
  18. lastPos = transform.position;
  19. }
  20. }
  21. }

Z Fighting Problem的更多相关文章

  1. Z - Fighting 和 Depth-bias

    Depth-bias操作在clipping之后进行实施,所以depth-bias对几何clipping没有影响. 另外需要注意的是:对一个给定体元(primitive),bias值是一个常量,在进行差 ...

  2. ACM的探索之Just Skip The Problem

    -----------------心怀虔诚,奋勇前进,fighting!!!!!! Problem Description: inclusively:          包括一切地;包含地 simul ...

  3. z-fighting在unity中的解决方式

    如果在画面中,发现有画面闪烁的问题.那么大多数情况下是z-fighting引起的, 解决方案: 1, 在每个场景中,找到那个MainCamera,然后在Inspector上,找到MainCamera的 ...

  4. 8.3 LIS LCS LCIS(完结了==!)

    感觉这个专题真不好捉,伤心了,慢慢啃吧,孩纸 地址http://acm.hust.edu.cn/vjudge/contest/view.action?cid=28195#overview 密码  ac ...

  5. Contest - 第10届“新秀杯”ACM程序设计大赛现场热身赛 赛后信息(题解)

      Problem Id Title   Problem A A+B   Problem B 统计字数   Problem C 生日计算   Problem D 冬瓜的寒假之旅 Problem A(略 ...

  6. [工作积累] shadow map问题汇总

    1.基本问题和相关 Common Techniques to Improve Shadow Depth Maps: https://msdn.microsoft.com/en-us/library/w ...

  7. threejs- z-fighting 问题(模型的重叠部位便不停的闪烁起来。这便是Z-Fighting问题)

    Z-Buffer 在threejs中,使用深度缓冲(Z-Buffer)来完成场景可见性计算,即确定场景哪部分可见,哪部分不可见.深度缓冲(Z-Buffer)是一个二维数组,其中的每一个元素对应屏幕上的 ...

  8. OpenGL ES 3.0之Shading Language(八)

    每个OpenGL ES 3.0程序要求一个顶点着色器和一个片段着色器去渲染一个图形.着色器概念是API 的中心,本篇将介绍着色器语言部分包含下面几项 1.变量和变量类型 2.矢量和矩阵创建及选择 3. ...

  9. WebGL 进入三维世界

    1.观察目标点和上方向 为了确定观察者的状态,你需要获取两项信息:视点,即观察者的位置:观察目标点(look-at point),即被观察目标所在的点,它可以用来确定视线.此外,因为我们需要把观察到的 ...

随机推荐

  1. 微分方程——包络和奇解

    对某些微分方程,存在一条(也可能多条)特殊的积分曲线,它并不属于方程的积分曲线族.但是,在这条特殊的积分曲线上的每一点处,都有积分曲线族中的一条曲线和它在此点相切.在几何学上,这条特殊的积分曲线称为上 ...

  2. 修复eclipse中使用mave update project后JRE都变成1.5的问题

    在项目中的parent pom中添加如下代码即可 <properties> <project.build.sourceEncoding>UTF-8</project.bu ...

  3. IT之人生感悟

    从实习到现在,一直在做程序开发,工作了也有1年了吧,日子也就这么浑浑噩噩的过去了,想想将要毕业那会,原本有想考研的打算,最后还是出于各方面考虑不了了之,相比考研族提早步入了社会,既然路是自己选的,那必 ...

  4. How to configure Veritas NetBackup (tm) to write Unified and Legacy log files to a different directory

    Problem DOCUMENTATION: How to configure Veritas NetBackup (tm) to write Unified and Legacy log files ...

  5. 四则运算GUI设计

    使用了QT来设计GUI,目前也还在看视频学习中,目前还不会用这个软件,所以具体功能还未实现,初步绘制的界面如下:

  6. C++设计模式-Builder建造者模式

    作用:将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以创建不同的表示. Builder模式和AbstractFactory模式在功能上很相似,因为都是用来创建大的复杂的对象,它们的区别是:B ...

  7. Js_Ajax_输入词提示

    输入"1",有提示,否则没有 suggest.jsp #suggest { background-color: #e0e0e0; width: 200px; } var xhr; ...

  8. Vi中的^M问题

    一般情况下,windows下编辑过的文件放到Linux下行尾会多出一个^M符号 1.可以通过dos2unix 命令作用与文件消除 2.或者在VI内通过 只需要在vi/vim 中输入命令:%s/\r// ...

  9. display:inline-block左右元素上下不对齐

    今天做了两个inline-block元素,出现左右两个元素顶端出现上下不对齐的情况(下图): 解决办法: 把应用 inline-block的元素加上 vertical-align: top; .CSS ...

  10. linux grep命令详解

    linux grep命令详解 简介 grep (global search regular expression(RE) and print out the line,全面搜索正则表达式并把行打印出来 ...