[Bf-blender-cvs] [d1ed354] viewport_experiments: Fix issue with sculpting and SSAO.

Antony Riakiotakis noreply at git.blender.org
Tue Sep 16 14:09:34 CEST 2014


Commit: d1ed35480eae9f100fc53f94e1c53f77b9440cfc
Author: Antony Riakiotakis
Date:   Tue Sep 16 14:09:21 2014 +0200
Branches: viewport_experiments
https://developer.blender.org/rBd1ed35480eae9f100fc53f94e1c53f77b9440cfc

Fix issue with sculpting and SSAO.

We need to enable stenciling on the compositing FBO or we can clear
areas we don't want to clear and cause invalid depth values.

===================================================================

M	source/blender/editors/space_view3d/view3d_draw.c
M	source/blender/gpu/GPU_compositing.h
M	source/blender/gpu/intern/gpu_compositing.c

===================================================================

diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index af51ca6..3b0caf5 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -3415,7 +3415,7 @@ static void view3d_main_area_draw_objects(const bContext *C, Scene *scene, View3
 		if (!rv3d->compositor)
 			rv3d->compositor = GPU_create_fx_compositor();
 		
-		do_compositing = GPU_initialize_fx_passes(rv3d->compositor, &ar->winrct, v3d->shader_fx);
+		do_compositing = GPU_initialize_fx_passes(rv3d->compositor, &ar->winrct, &ar->drawrct, v3d->shader_fx);
 	}
 	
 	/* clear the background */
diff --git a/source/blender/gpu/GPU_compositing.h b/source/blender/gpu/GPU_compositing.h
index 0fd29ac..b186c0c 100644
--- a/source/blender/gpu/GPU_compositing.h
+++ b/source/blender/gpu/GPU_compositing.h
@@ -55,7 +55,7 @@ GPUFX *GPU_create_fx_compositor(void);
 void GPU_destroy_fx_compositor(GPUFX *fx);
 
 /* initialize a framebuffer with size taken from the viewport */
-bool GPU_initialize_fx_passes(GPUFX *fx, struct rcti *rect, int fxflags);
+bool GPU_initialize_fx_passes(GPUFX *fx, struct rcti *rect, rcti *scissor_rect, int fxflags);
 
 /* do compositing on the fx passes that have been initialized */
 bool GPU_fx_do_composite_pass(GPUFX *fx, struct View3D *v3d);
diff --git a/source/blender/gpu/intern/gpu_compositing.c b/source/blender/gpu/intern/gpu_compositing.c
index 4de29c1..4f03bd8 100644
--- a/source/blender/gpu/intern/gpu_compositing.c
+++ b/source/blender/gpu/intern/gpu_compositing.c
@@ -105,7 +105,7 @@ void GPU_destroy_fx_compositor(GPUFX *fx)
 
 
 
-bool GPU_initialize_fx_passes(GPUFX *fx, rcti *rect, int fxflags)
+bool GPU_initialize_fx_passes(GPUFX *fx, rcti *rect, rcti *scissor_rect, int fxflags)
 {
 	int w = BLI_rcti_size_x(rect) + 1, h = BLI_rcti_size_y(rect) + 1;
 	char err_out[256];
@@ -151,6 +151,16 @@ bool GPU_initialize_fx_passes(GPUFX *fx, rcti *rect, int fxflags)
 	
 	GPU_framebuffer_texture_bind(fx->gbuffer, fx->color_buffer, 
 								 GPU_texture_opengl_width(fx->color_buffer), GPU_texture_opengl_height(fx->color_buffer));
+
+	/* enable scissor test. It's needed to ensure sculpting works correctly */
+	if (scissor_rect) {
+		int w_sc = BLI_rcti_size_x(scissor_rect) + 1;
+		int h_sc = BLI_rcti_size_y(scissor_rect) + 1;
+		glPushAttrib(GL_SCISSOR_BIT);
+		glEnable(GL_SCISSOR_TEST);
+		glScissor(scissor_rect->xmin - rect->xmin, scissor_rect->ymin - rect->ymin, 
+				  w_sc, h_sc);
+	}
 	fx->effects = fxflags;
 	
 	return true;
@@ -167,6 +177,7 @@ bool GPU_fx_do_composite_pass(GPUFX *fx, struct View3D *v3d) {
 	
 	/* first, unbind the render-to-texture framebuffer */
 	GPU_framebuffer_texture_unbind(fx->gbuffer, fx->color_buffer);
+	glPopAttrib();
 	GPU_framebuffer_restore();
 	
 	/* full screen FX pass */




More information about the Bf-blender-cvs mailing list