diff options
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/ssr_lib.glsl')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/ssr_lib.glsl | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/ssr_lib.glsl b/source/blender/draw/engines/eevee/shaders/ssr_lib.glsl index 15c28efe622..5a09120916a 100644 --- a/source/blender/draw/engines/eevee/shaders/ssr_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/ssr_lib.glsl @@ -39,10 +39,20 @@ vec4 screen_space_refraction(vec3 vP, vec3 N, vec3 V, float ior, float roughness R = transform_direction(ViewMatrix, R); - vec3 hit_pos = raycast( - -1, vP, R * 1e16, ssrThickness, rand.y, ssrQuality, roughnessSquared, false); + Ray ray; + ray.origin = vP; + ray.direction = R * 1e16; - if ((hit_pos.z > 0.0) && (F_eta(ior, dot(H, V)) < 1.0)) { + RayTraceParameters params; + params.thickness = ssrThickness; + params.jitter = rand.y; + params.trace_quality = ssrQuality; + params.roughness = roughnessSquared; + + vec3 hit_pos; + bool hit = raytrace(ray, params, false, hit_pos); + + if (hit && (F_eta(ior, dot(H, V)) < 1.0)) { hit_pos = get_view_space_from_depth(hit_pos.xy, hit_pos.z); float hit_dist = distance(hit_pos, vP); @@ -68,10 +78,7 @@ vec4 screen_space_refraction(vec3 vP, vec3 N, vec3 V, float ior, float roughness vec2 texture_size = vec2(textureSize(colorBuffer, 0).xy); float mip = clamp(log2(cone_footprint * max(texture_size.x, texture_size.y)), 0.0, 9.0); - /* Correct UVs for mipmaping mis-alignment */ - hit_uvs *= mip_ratio_interp(mip); - - vec3 spec = textureLod(colorBuffer, hit_uvs, mip).xyz; + vec3 spec = textureLod(colorBuffer, hit_uvs * hizUvScale.xy, mip).xyz; float mask = screen_border_mask(hit_uvs); return vec4(spec, mask); |