From de2ea031bc8d249b7e45a1e2e002c30a25ab614b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Thu, 12 Oct 2023 12:40:22 +0200 Subject: [PATCH] Fix EEVE-Next: Broken Parallax Parallax distance was not actually use. It was affecting the world and had unwanted effect if lower than influence radius. --- .../draw/engines/eevee_next/eevee_reflection_probes.cc | 4 +++- .../eevee_next/shaders/eevee_lightprobe_eval_lib.glsl | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/source/blender/draw/engines/eevee_next/eevee_reflection_probes.cc b/source/blender/draw/engines/eevee_next/eevee_reflection_probes.cc index 53c94183a26..530ac4d41b8 100644 --- a/source/blender/draw/engines/eevee_next/eevee_reflection_probes.cc +++ b/source/blender/draw/engines/eevee_next/eevee_reflection_probes.cc @@ -293,7 +293,9 @@ void ReflectionProbeModule::sync_object(Object *ob, ObjectHandle &ob_handle) } bool use_custom_parallax = (light_probe.flag & LIGHTPROBE_FLAG_CUSTOM_PARALLAX) != 0; - float parallax_distance = use_custom_parallax ? light_probe.distpar : light_probe.distinf; + float parallax_distance = use_custom_parallax ? + max_ff(light_probe.distpar, light_probe.distinf) : + light_probe.distinf; float influence_distance = light_probe.distinf; float influence_falloff = light_probe.falloff; probe.influence_shape = (light_probe.attenuation_type == LIGHTPROBE_SHAPE_BOX) ? SHAPE_CUBOID : diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_lightprobe_eval_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_lightprobe_eval_lib.glsl index 2a2d8acb158..ef9da30dedd 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_lightprobe_eval_lib.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_lightprobe_eval_lib.glsl @@ -222,9 +222,13 @@ LightProbeSample lightprobe_load(vec3 P, vec3 Ng, vec3 V) /* Return the best parallax corrected ray direction from the probe center. */ vec3 lightprobe_sphere_parallax(ReflectionProbeData probe, vec3 P, vec3 L) { + bool is_world = (probe.influence_scale == 0.0); + if (is_world) { + return L; + } /* Correct reflection ray using parallax volume intersection. */ vec3 lP = vec4(P, 1.0) * probe.world_to_probe_transposed; - vec3 lL = L * mat3x3(probe.world_to_probe_transposed); + vec3 lL = (mat3x3(probe.world_to_probe_transposed) * L) / probe.parallax_distance; float dist = (probe.parallax_shape == SHAPE_ELIPSOID) ? line_unit_sphere_intersect_dist(lP, lL) : line_unit_box_intersect_dist(lP, lL);