Unity - A计划(一年有效期) 扫二维码继续学习 二维码时效为半小时

(61评价)
价格: 2170.00元
(急)Unity3D我的树叶渲染,关闭反面剔除 Cull Off ,但是为什么隔一定的距离,叶子就不见了。
ZerO23发起了问答2019-01-04
3
回复
657
浏览

 我的树叶渲染,使用 Cull Off 关闭反面剔除,但是为什么隔一定的距离,叶子就不见了。我想距离多远距离都能看见。不知道是什么原因导致的隔了一段距离,叶子就消失了。

叶子Shader的代码:

Shader "Cull-Off Cutout" {
    Properties {
        _Color ("Main Color", Color) = (1,1,1,1)
        _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
        _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
    }

    SubShader {
        Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
        Cull Off
        
CGPROGRAM
#pragma surface surf Lambert alphatest:_Cutoff

        sampler2D _MainTex;
        fixed4 _Color;
        
        struct Input {
            float2 uv_MainTex;
        };
        
        void surf (Input IN, inout SurfaceOutput o) {
            fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
            o.Albedo = c.rgb;
            o.Alpha = c.a;
        }
ENDCG
    }
    
    Fallback "Transparent/Cutout/VertexLit"
}
 

所有回复
  • 老师_Trigger 2019-01-04

    同学你好,可以参考一下这篇文章:

    http://blog.sina.cn/dpool/blog/s/blog_471132920101dfvt.html

    • ZerO23 2019-01-06

      老师,里面没有写怎么解决。。。

      (0) 回复
    • 老师_Trigger 2019-01-06

      回复 @ ZerO23: 按正常代码同学使用Cull Off是不剔除的,不该会出现剔除的情况,那么同学按照文章里的做法看看是不是深度测试的问题。

      (0) 回复
    还有-3条回复,点击查看
    你还没有登录,请先登录注册
发表回复
你还没有登录,请先 登录或 注册!