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. Win8 WinRT将替换Win32 API程序员何去何从?

    win8 新引入了称为WinRT的核心API.支持使用C/C++..NET或JavaScript来开发Metro风格的应用.这些应用自动获得硬件加速和高级电源管理的功能.现有的Silverlight和 ...

  2. for xml path(''),root('')

    ,,'') SELECT top 10 ROW_NUMBER()OVER(ORDER BY OperationID) as 'Message/MessageId', OperationID as 'I ...

  3. Property ClientHeight does not exist 问题解决

    delphi的TFrame继承自另一个TFrame时,最好通过File->New->Other...->Delphi Projects->Inheritable Items 的 ...

  4. Delphi 使用CHM文件制作系统帮助文档(上下文感知帮助的制作)

    一.基础知识简介         使用帮助提示窗口或状态栏只能提供简单.单一的帮助,无法对某一模块或应用程序整体提供系统的 帮助,因此运行Windows应用程序,需要帮助时一般都可以通过执行帮助菜单获 ...

  5. swoole和erlang通信测试

    直接用docker跑环境 docker pull xlight/docker-php7-swoole docker run -it -v ~/Projects/php/swoole:/workdir ...

  6. Asp.net MVC 之请求生命周期

    今天主要试着描述一下ASP.NET MVC 请求从开始到结束的整个生命周期,了解这些后,对MVC会有一个整体的认识. 这里主要研究了MVC请求的五个过程. 1.创建RouteTable 当ASP.NE ...

  7. MapReduce排序输出

    hadoop的map是具有输出自动排序功能的~继续学习~ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.c ...

  8. js零散总结

    字符串的查找 index of 指定查找位置 可以查所有,不支持正则   找不到返回-1 var i=-1; while((i=str.indexOf("关键词",i+1))!=- ...

  9. silverlight简单数据绑定3

    3种数据绑定模式  OneTime(一次绑定) OneWay(单项绑定) TwoWay(双向绑定) OneTime:仅在数据绑定创建时使用数据源更新目标. 列子: 第一步,创建数据源对象让Person ...

  10. rsync无密码实时增量同步

    rsync -azvP /rsync/ --password-file=/etc/rsyncd/rsyncd.password  ruiy@192.168.11.199:/rsync/ rsync - ...