zoukankan      html  css  js  c++  java
  • Unity Diffuse Metal Shader Mod

    Shader "MetalShader"
    {
    Properties {
    _MainTex ("Base (RGB) RefStrGloss (A)", 2D) = "white" {}
    _SkyTex ("SkyCube", Cube) = "" {}
    _BumpMap ("Normalmap", 2D) = "bump" {}
    _Color ("Main Color", Color) = (1,1,1,1)
    _FresnelColor ("Fresnel Color", Color) = (0.5,0.5,0.5,1)
    _Specular ("Specular", Range (0, 10)) = 5
    }
    SubShader {
    Tags { "RenderType" = "Opaque" }
    CGPROGRAM
    #pragma surface surf MetalSpecular

    fixed4 _Color;
    fixed4 _FresnelColor;
    float _Specular;
    sampler2D _MainTex;
    sampler2D _BumpMap;
    samplerCUBE _SkyTex;

    half4 LightingMetalSpecular (SurfaceOutput s, half3 lightDir, half3 viewDir, half atten)
    {
    half diff = max (0, dot (s.Normal, lightDir));
    half fFresnel = saturate(dot(s.Normal, viewDir));

    float3 vReflection = 2 * s.Normal * fFresnel - viewDir;
    float4 envMap = texCUBE(_SkyTex, vReflection);
    envMap.rgb *= s.Gloss * envMap.a * s.Specular;

    float fFresnelSq = fFresnel * fFresnel;
    float4 metalColor = fFresnel * _Color +
    fFresnelSq * _FresnelColor +
    fFresnelSq * fFresnelSq * (1- _FresnelColor);

    float fEnvContribution = saturate(1.0 - 0.5 * fFresnel);

    half4 c;
    c.rgb = (envMap.rgb * fEnvContribution + metalColor * (diff + _FresnelColor.a) * _LightColor0.rgb) * atten;
    c.a = s.Alpha;
    return c;
    }

    struct Input {
    float2 uv_MainTex;
    float2 uv_BumpMap;
    };

    void surf (Input IN, inout SurfaceOutput o)
    {
    fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
    o.Albedo = tex.rgb;
    o.Gloss = tex.a;
    o.Specular = _Specular;
    o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
    o.Alpha = 1;
    }
    ENDCG
    }
    Fallback Off
    }

  • 相关阅读:
    数据取证任务
    VMware虚拟机重置密码
    pon(无源光纤网络)
    Gpon与Epon的区别
    DNS相关
    牛人博客收集
    值得细细品读的URL资源
    SQL注入
    IPSec方案部署(多业务场景)
    python专题-函数式编程
  • 原文地址:https://www.cnblogs.com/bearworks/p/5264166.html
Copyright © 2011-2022 走看看