Search Unity

About highlights Facula always look at camera,post have shader code,help!

Discussion in 'Shaders' started by zengfanxing, Jul 2, 2015.

?

Such as title,how to modify this shader

  1. 1

    1 vote(s)
    100.0%
  2. 1

    0 vote(s)
    0.0%
  1. zengfanxing

    zengfanxing

    Joined:
    Jul 1, 2015
    Posts:
    2
    Shader"Custom/Facula"
    {
    Properties
    {
    _MainTex ("Texture", 2D) = "white" {}
    _MainPower ("TexturePower", Range(1.0,3.0)) = 1.6
    _MainAlpha ("MainAlpha", Range(0.0,1.0)) = 1
    _TextureFac ("TextureFacula (Alpha)", 2D) = "white" {}
    _RimColor ("RimColor", Color) = (1,0,0,0)
    _RimPower ("RimPower", Range(0.1,5.0)) = 0.1
    _FaculaColor ("FaculaColor", Color) = (1,1,1,0)
    _FaculaPower ("FaculaPower", Range(0.0,2.0)) = 0.4
    }
    SubShader
    {
    Tags {"Queue" = "Transparent"}
    ZWrite Off
    ZTest Always
    CGPROGRAM
    #include "UnityCG.cginc"
    #pragma surface surf Lambert alpha:fade interpolateview noshadow nofog noforwardadd exclude_path:deferred
    structInput
    {
    float2 uv_MainTex;
    float2 uv_TextureFac;
    float3 viewDir;
    float4 screenPos;
    };
    sampler2D _MainTex;
    float _MainPower;
    float _MainAlpha;
    sampler2D _TextureFac;
    float4 _RimColor;
    float _RimPower;
    float4 _FaculaColor;
    float _FaculaPower;
    voidsurf (Input IN, inoutSurfaceOutput o)
    {
    o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb*_MainPower;
    fixed dotValue=dot (normalize(IN.viewDir), o.Normal);
    if(dotValue<=0.3)
    {
    half rim = 1.0 - saturate(dotValue);
    o.Emission = _RimColor.rgb * pow (rim, _RimPower);
    }
    float2 screenUV = IN.screenPos.xy / IN.screenPos.w;
    screenUV=screenUV/_ScreenParams.xy;
    //fixed alpha=tex2D(_TextureFac,screenUV).a; //no facula?
    fixed alpha=tex2D(_TextureFac,IN.uv_TextureFac).a;
    o.Emission += _FaculaColor*alpha*_FaculaPower;
    o.Alpha=_MainAlpha;
    }
    ENDCG
    }
    Fallback"Diffuse"
    }
     
    Last edited: Jul 2, 2015