diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:17:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:21:24 +0300 |
commit | e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch) | |
tree | 8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/draw/engines/eevee/shaders/effect_gtao_frag.glsl | |
parent | b3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff) |
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.
For details on usage and instructions for migrating branches
without conflicts, see:
https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/effect_gtao_frag.glsl')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/effect_gtao_frag.glsl | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/effect_gtao_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_gtao_frag.glsl index 6a223ddc1fe..eea0ce0aae2 100644 --- a/source/blender/draw/engines/eevee/shaders/effect_gtao_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/effect_gtao_frag.glsl @@ -12,66 +12,66 @@ uniform sampler2D normalBuffer; void main() { - vec2 texel_size = 1.0 / vec2(textureSize(depthBuffer, 0)).xy; - vec2 uvs = saturate(gl_FragCoord.xy * texel_size); + vec2 texel_size = 1.0 / vec2(textureSize(depthBuffer, 0)).xy; + vec2 uvs = saturate(gl_FragCoord.xy * texel_size); - float depth = textureLod(depthBuffer, uvs, 0.0).r; + float depth = textureLod(depthBuffer, uvs, 0.0).r; - vec3 viewPosition = get_view_space_from_depth(uvs, depth); - vec3 V = viewCameraVec; - vec3 normal = normal_decode(texture(normalBuffer, uvs).rg, V); + vec3 viewPosition = get_view_space_from_depth(uvs, depth); + vec3 V = viewCameraVec; + vec3 normal = normal_decode(texture(normalBuffer, uvs).rg, V); - vec3 bent_normal; - float visibility; + vec3 bent_normal; + float visibility; - vec4 noise = texelfetch_noise_tex(gl_FragCoord.xy); + vec4 noise = texelfetch_noise_tex(gl_FragCoord.xy); - gtao_deferred(normal, noise, depth, visibility, bent_normal); + gtao_deferred(normal, noise, depth, visibility, bent_normal); - /* Handle Background case. Prevent artifact due to uncleared Horizon Render Target. */ - FragColor = vec4((depth == 1.0) ? 0.0 : visibility); + /* Handle Background case. Prevent artifact due to uncleared Horizon Render Target. */ + FragColor = vec4((depth == 1.0) ? 0.0 : visibility); } #else -#ifdef LAYERED_DEPTH +# ifdef LAYERED_DEPTH uniform sampler2DArray depthBufferLayered; uniform int layer; -# define gtao_depthBuffer depthBufferLayered -# define gtao_textureLod(a, b, c) textureLod(a, vec3(b, layer), c) +# define gtao_depthBuffer depthBufferLayered +# define gtao_textureLod(a, b, c) textureLod(a, vec3(b, layer), c) -#else -# define gtao_depthBuffer depthBuffer -# define gtao_textureLod(a, b, c) textureLod(a, b, c) +# else +# define gtao_depthBuffer depthBuffer +# define gtao_textureLod(a, b, c) textureLod(a, b, c) -#endif +# endif void main() { - vec2 uvs = saturate(gl_FragCoord.xy / vec2(textureSize(gtao_depthBuffer, 0).xy)); - float depth = gtao_textureLod(gtao_depthBuffer, uvs, 0.0).r; - - if (depth == 1.0) { - /* Do not trace for background */ - FragColor = vec4(0.0); - return; - } - - /* Avoid self shadowing. */ - depth = saturate(depth - 3e-6); /* Tweaked for 24bit depth buffer. */ - - vec3 viewPosition = get_view_space_from_depth(uvs, depth); - vec4 noise = texelfetch_noise_tex(gl_FragCoord.xy); - vec2 max_dir = get_max_dir(viewPosition.z); - vec4 dirs; - dirs.xy = get_ao_dir(noise.x * 0.5); - dirs.zw = get_ao_dir(noise.x * 0.5 + 0.5); - - /* Search in 4 directions. */ - FragColor.xy = search_horizon_sweep(dirs.xy, viewPosition, uvs, noise.y, max_dir); - FragColor.zw = search_horizon_sweep(dirs.zw, viewPosition, uvs, noise.y, max_dir); - - /* Resize output for integer texture. */ - FragColor = pack_horizons(FragColor); + vec2 uvs = saturate(gl_FragCoord.xy / vec2(textureSize(gtao_depthBuffer, 0).xy)); + float depth = gtao_textureLod(gtao_depthBuffer, uvs, 0.0).r; + + if (depth == 1.0) { + /* Do not trace for background */ + FragColor = vec4(0.0); + return; + } + + /* Avoid self shadowing. */ + depth = saturate(depth - 3e-6); /* Tweaked for 24bit depth buffer. */ + + vec3 viewPosition = get_view_space_from_depth(uvs, depth); + vec4 noise = texelfetch_noise_tex(gl_FragCoord.xy); + vec2 max_dir = get_max_dir(viewPosition.z); + vec4 dirs; + dirs.xy = get_ao_dir(noise.x * 0.5); + dirs.zw = get_ao_dir(noise.x * 0.5 + 0.5); + + /* Search in 4 directions. */ + FragColor.xy = search_horizon_sweep(dirs.xy, viewPosition, uvs, noise.y, max_dir); + FragColor.zw = search_horizon_sweep(dirs.zw, viewPosition, uvs, noise.y, max_dir); + + /* Resize output for integer texture. */ + FragColor = pack_horizons(FragColor); } #endif |