Unity 2DTIleMap物体出现线条问题 您所在的位置:网站首页 SolidWorks打开3D鼠标扫过会出现一根根线条 Unity 2DTIleMap物体出现线条问题

Unity 2DTIleMap物体出现线条问题

#Unity 2DTIleMap物体出现线条问题| 来源: 网络整理| 查看: 265

Unity 2DTIleMap物体出现线条问题 最近做2D项目的时候,相机移动,2D物体之间会有线条,特别是那种TileMap制作的。 解决方法: Main Camera 关闭 MSAA 在这里插入图片描述 链接: 最根本的解决方法上Shader,此篇博客更详细

```csharp Shader "Sprites/Pixel Snap/Alpha Blended" { Properties { _MainTex ("Sprite Texture", 2D) = "white" {} _Color ("Main Color", Color) = (1,1,1,1) } SubShader { Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } Cull Off Lighting Off ZWrite Off ZTest Always Fog { Mode Off } Blend SrcAlpha OneMinusSrcAlpha Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #pragma fragmentoption ARB_precision_hint_fastest #include "UnityCG.cginc" sampler2D _MainTex; float4 _MainTex_ST; fixed4 _Color; struct appdata_t { float4 vertex : POSITION; float2 texcoord : TEXCOORD0; }; struct v2f { float4 vertex : POSITION; float2 texcoord : TEXCOORD0; }; v2f vert(appdata_t IN) { v2f OUT; OUT.vertex = mul(UNITY_MATRIX_MVP, IN.vertex); OUT.texcoord = TRANSFORM_TEX(IN.texcoord, _MainTex); // Snapping params float hpcX = _ScreenParams.x * 0.5; float hpcY = _ScreenParams.y * 0.5; #ifdef UNITY_HALF_TEXEL_OFFSET float hpcOX = -0.5; float hpcOY = 0.5; #else float hpcOX = 0; float hpcOY = 0; #endif // Snap float pos = floor((OUT.vertex.x / OUT.vertex.w) * hpcX + 0.5f) + hpcOX; OUT.vertex.x = pos / hpcX * OUT.vertex.w; pos = floor((OUT.vertex.y / OUT.vertex.w) * hpcY + 0.5f) + hpcOY; OUT.vertex.y = pos / hpcY * OUT.vertex.w; return OUT; } fixed4 frag(v2f IN) : COLOR { return tex2D( _MainTex, IN.texcoord) * _Color; } ENDCG } } }


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有