• 金属流,高光流,粗照度流 傻傻分不清


    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;
    }
    

      

  • 相关阅读:
    win10以管理员身份打开hosts文件并编辑保存
    Thrift 初探
    MySQL 批量插入或更新数万条数据
    C# 退出应用程序的几种方法
    Antd VUE中table子表同时只展开一个子信息的说明
    C++ 中的 volatile,atomic 及 memory barrier
    C++计算代码执行时间
    css学习笔记
    剑指 Offer II 021. 删除链表的倒数第 n 个结点
    剑指 Offer II 026. 重排链表
  • 原文地址:https://www.cnblogs.com/wbaoqing/p/9811385.html
Copyright © 2020-2023  润新知