对象缩放纹理自动重复

来源:互联网 发布:阿里云服务器里安装ftp 编辑:程序博客网 时间:2024/05/17 18:29
Shader "Unlit/TransparentAutoRepeat" {Properties {    _MainTex ("_MainTex", 2D)  = "white" {}    _Alpha("Alpha", Range(0,1)) = 1}SubShader {    Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}    LOD 100    ZWrite Off    Blend SrcAlpha OneMinusSrcAlpha    Pass     {          CGPROGRAM            #pragma vertex vert            #pragma fragment frag            #pragma multi_compile ETC_ON ETC_OFF            #include "UnityCG.cginc"            struct appdata_t             {                float4 vertex : POSITION;                float2 texcoord : TEXCOORD0;            };            struct v2f             {                float4 vertex : SV_POSITION;                half2 texcoord : TEXCOORD0;            };            sampler2D _MainTex;            float4 _MainTex_ST;            float  _Alpha;            v2f vert (appdata_t v)            {                float3 vnormal = float3(1,1,1);                float3 scale   = mul(unity_ObjectToWorld,vnormal);                v2f o;                o.vertex   = mul(UNITY_MATRIX_MVP, v.vertex);                o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);                o.texcoord = o.texcoord*scale;                return o;            }            fixed4 frag (v2f i) : SV_Target            {                fixed4 col   = tex2D(_MainTex,  i.texcoord);                col.a        = col.a*_Alpha;                return col;            }        ENDCG    }}}

在5.1.3f版本上发现了一个问题当摄像机远离 对象时展现上会出现问题
后来发现了这个帖子

http://answers.unity3d.com/questions/1241231/replaced-object2world-with-unity-objecttoworld.html

everytime _Object2World is replaced by unity_ObjectToWorld with a upgrade message on top

不知道这个能不能解决当前的问题 待验证

升级到unity 5.5.3 后 自动替换了 unity_ObjectToWorld
当时效果依然有问题
最后尝试在shader的tag里关闭 batch的优化
“DisableBatching” = “true”

发现没有问题 了 原来时untiy优化后产生的问题
不过绘制批次瞬间爆表

0 0
原创粉丝点击