PageRenderTime 30ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/app_settings/shaders/class3/deferred/postgiF.glsl

https://bitbucket.org/lindenlab/viewer-beta/
text | 89 lines | 68 code | 21 blank | 0 comment | 0 complexity | ab745093c46ed703fbcb5545bff03e92 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file postgiF.glsl
  3. *
  4. * $LicenseInfo:firstyear=2007&license=viewerlgpl$
  5. * Second Life Viewer Source Code
  6. * Copyright (C) 2007, Linden Research, Inc.
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation;
  11. * version 2.1 of the License only.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. *
  22. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  23. * $/LicenseInfo$
  24. */
  25. #extension GL_ARB_texture_rectangle : enable
  26. uniform sampler2DRect depthMap;
  27. uniform sampler2DRect normalMap;
  28. uniform sampler2DRect giLightMap;
  29. uniform sampler2D noiseMap;
  30. uniform sampler2D giMip;
  31. uniform sampler2DRect edgeMap;
  32. uniform vec2 delta;
  33. uniform float kern_scale;
  34. uniform float gi_edge_weight;
  35. uniform float gi_blur_brightness;
  36. varying vec2 vary_fragcoord;
  37. void main()
  38. {
  39. vec2 dlt = kern_scale*delta;
  40. float defined_weight = 0.0;
  41. vec3 col = vec3(0.0);
  42. float e = 1.0;
  43. for (int i = 1; i < 8; i++)
  44. {
  45. vec2 tc = vary_fragcoord.xy + float(i) * dlt;
  46. e = max(e, 0.0);
  47. float wght = e;
  48. col += texture2DRect(giLightMap, tc).rgb*wght;
  49. defined_weight += wght;
  50. e *= e;
  51. e -=(texture2DRect(edgeMap, tc.xy-dlt*0.25).a+
  52. texture2DRect(edgeMap, tc.xy+dlt*0.25).a)*gi_edge_weight;
  53. }
  54. e = 1.0;
  55. for (int i = 1; i < 8; i++)
  56. {
  57. vec2 tc = vary_fragcoord.xy - float(i) * dlt;
  58. e = max(e,0.0);
  59. float wght = e;
  60. col += texture2DRect(giLightMap, tc).rgb*wght;
  61. defined_weight += wght;
  62. e *= e;
  63. e -= (texture2DRect(edgeMap, tc.xy-dlt*0.25).a+
  64. texture2DRect(edgeMap, tc.xy+dlt*0.25).a)*gi_edge_weight;
  65. }
  66. col /= max(defined_weight, 0.01);
  67. gl_FragColor.rgb = col * gi_blur_brightness;
  68. }