PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://bitbucket.org/lindenlab/viewer-beta/
text | 100 lines | 76 code | 24 blank | 0 comment | 0 complexity | 8da74362fb8772a0c0b1c3e8d56f9bfc MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file postDeferredF.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 diffuseRect;
  27. uniform sampler2DRect specularRect;
  28. uniform sampler2DRect localLightMap;
  29. uniform sampler2DRect sunLightMap;
  30. uniform sampler2DRect giLightMap;
  31. uniform sampler2DRect edgeMap;
  32. uniform sampler2D luminanceMap;
  33. uniform sampler2DRect lightMap;
  34. uniform sampler2D lightFunc;
  35. uniform sampler2D noiseMap;
  36. uniform float sun_lum_scale;
  37. uniform float sun_lum_offset;
  38. uniform float lum_scale;
  39. uniform float lum_lod;
  40. uniform vec4 ambient;
  41. uniform float gi_brightness;
  42. uniform float gi_luminance;
  43. uniform vec4 sunlight_color;
  44. uniform vec2 screen_res;
  45. varying vec2 vary_fragcoord;
  46. void main()
  47. {
  48. vec2 tc = vary_fragcoord.xy;
  49. vec4 lcol = texture2DLod(luminanceMap, vec2(0.5, 0.5), lum_lod);
  50. vec3 gi_col = texture2DRect(giLightMap, vary_fragcoord.xy).rgb;
  51. vec4 sun_col = texture2DRect(sunLightMap, vary_fragcoord.xy);
  52. vec3 local_col = texture2DRect(localLightMap, vary_fragcoord.xy).rgb;
  53. float scol = texture2DRect(lightMap, vary_fragcoord.xy).r;
  54. vec3 diff = texture2DRect(diffuseRect, vary_fragcoord.xy).rgb;
  55. vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
  56. gi_col = gi_col*(diff.rgb+spec.rgb*spec.a);
  57. float lum = 1.0-clamp(pow(lcol.r, gi_brightness)+sun_lum_offset, 0.0, 1.0);
  58. lum *= sun_lum_scale;
  59. sun_col *= 1.0+(lum*lum_scale*scol);
  60. vec4 col;
  61. col.rgb = gi_col+sun_col.rgb+local_col;
  62. col.a = sun_col.a;
  63. vec3 bcol = vec3(0,0,0);
  64. float tweight = 0.0;
  65. for (int i = 0; i < 16; i++)
  66. {
  67. float weight = (float(i)+1.0)/2.0;
  68. bcol += texture2DLod(luminanceMap, vary_fragcoord.xy/screen_res, weight).rgb*weight*weight*weight;
  69. tweight += weight*weight;
  70. }
  71. bcol /= tweight;
  72. bcol *= gi_luminance;
  73. col.rgb += bcol*lum;
  74. gl_FragColor = col;
  75. //gl_FragColor.rgb = texture2DRect(giLightMap, vary_fragcoord.xy).rgb;
  76. }