zoukankan      html  css  js  c++  java
  • 金属流,高光流,粗照度流 傻傻分不清

    half4 SpecularGloss(float2 uv)
    {
        half4 sg;
    #ifdef _SPECGLOSSMAP
        #if defined(_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A)
            sg.rgb = tex2D(_SpecGlossMap, uv).rgb;
            sg.a = tex2D(_MainTex, uv).a;
        #else
            sg = tex2D(_SpecGlossMap, uv);
        #endif
        sg.a *= _GlossMapScale;
    #else
        sg.rgb = _SpecColor.rgb;
        #ifdef _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
            sg.a = tex2D(_MainTex, uv).a * _GlossMapScale;
        #else
            sg.a = _Glossiness;
        #endif
    #endif
        return sg;
    }
    
    half2 MetallicGloss(float2 uv)
    {
        half2 mg;
    
    #ifdef _METALLICGLOSSMAP
        #ifdef _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
            mg.r = tex2D(_MetallicGlossMap, uv).r;
            mg.g = tex2D(_MainTex, uv).a;
        #else
            mg = tex2D(_MetallicGlossMap, uv).ra;
        #endif
        mg.g *= _GlossMapScale;
    #else
        mg.r = _Metallic;
        #ifdef _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
            mg.g = tex2D(_MainTex, uv).a * _GlossMapScale;
        #else
            mg.g = _Glossiness;
        #endif
    #endif
        return mg;
    }
    
    half2 MetallicRough(float2 uv)
    {
        half2 mg;
    #ifdef _METALLICGLOSSMAP
        mg.r = tex2D(_MetallicGlossMap, uv).r;
    #else
        mg.r = _Metallic;
    #endif
    
    #ifdef _SPECGLOSSMAP
        mg.g = 1.0f - tex2D(_SpecGlossMap, uv).r;
    #else
        mg.g = 1.0f - _Glossiness;
    #endif
        return mg;
    }
    

      

    inline FragmentCommonData SpecularSetup (float4 i_tex)
    {
        half4 specGloss = SpecularGloss(i_tex.xy);
        half3 specColor = specGloss.rgb;
        half smoothness = specGloss.a;
    
        half oneMinusReflectivity;
        half3 diffColor = EnergyConservationBetweenDiffuseAndSpecular (Albedo(i_tex), specColor, /*out*/ oneMinusReflectivity);
    
        FragmentCommonData o = (FragmentCommonData)0;
        o.diffColor = diffColor;
        o.specColor = specColor;
        o.oneMinusReflectivity = oneMinusReflectivity;
        o.smoothness = smoothness;
        return o;
    }
    
    inline FragmentCommonData RoughnessSetup(float4 i_tex)
    {
        half2 metallicGloss = MetallicRough(i_tex.xy);
        half metallic = metallicGloss.x;
        half smoothness = metallicGloss.y; // this is 1 minus the square root of real roughness m.
    
        half oneMinusReflectivity;
        half3 specColor;
        half3 diffColor = DiffuseAndSpecularFromMetallic(Albedo(i_tex), metallic, /*out*/ specColor, /*out*/ oneMinusReflectivity);
    
        FragmentCommonData o = (FragmentCommonData)0;
        o.diffColor = diffColor;
        o.specColor = specColor;
        o.oneMinusReflectivity = oneMinusReflectivity;
        o.smoothness = smoothness;
        return o;
    }
    
    inline FragmentCommonData MetallicSetup (float4 i_tex)
    {
        half2 metallicGloss = MetallicGloss(i_tex.xy);
        half metallic = metallicGloss.x;
        half smoothness = metallicGloss.y; // this is 1 minus the square root of real roughness m.
    
        half oneMinusReflectivity;
        half3 specColor;
        half3 diffColor = DiffuseAndSpecularFromMetallic (Albedo(i_tex), metallic, /*out*/ specColor, /*out*/ oneMinusReflectivity);
    
        FragmentCommonData o = (FragmentCommonData)0;
        o.diffColor = diffColor;
        o.specColor = specColor;
        o.oneMinusReflectivity = oneMinusReflectivity;
        o.smoothness = smoothness;
        return o;
    }
    

      

  • 相关阅读:
    为什么我的Android SDK Manager中只显示已安装的package?
    解决Android Studio Gradle Build特别慢的问题
    一款不错的取色器
    Android Studio没有导包快捷键怎么办
    Android Studio中有没有类似于Eclipse中的ctrl+2+L的快捷键? Android Studio快捷键之代码提示
    安卓动画总结【非原创】
    ButterKnife-5.1.2.jar(较低版本的ButterKnife)使用方法
    【转】调用getActionBar()报Call requires API level 11 (current min is 8): android.app.Activity#getActionBar
    spring容器加载完毕做一件事情(利用ContextRefreshedEvent事件)转
    详解 Spring 3.0 基于 Annotation 的依赖注入实现(转)
  • 原文地址:https://www.cnblogs.com/wbaoqing/p/9811385.html
Copyright © 2011-2022 走看看