postDeferredF.glsl
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:2k
源码类别:

游戏引擎

开发平台:

C++ Builder

  1. /** 
  2.  * @file postDeferredF.glsl
  3.  *
  4.  * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
  5.  * $License$
  6.  */
  7. uniform sampler2DRect diffuseRect;
  8. uniform sampler2DRect localLightMap;
  9. uniform sampler2DRect sunLightMap;
  10. uniform sampler2DRect giLightMap;
  11. uniform sampler2D   luminanceMap;
  12. uniform sampler2DRect lightMap;
  13. uniform vec3 gi_lum_quad;
  14. uniform vec3 sun_lum_quad;
  15. uniform vec3 lum_quad;
  16. uniform float lum_lod;
  17. uniform vec4 ambient;
  18. uniform vec3 gi_quad;
  19. uniform vec2 screen_res;
  20. varying vec2 vary_fragcoord;
  21. void main() 
  22. {
  23. vec2 tc = vary_fragcoord.xy;
  24. vec3 lcol = texture2DLod(luminanceMap, tc/screen_res, lum_lod).rgb;
  25. float lum = sqrt(lcol.r)*lum_quad.x+lcol.r*lcol.r*lum_quad.y+lcol.r*lum_quad.z;
  26. vec4 diff = texture2DRect(diffuseRect, vary_fragcoord.xy);
  27. float ambocc = texture2DRect(lightMap, vary_fragcoord.xy).g;
  28. vec3 gi_col = texture2DRect(giLightMap, vary_fragcoord.xy).rgb;
  29. gi_col = gi_col*gi_col*gi_quad.x + gi_col*gi_quad.y+gi_quad.z*ambocc*ambient.rgb;
  30. gi_col *= diff;
  31. vec4 sun_col = texture2DRect(sunLightMap, vary_fragcoord.xy);
  32. vec3 local_col = texture2DRect(localLightMap, vary_fragcoord.xy).rgb;
  33. float sun_lum = 1.0-lum;
  34. sun_lum = sun_lum*sun_lum*sun_lum_quad.x + sun_lum*sun_lum_quad.y+sun_lum_quad.z;
  35. float gi_lum = lum;
  36. gi_lum = gi_lum*gi_lum*gi_lum_quad.x+gi_lum*gi_lum_quad.y+gi_lum_quad.z;
  37. gi_col *= 1.0/gi_lum;
  38. vec3 col = sun_col.rgb*(1.0+max(sun_lum,0.0))+gi_col+local_col;
  39. gl_FragColor.rgb = col.rgb;
  40. gl_FragColor.a = max(sun_lum*min(sun_col.r+sun_col.g+sun_col.b, 1.0), sun_col.a);
  41. //gl_FragColor.rgb = texture2DRect(giLightMap, vary_fragcoord.xy).rgb;
  42. }