zoukankan      html  css  js  c++  java
  • Unity关闭shader中的光照模型以及如何自定义光照模型

    // Upgrade NOTE: replaced '_World2Object' with 'unity_WorldToObject'
    
    // Upgrade NOTE: replaced '_World2Object' with 'unity_WorldToObject'
    
    Shader "Custom/RadarWave" {
        Properties {
            _Color ("Color", Color) = (1,1,1,1)
            _MainTex ("Albedo (RGB)", 2D) = "white" {}
            _Glossiness ("Smoothness", Range(0,1)) = 0.5
            _Metallic ("Metallic", Range(0,1)) = 0.0
            _TransVal("Transparency Value", Range(0,1)) = 0.5
            _StripWidth("Strip Width", Range(0.1,10)) = 0.2
            _Speed("Speed", Range(1,100)) = 1
        }
        SubShader {
            Tags { "RenderType"="Opaque" "Queue" = "Transparent" }
            LOD 200
            //Cull Off//关闭背面裁剪
            //Lighting Off//此设置在surface shader中不起作用,貌似是在Unlit Shader中使用的
            //ZWrite On
            //ZTest On
            Blend SrcAlpha OneMinusSrcAlpha
            
            CGPROGRAM
            // Physically based Standard lighting model, and enable shadows on all light types
            //#pragma surface surf Standard fullforwardshadows alpha vertex:vert
            #pragma surface surf NoLightModel fullforwardshadows alpha vertex:vert
    
            
    
            // Use shader model 3.0 target, to get nicer looking lighting
            #pragma target 3.0
    
            sampler2D _MainTex;
    
            struct Input {
                float2 uv_MainTex;
                float4 modelPos_;
            };
    
            half _Glossiness;
            half _Metallic;
            half _TransVal;
            half _StripWidth;
            half _Speed;
            fixed4 _Color;
    
            // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
            // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
            // #pragma instancing_options assumeuniformscaling
            UNITY_INSTANCING_CBUFFER_START(Props)
                // put more per-instance properties here
            UNITY_INSTANCING_CBUFFER_END
    
            void surf(Input IN, inout SurfaceOutput o) {
                // Albedo comes from a texture tinted by color
                fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
                o.Albedo = c.rgb;
                //float4 tmp = mul(unity_WorldToObject, IN.modelPos_);
                if (fmod(floor((IN.modelPos_.z-_Time.y*_Speed)/ _StripWidth),3)!=0)
                {
                    //clip(-1);
                    discard;
                }
                //o.Alpha = c.a;
                o.Alpha = _TransVal;
            }
    
            void vert(inout appdata_full v, out Input o)
            {
                UNITY_INITIALIZE_OUTPUT(Input, o);
                o.modelPos_ = v.vertex;
            }
    
            //命名规则:Lighting接#pragma suface之后起的名字   
            //lightDir :点到光源的单位向量   viewDir:点到摄像机的单位向量   atten:衰减系数   
            float4 LightingNoLightModel(SurfaceOutput s, float3 lightDir, half3 viewDir, half atten)
            {
                float4 c;
                c.rgb = s.Albedo;
                c.a = s.Alpha;
                return c;
            }
    
            ENDCG
        }
        FallBack "Diffuse"
    }
  • 相关阅读:
    Java设计模式系列之策略模式
    设计模式系列之热身
    算术表达式系列之后缀表达式求值
    算术表达式系列之中缀表达式转后缀表达式
    Maven下使用Junit对Spring进行单元测试
    Windows命令行使用总结(持续更新)
    Eclipse中web项目部署至Tomcat步骤
    MyBatis保存完整日期的解决方法
    Redis(一)源码安装
    【集成学习】sklearn中xgboost模块中plot_importance函数(绘图--特征重要性)
  • 原文地址:https://www.cnblogs.com/coolbear/p/8676474.html
Copyright © 2011-2022 走看看