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. Autocad 常用命令

    一律使用的简写 1:将多条线段合并成一条多线段[pe] 2:如果发现合并的多线段将自己不想合并的区域合并进去了,别担心,炸开就行了 [x] 3:如果画的线段太长工作区不适应,使用缩放命令.[scale ...

  2. mac android studio 编译时报Class JavaLaunchHelper is implemented in both

    Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Cont ...

  3. 【日期-时间】Java中Calendar的使用

    主要介绍了Calendar类的使用 输出 * 时间格式化 * 当前时间:2016-12-02 16:46:27.079 * * 转换:String-->Date-->Calendar * ...

  4. 黄聪:PHP7.0中htmlspecialchars出错解决方案(wordpress)

    htmlspecialchars( $context, ENT_COMPAT, 'UTF-8' )

  5. windows server2012 r2 上 安装 IIS8.5

    一时间不知道怎么开头了,直接上图吧! 本人技术不高,正在学习中, 要是有 喜欢 .Net,觉得酷的,欢迎来 QQ群  316497348  交流分享!

  6. webpack +vue开发(1)

    首先安装 node.js这是毋庸置疑的,安装完了之后安装webpack npm install webpack -g 接下来创建一个自己的文件夹 webpack-learn在里面创建一个index.h ...

  7. 一行代码解释.net事件与委托

    button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); }; delegat ...

  8. mysql登录基本语句

    默认密码:root mysql 显示所有的数据库,代码如下: mysql> show databases; mysql> show tables; MySQL显示命令二.显示命令 1.显示 ...

  9. AX Dynamic 2012 tabletype:TempDB使用

    LedgerJournalTmp ledgerJournalTmpJoin; LedgerJournalTransAccrual this.takeOwnershipOfTempTable(ledge ...

  10. (整理)SQLServer 大数据的插入与查询

    最近几天一直在折腾大数据量的查询,最后在索引.分页存储过程和控件以及视图的帮助下,搞定了.这篇文章记录解决问题时候查看的网友的分享链接,以及大数据量数据的插入链接. DatagridView Virt ...