Unity turns off the lighting model in shader and how to customize the lighting model

Source: Internet
Author: User

//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,Ten)) =0.2_speed (" Speed", Range (1, -)) =1} subshader {Tags {"Rendertype"="Opaque" "Queue"="Transparent"} LOD $        //Cull Off//turn off back cropping//Lighting Off//This setting does not work in surface shader and appears to be used in unlit shader//Zwrite on//ZTest onBlend srcalpha oneminussrcalpha cgprogram//physically based standard lighting model, and enable Shadows on all light types//#pragma surface surf standard fullforwardshadows Alpha Vertex:vert        #pragmaSurface surf Nolightmodel fullforwardshadows Alpha Vertex:vert//Use Shader Model 3.0 target, to get nicer looking lighting        #pragmaTarget 3.0sampler2d _maintex; structInput {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, the shader. // Seehttps://docs.unity3d.com/Manual/GPUInstancing.htmlFor more information about instancing. //#pragma instancing_options assumeuniformscalingUnity_instancing_cbuffer_start (Props)//put more per-instance properties hereUnity_instancing_cbuffer_endvoidSurf (Input in, InOut surfaceoutput o) {//Albedo comes from a texture tinted by colorFixed4 C = tex2d (_maintex, In.uv_maintex) *_color; O.albedo=C.rgb; //FLOAT4 tmp = Mul (Unity_worldtoobject, in.modelpos_);            if(Fmod ((in.modelpos_.z-_time.y*_speed)/_stripwidth),3)!=0)            {                //clip ( -1);Discard; }            //o.alpha = C.A;O.alpha =_transval; }        voidVert (inout Appdata_full V, outInput o)            {unity_initialize_output (Input, O); O.modelpos_=V.vertex; }        //naming rules: Lighting the name after #pragma suface//Lightdir: Point-to-light unit vector viewdir: point to camera unit vector atten: attenuation factorfloat4 Lightingnolightmodel (surfaceoutput s, float3 Lightdir, Half3 viewdir, half atten) {f            LOAT4 C; C.rgb=S.albedo; C.A=S.alpha; returnC; } ENDCG} FallBack"Diffuse"}

Unity turns off the lighting model in shader and how to customize the lighting model

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.