fs_hdr_lum.sc 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. $input v_texcoord0
  2. /*
  3. * Copyright 2011-2025 Branimir Karadzic. All rights reserved.
  4. * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
  5. */
  6. #include "common.sh"
  7. SAMPLER2D(s_texColor, 0);
  8. void main()
  9. {
  10. float delta = 0.0001;
  11. vec3 rgb0 = decodeRGBE8(texture2D(s_texColor, v_texcoord0+u_offset[0].xy) );
  12. vec3 rgb1 = decodeRGBE8(texture2D(s_texColor, v_texcoord0+u_offset[1].xy) );
  13. vec3 rgb2 = decodeRGBE8(texture2D(s_texColor, v_texcoord0+u_offset[2].xy) );
  14. vec3 rgb3 = decodeRGBE8(texture2D(s_texColor, v_texcoord0+u_offset[3].xy) );
  15. vec3 rgb4 = decodeRGBE8(texture2D(s_texColor, v_texcoord0+u_offset[4].xy) );
  16. vec3 rgb5 = decodeRGBE8(texture2D(s_texColor, v_texcoord0+u_offset[5].xy) );
  17. vec3 rgb6 = decodeRGBE8(texture2D(s_texColor, v_texcoord0+u_offset[6].xy) );
  18. vec3 rgb7 = decodeRGBE8(texture2D(s_texColor, v_texcoord0+u_offset[7].xy) );
  19. vec3 rgb8 = decodeRGBE8(texture2D(s_texColor, v_texcoord0+u_offset[8].xy) );
  20. float avg = luma(rgb0).x
  21. + luma(rgb1).x
  22. + luma(rgb2).x
  23. + luma(rgb3).x
  24. + luma(rgb4).x
  25. + luma(rgb5).x
  26. + luma(rgb6).x
  27. + luma(rgb7).x
  28. + luma(rgb8).x
  29. ;
  30. avg *= 1.0/9.0;
  31. gl_FragColor = encodeRE8(avg);
  32. }