From ff7220349d32e747c7559809d68de7d835c0c1cd Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Tue, 17 Feb 2015 18:08:28 +0100 Subject: Compositing works with X-Ray. Basically, before drawing X-Rays, we now bind a second depth buffer. After drawing XRays, we do an extra resolve pass where we overwrite the non-XRay depth buffer in pixels where the depth is not maximum (which means background pixel, since depth is cleared before drawing X-Ray objects). This ensures both scene and X-Rays keep their depth values and are ready for compositing. Well, the odd effect due to depth discontinuities can be expected, and X-Rays are a bit more expensive (extra buffer + resolve pass) but at least X-Rays won't invalidate depth values anymore. Whee! --- source/blender/gpu/GPU_compositing.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source/blender/gpu/GPU_compositing.h') diff --git a/source/blender/gpu/GPU_compositing.h b/source/blender/gpu/GPU_compositing.h index 796341d4830..93f1bc64922 100644 --- a/source/blender/gpu/GPU_compositing.h +++ b/source/blender/gpu/GPU_compositing.h @@ -60,10 +60,12 @@ typedef enum GPUFXShaderEffect { GPU_SHADER_FX_DEPTH_OF_FIELD_PASS_THREE = 4, GPU_SHADER_FX_DEPTH_OF_FIELD_PASS_FOUR = 5, GPU_SHADER_FX_DEPTH_OF_FIELD_PASS_FIVE = 6, + + GPU_SHADER_FX_DEPTH_RESOLVE = 7, } GPUFXShaderEffect; /* keep in synch with enum above! */ -#define MAX_FX_SHADERS 11 +#define MAX_FX_SHADERS 8 /* generate a new FX compositor */ GPUFX *GPU_fx_compositor_create(void); @@ -79,6 +81,12 @@ bool GPU_fx_compositor_initialize_passes( /* do compositing on the fx passes that have been initialized */ bool GPU_fx_do_composite_pass(GPUFX *fx, float projmat[4][4], bool is_persp, struct Scene *scene, struct GPUOffScreen *ofs); +/* bind new depth buffer for XRay pass */ +void GPU_fx_compositor_setup_XRay_pass(GPUFX *fx, bool do_xray); + +/* resolve a final depth buffer by compositing the XRay and normal depth buffers */ +void GPU_fx_compositor_XRay_resolve(GPUFX *fx); + void GPU_fx_compositor_init_dof_settings(struct GPUDOFSettings *dof); void GPU_fx_compositor_init_ssao_settings(struct GPUSSAOSettings *ssao); #ifdef __cplusplus -- cgit v1.2.3