diff options
author | Rider Linden <rider@lindenlab.com> | 2019-01-31 23:06:53 +0000 |
---|---|---|
committer | Rider Linden <rider@lindenlab.com> | 2019-01-31 23:06:53 +0000 |
commit | 2456715a407cc11f3e0077cb3c54e21188e6ec86 (patch) | |
tree | b52162e8c228c2822d9a1165a1c81dfa3e47661e /indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl | |
parent | 29e8215faaf0ed949ffadd81eeb92b43d6af1f3f (diff) | |
parent | f1ee481b82275cfadbce156514920750ebdd3065 (diff) |
Merged in graham_linden/viewer-eep-fixes (pull request #253)
SL-10443, SL-9994, SL-10374, SL-10081
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl')
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl index 3bb59dd7f9..23adbded5e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl @@ -24,13 +24,43 @@ */ uniform sampler2D noiseMap; +uniform sampler2DRect normalMap; +uniform sampler2DRect depthMap; uniform float ssao_radius; uniform float ssao_max_radius; uniform float ssao_factor; uniform float ssao_factor_inv; -vec4 getPosition(vec2 pos_screen); +uniform mat4 inv_proj; +uniform vec2 screen_res; + +vec2 getScreenCoordinateAo(vec2 screenpos) +{ + vec2 sc = screenpos.xy * 2.0; + if (screen_res.x > 0 && screen_res.y > 0) + { + sc /= screen_res; + } + return sc - vec2(1.0, 1.0); +} + +float getDepthAo(vec2 pos_screen) +{ + float depth = texture2DRect(depthMap, pos_screen).r; + return depth; +} + +vec4 getPositionAo(vec2 pos_screen) +{ + float depth = getDepthAo(pos_screen); + vec2 sc = getScreenCoordinateAo(pos_screen); + vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); + vec4 pos = inv_proj * ndc; + pos /= pos.w; + pos.w = 1.0; + return pos; +} vec2 getKern(int i) { @@ -64,7 +94,7 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm, vec2 pos_screen) for (int i = 0; i < 8; i++) { vec2 samppos_screen = pos_screen + scale * reflect(getKern(i), noise_reflect); - vec3 samppos_world = getPosition(samppos_screen).xyz; + vec3 samppos_world = getPositionAo(samppos_screen).xyz; vec3 diff = pos_world - samppos_world; float dist2 = dot(diff, diff); |