diff options
author | Alexander Romanov <a.romanov@blend4web.com> | 2016-04-27 12:14:13 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-04-27 12:53:24 +0300 |
commit | c0ae38f65642da42909420e444ef464686773e49 (patch) | |
tree | d39cf3226e1690762890ccd44d37011693dbfa17 /source | |
parent | 7f0cf3ab382ecbd06049d2fb231790a107014a1f (diff) |
Fix artifacts w/ low near clear in bglPolygonOffset
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/screen/glutil.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index b7ad911b6f5..a1c330d9dff 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -795,8 +795,13 @@ void bglPolygonOffset(float viewdist, float dist) #endif } else { - /* should be clipping value or so... */ - offs = 0.0005f * dist; + /* This adjustment effectively results in reducing the Z value by 0.25%. + * + * winmat[14] actually evaluates to `-2 * far * near / (far - near)`, + * is very close to -0.2 with default clip range, and is used as the coefficient multiplied by `w / z`, + * thus controlling the z dependent part of the depth value. + */ + offs = winmat[14] * -0.0025f * dist; } winmat[14] -= offs; |