• 使一个片同时支持正反面图片显示


    // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
    
    // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
    
    Shader "Custom/TwoFaceShader"
    {
        Properties
        {
            _MainTex_1 ("贴图1", 2D) = "white" {}
            _MainTex_2 ("贴图2",2D) = ""{} 
        }
        SubShader
        {
            
            Pass {
                Tags{"LightMode" = "ForwardBase"}
                LOD 100
                
                //在这个通道内剔除背面渲染
                Cull Back
                CGPROGRAM
                #pragma vertex vert
                #pragma fragment frag
                #include "UnityCG.cginc"
                
                struct appdata {
                    float4 vertex:POSITION;
                    float2 uv:TEXCOORD0;
                };
    
                struct v2f{
                    float4 vertex:SV_POSITION;
                    float2 uv:TEXCOORD0;
                };
                sampler2D _MainTex_1;
                //使用TRANSFORM_TEX时需要定义一个 _贴图的变量名_ST 用来供给系统使用
                float4 _MainTex_1_ST;
                
                v2f vert(appdata v){
                    v2f o;
                    o.vertex = UnityObjectToClipPos(v.vertex);
                    o.uv = TRANSFORM_TEX(v.uv,_MainTex_1);
                    return o;
                }
    
                fixed4 frag(v2f v):SV_TARGET{
                    fixed4 col= tex2D(_MainTex_1,v.uv);
                    return col;
                }
    
                 ENDCG    
            }
    
            Pass{
                Tags{"LightMode" = "ForwardBase"}
                Cull Front 
    
                CGPROGRAM
                #pragma vertex vert
                #pragma fragment frag 
                #include "UnityCG.cginc"
    
                struct appdata{
                    float4 vertex:POSITION;
                    float2 uv:TEXCOORD0;
                };
    
                struct v2f{
                    float4 vertex:SV_POSITION;
                    float2 uv:TEXCOORD0;
                };
    
                sampler2D _MainTex_2;
                float4 _MainTex_2_ST;
    
                v2f vert(appdata v){
                    v2f o;
                    o.vertex = UnityObjectToClipPos(v.vertex);
                    o.uv = TRANSFORM_TEX(v.uv,_MainTex_2);
                    return o;
                }
    
                fixed4 frag(v2f v):SV_TARGET
                {
                    fixed4 col = tex2D(_MainTex_2,v.uv);
                    return col;
                }
    
                ENDCG
            }
        }
        FallBack "Diffuse"
    }
  • 相关阅读:
    敏捷之Scrum框架
    Google浏览器80版本以上无法打开系统页面问题
    ThreadLocal 了解
    简化两个list之间赋值操作
    linux下用命令调用dubbo服务
    13条代码审查建议
    初识MongoDB(1)
    linux日常常用命令整理
    java发起http请求
    工作思维方法
  • 原文地址:https://www.cnblogs.com/chenggg/p/11710390.html
Copyright © 2020-2023  润新知