HDR

原文链接: http://www.cnblogs.com/ActionFG/archive/2012/09/09/2677483.html
  1. const float MIDDLE_GREY = 0.72;
    const float FUDGE = 0.001;
    const float L_WHITE = 1.5;
    
    /** Tone mapping function
    @note Only affects rgb, not a
    @param inColour The HDR colour
    @param lum The scene lumninence
    @returns Tone mapped colour
    */
    vec4 toneMap(in vec4 inColour, in float lum)
    {
        // From Reinhard et al
        // "Photographic Tone Reproduction for Digital Images"
       
        // Initial luminence scaling (equation 2)
        inColour.rgb *= MIDDLE_GREY / (FUDGE + lum);
    
        // Control white out (equation 4 nom)
        inColour.rgb *= (1.0 + inColour.rgb / L_WHITE);
    
        // Final mapping (equation 4 denom)
        inColour.rgb /= (1.0 + inColour.rgb);
       
        return inColour;
    
    }

     

其中a可理解为:exposure

Lw = 0.27 * R + 0.67 * G + 0.06 * B

最终输出:(color / Lw) * Ld;

主要三部:

  • DownSamplePass:2*2亮度过滤、最后3*3 downSample到一个像素得到平均亮度——lum
  • BrightPass:将场景图 max(3*3平均 - vec4(0.6), 0.0),并将结果与平均亮度进行tonemap(色泽贴图)——brightMap
  • BloomPass:将brightMap分别进行纵向、横向加权和(15个像素)——BloomMap
  • 合并:Tonemap(sceneColor, lum)+ BloomColor

转载于:https://www.cnblogs.com/ActionFG/archive/2012/09/09/2677483.html

你可能感兴趣的:(HDR)