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

      

  • 相关阅读:
    大数据技术栈,主要有哪些
    微服务海量日志监控平台
    Elastic APM安装
    Elasticsearch SSL认证/证书制作
    Elastic APM 上报数据分析与应用
    elasticsearch7.X x-pack破解
    Netty源码学习系列之5-NioEventLoop的run方法
    Netty源码学习系列之4-ServerBootstrap的bind方法
    Netty源码学习系列之3-ServerBootstrap的初始化
    Netty源码学习系列之2-NioEventLoopGroup的初始化
  • 原文地址:https://www.cnblogs.com/wbaoqing/p/9811385.html
Copyright © 2011-2022 走看看