diff options
author | Dave Parks <davep@lindenlab.com> | 2022-10-06 18:40:01 -0500 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2022-10-06 18:40:01 -0500 |
commit | 9448db5d4af7bba094e5bc51f85e5c2491d3f5a1 (patch) | |
tree | 98e3c28316a892512ecf26661a564c8a81832a39 /indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl | |
parent | 2b28fecf4893e103e99328e5b4a13c607498396d (diff) |
SL-18190 Water shader WIP. Better parallax correction for sphere probes. Reduce probe memory footprint. Remove framebuffer copies and move to deprecate stencil buffer usage.
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl')
-rw-r--r-- | indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl b/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl index e8452a9c14..9dd97a80b2 100644 --- a/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl @@ -33,10 +33,20 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif -uniform sampler2DRect screenMap; +// NOTE screenMap should always be texture channel 0 and +// depthmap should always be channel 1 +uniform sampler2DRect diffuseRect; +uniform sampler2DRect depthMap; + +uniform float resScale; +uniform float znear; +uniform float zfar; VARYING vec2 vary_texcoord0; +// get linear depth value given a depth buffer sample d and znear and zfar values +float linearDepth(float d, float znear, float zfar); + void main() { #if 0 @@ -74,6 +84,18 @@ void main() frag_color = vec4(color, 1.0); #else - frag_color = vec4(texture2DRect(screenMap, vary_texcoord0.xy).rgb, 1.0); + vec2 depth_tc = vary_texcoord0.xy * resScale; + float depth = texture(depthMap, depth_tc).r; + float dist = linearDepth(depth, znear, zfar); + + // convert linear depth to distance + vec3 v; + v.xy = depth_tc / 512.0 * 2.0 - 1.0; + v.z = 1.0; + v = normalize(v); + dist /= v.z; + + vec3 col = texture2DRect(diffuseRect, vary_texcoord0.xy).rgb; + frag_color = vec4(col, dist/256.0); #endif } |