diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-07-21 16:06:29 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-07-24 16:28:27 +0300 |
commit | 18aa6cf1cc66ace97f23d984d8cce528ebc9f77d (patch) | |
tree | e7751c3880e0f2774bf719f12c7117a2746fa184 /source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl | |
parent | e0c1323737c1ba018decd2686c971471deab9f01 (diff) |
Eevee: SSR: Add fullscreen raytrace.
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl index e266dac6d22..4473d73c5c8 100644 --- a/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl @@ -34,15 +34,24 @@ layout(location = 1) out vec4 pdfData; void main() { +#ifdef FULLRES + ivec2 fullres_texel = ivec2(gl_FragCoord.xy); + ivec2 halfres_texel = fullres_texel; +#else ivec2 fullres_texel = ivec2(gl_FragCoord.xy) * 2; ivec2 halfres_texel = ivec2(gl_FragCoord.xy); +#endif + float depth = texelFetch(depthBuffer, fullres_texel, 0).r; /* Early out */ if (depth == 1.0) discard; - vec2 uvs = gl_FragCoord.xy * 2.0 / vec2(textureSize(depthBuffer, 0)); + vec2 uvs = gl_FragCoord.xy / vec2(textureSize(depthBuffer, 0)); +#ifndef FULLRES + uvs *= 2.0; +#endif /* Using view space */ vec3 viewPosition = get_view_space_from_depth(uvs, depth); @@ -75,8 +84,10 @@ void main() /* Raycast over screen */ float hit_dist = -1.0; + /* Only raytrace if ray is above the surface normal */ + /* Note : this still fails in some cases like with normal map. + * We should check against the geometric normal but we don't have it at this stage. */ if (dot(R, N) > 0.0001) { - /* Only raytrace if ray is above the surface normal */ hit_dist = raycast(depthBuffer, viewPosition, R); } @@ -195,8 +206,12 @@ float screen_border_mask(vec2 past_hit_co, vec3 hit) void main() { - ivec2 halfres_texel = ivec2(gl_FragCoord.xy / 2.0); ivec2 fullres_texel = ivec2(gl_FragCoord.xy); +#ifdef FULLRES + ivec2 halfres_texel = fullres_texel; +#else + ivec2 halfres_texel = ivec2(gl_FragCoord.xy / 2.0); +#endif vec2 texture_size = vec2(textureSize(depthBuffer, 0)); vec2 uvs = gl_FragCoord.xy / texture_size; vec3 rand = texelFetch(utilTex, ivec3(fullres_texel % LUT_SIZE, 2), 0).rba; |