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-06-23 20:19:19 +0300
committerClément Foucault <foucault.clem@gmail.com>2017-06-23 23:51:38 +0300
commit5e3f902eaa35aaba8e6d27dc9d39fdf4d9a37e3e (patch)
tree7a375a2de91824ffe2527bf4b09c0ff898da5ff9 /source/blender/draw/engines/eevee
parent1111e64c72736e84a9f65d426245c759fdf8bfdc (diff)
Eevee: Planar Reflection: Fix precision issue near cliplane.
The problem was that the depth prepass was using the clip plane but not the shading pass. During the clipping stage, the triangle is converted to a quad clipped to the given clip plane. But this introduce subtle changes in the depth when this new geometry is rasterized. Since the shading pass was using an EQUAL depth test, the depth values from the shading pass were not always equal to the depth prepass. Enabling clipping in the shading vertex shader has a too small impact to require a dedicated shader.
Diffstat (limited to 'source/blender/draw/engines/eevee')
-rw-r--r--source/blender/draw/engines/eevee/eevee_materials.c4
-rw-r--r--source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl6
2 files changed, 8 insertions, 2 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c
index f4901ed0c55..035766de911 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -430,7 +430,7 @@ static struct DRWShadingGroup *EEVEE_default_shading_group_get(
}
if (vedata->psl->default_pass[options] == NULL) {
- DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_WIRE;
+ DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_CLIP_PLANES | DRW_STATE_WIRE;
vedata->psl->default_pass[options] = DRW_pass_create("Default Lit Pass", state);
DRWShadingGroup *shgrp = DRW_shgroup_create(e_data.default_lit[options], vedata->psl->default_pass[options]);
@@ -517,7 +517,7 @@ void EEVEE_materials_cache_init(EEVEE_Data *vedata)
}
{
- DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_WIRE;
+ DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_CLIP_PLANES | DRW_STATE_WIRE;
psl->material_pass = DRW_pass_create("Material Shader Pass", state);
}
}
diff --git a/source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl b/source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl
index cf5c8a311f1..998ccfa453a 100644
--- a/source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lit_surface_vert.glsl
@@ -13,6 +13,9 @@ in vec3 nor;
out vec3 worldPosition;
out vec3 viewPosition;
+/* Used for planar reflections */
+uniform vec4 ClipPlanes[1];
+
#ifdef USE_FLAT_NORMAL
flat out vec3 worldNormal;
flat out vec3 viewNormal;
@@ -28,6 +31,9 @@ void main() {
viewNormal = normalize(NormalMatrix * nor);
worldNormal = normalize(WorldNormalMatrix * nor);
+ /* Used for planar reflections */
+ gl_ClipDistance[0] = dot(vec4(worldPosition, 1.0), ClipPlanes[0]);
+
#ifdef ATTRIB
pass_attrib(pos);
#endif