Workbench: Attenuate dithering effect when using viewport render
Quick hack to get rid of most of the noise when doing a viewport render in xray or wireframe mode.
This commit is contained in:
parent
d86e77ac16
commit
4e23c69bfa
|
@ -9,6 +9,7 @@ const vec4 dither_mat[4] = vec4[4](
|
|||
);
|
||||
|
||||
uniform float threshold = 0.5;
|
||||
uniform float offset = 0.0;
|
||||
|
||||
/* Noise dithering pattern
|
||||
* 0 - Bayer matrix
|
||||
|
@ -24,7 +25,7 @@ void main()
|
|||
#elif NOISE == 1
|
||||
/* Interlieved gradient noise by Jorge Jimenez
|
||||
* http://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare */
|
||||
float noise = fract(52.9829189 * fract(0.06711056 * gl_FragCoord.x + 0.00583715 * gl_FragCoord.y));
|
||||
float noise = fract(offset + 52.9829189 * fract(0.06711056 * gl_FragCoord.x + 0.00583715 * gl_FragCoord.y));
|
||||
#else
|
||||
#error
|
||||
#endif
|
||||
|
|
|
@ -363,8 +363,14 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata)
|
|||
|
||||
/* Checker Depth */
|
||||
{
|
||||
static float noise_offset = 0.0f;
|
||||
float blend_threshold = 0.0f;
|
||||
|
||||
if (DRW_state_is_image_render()) {
|
||||
/* TODO: Should be based on the number of samples used for render. */
|
||||
noise_offset = fmodf(noise_offset + 1.0f/8.0f, 1.0f);
|
||||
}
|
||||
|
||||
if (wpd->shading.flag & XRAY_FLAG(wpd)) {
|
||||
blend_threshold = 0.75f - XRAY_ALPHA(wpd) * 0.5f;
|
||||
}
|
||||
|
@ -379,6 +385,7 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata)
|
|||
grp = DRW_shgroup_create(e_data.checker_depth_sh, psl->checker_depth_pass);
|
||||
DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
|
||||
DRW_shgroup_uniform_float_copy(grp, "threshold", blend_threshold);
|
||||
DRW_shgroup_uniform_float_copy(grp, "offset", noise_offset);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue