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. sql查看数据字典(表结构)

    SELECT (case when a.colorder=1 then d.name else null end) 表名, a.colorder 字段序号,a.name 字段名, (case when ...

  2. 在命令行中通过adb shell am broadcast发送广播通知

    通过命令行执行adb shell am broadcast发送广播通知. adb shell am broadcast 后面的参数有:[-a <ACTION>][-d <DATA_U ...

  3. 使用C#对SQLLite进行操作

    1.数据库连接(常用连接方法,示例) 1). 添加引用: System.Data.SQLite.DLL .2). 打开或创建数据库文件: SQLiteConnection.CreateFile(fil ...

  4. Yii里增删改查的操作方法

    一.AR $model=New user();//user是数据库中的一张表,有id,name,pwd字段 1.增加: <1. $model->name='张三': $model-> ...

  5. DOMContentLoaded和jquery的ready和window.onload的顺序

    document.addEventListener('DOMContentLoaded', function(){ alert(1) }); window.onload=function(){ ale ...

  6. 两个二进制数多少个位(bit)不同

    class Solution { public: /** * 获得两个整形二进制表达位数不同的数量 * * @param m 整数m * @param n 整数n * @return 整型 */ in ...

  7. protoc 和 protoc-gen-go 产生的 proto 文件代码对比

    protoc 命令来自 https://github.com/google/protobuf, 由于这里没有 go 的产生代码, go的产生代码在 protoc-gen-go  (https://gi ...

  8. HTTP调试工具扩展

    ★Fiddler神器之一,IE-WinNet-Fiddler-Server,能跟踪调试HTTP和HTTPS是优点也是缺点. 地址:http://www.fiddler2.com/ ★Charles,可 ...

  9. html doctype 作用介绍

    文档模式主要有以下两个作用: 1.告诉浏览器使用什么样的html或xhtml规范来解析html文档 2.对浏览器的渲染模式产生影响:不同的渲染模式会影响到浏览器对于 CSS 代码甚至 JavaScri ...

  10. leetcode 136

    136. Single Number Given an array of integers, every element appears twice except for one. Find that ...