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>2017-07-24 12:18:11 +0300
committerClément Foucault <foucault.clem@gmail.com>2017-07-24 16:36:37 +0300
commit27dd82a951776a6a322a1009667a6cc6f4331b01 (patch)
tree5f3cd8f005851389b2b3a5c503cc4e867d36a696 /source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
parent7585c8272201856e8504a93b435d3bed3476b98e (diff)
Eevee: SSR: Refactor multiple rays. Plus other changes...
-Allow a maximum of 4 rays per trace pixel. -Removes parameter Normalize: use normalization all the time now. -Add firefly clamp slider.
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl')
-rw-r--r--source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl24
1 files changed, 17 insertions, 7 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl b/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
index f017453bad0..421079c0bfa 100644
--- a/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
@@ -21,15 +21,20 @@ void swapIfBigger(inout float a, inout float b)
}
}
-/* Return the length of the ray if there is a hit, and -1.0 if not hit occured */
+/* Return the length of the ray if there is a hit, and negate it if not hit occured */
float raycast(sampler2D depth_texture, vec3 ray_origin, vec3 ray_dir, float ray_jitter)
{
float near = get_view_z_from_depth(0.0); /* TODO optimize */
+ float far = get_view_z_from_depth(1.0); /* TODO optimize */
- /* Clip ray to a near plane in 3D */
+ /* Clip ray to a near/far plane in 3D */
float ray_length = 1e16;
- if ((ray_origin.z + ray_dir.z * ray_length) > near)
+ if ((ray_origin.z + ray_dir.z * ray_length) > near) {
ray_length = (near - ray_origin.z) / ray_dir.z;
+ }
+ else {
+ ray_length = (ray_origin.z - far) / -ray_dir.z;
+ }
vec3 ray_end = ray_dir * ray_length + ray_origin;
@@ -136,7 +141,7 @@ float raycast(sampler2D depth_texture, vec3 ray_origin, vec3 ray_dir, float ray_
prev_zmax = (dPQK.z * -0.5 + pqk.z) / (dPQK.w * -0.5 + pqk.w);
- for (float refinestep = 0.0; refinestep < ssrStride * 2.0 && refinestep < MAX_REFINE_STEP * 2.0; refinestep++) {
+ for (float refinestep = 0.0; refinestep < (ssrStride * 2.0) && refinestep < (MAX_REFINE_STEP * 2.0); refinestep++) {
/* step through current cell */
pqk += dPQK;
@@ -159,9 +164,14 @@ float raycast(sampler2D depth_texture, vec3 ray_origin, vec3 ray_dir, float ray_
}
}
- /* Background case. */
- hit = hit && (raw_depth != 1.0);
+ /* If we did hit the background, get exact ray. */
+ if (raw_depth == 1.0) {
+ zmax = get_view_z_from_depth(1.0); /* TODO optimize */
+ }
+
+ hit = hit && (raw_depth != 0.0);
/* Return length */
- return (hit) ? (zmax - ray_origin.z) / ray_dir.z : -1.0;
+ float result = (zmax - ray_origin.z) / ray_dir.z;
+ return (hit) ? result : -result;
}