Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2019-03-12 17:45:44 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-03-12 18:01:23 +0300
commitaaeca5d87244bca2832b86d60457f0568acf1427 (patch)
tree1a06cfe4459de9077ba82c941eeaa712f58d593f /source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
parentccb4484ea346d640fcd583ced9137313382390ad (diff)
Eevee: Planar Ref.: Invert view matrix to remove triangle front face flip
This was the cause of some issue with normal mapping. This way is cleaner since it does not modify the state of the drawcalls and other ad-hoc solutions to fix the problems down the road. Unfortunately, it does require to fix every sampling coordinate for this texture. Fix T62215: flipped normals in reflection plane
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl')
-rw-r--r--source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl16
1 files changed, 11 insertions, 5 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl b/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
index c9f2d64f30b..d5a51f89e81 100644
--- a/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
@@ -59,7 +59,7 @@ float refine_isect(float prev_delta, float curr_delta)
}
void prepare_raycast(
- vec3 ray_origin, vec3 ray_dir, float thickness, out vec4 ss_step, out vec4 ss_ray, out float max_time)
+ vec3 ray_origin, vec3 ray_dir, float thickness, int index, out vec4 ss_step, out vec4 ss_ray, out float max_time)
{
/* Negate the ray direction if it goes towards the camera.
* This way we don't need to care if the projected point
@@ -106,10 +106,16 @@ void prepare_raycast(
/* Convert to texture coords. Z component included
* since this is how it's stored in the depth buffer.
* 4th component how far we are on the ray */
- ss_ray = ss_start * 0.5 + 0.5;
- ss_step *= 0.5;
+#ifdef PLANAR_PROBE_RAYTRACE
+ /* Planar Reflections have X mirrored. */
+ vec2 m = (index > -1) ? vec2(-0.5, 0.5) : vec2(0.5);
+#else
+ const vec2 m = vec2(0.5);
+#endif
+ ss_ray = ss_start * m.xyyy + 0.5;
+ ss_step *= m.xyyy;
- ss_ray.xy += 0.5 * ssrPixelSize * 2.0; /* take the center of the texel. * 2 because halfres. */
+ ss_ray.xy += m * ssrPixelSize * 2.0; /* take the center of the texel. * 2 because halfres. */
}
/* See times_and_deltas. */
@@ -127,7 +133,7 @@ vec3 raycast(
{
vec4 ss_step, ss_start;
float max_time;
- prepare_raycast(ray_origin, ray_dir, thickness, ss_step, ss_start, max_time);
+ prepare_raycast(ray_origin, ray_dir, thickness, index, ss_step, ss_start, max_time);
float max_trace_time = max(0.001, max_time - 0.01);