[Bf-blender-cvs] [dea27f0] GPU_data_request: Add compositing and proper back drawing back to new viewport.

Antony Riakiotakis noreply at git.blender.org
Fri Apr 10 14:26:42 CEST 2015


Commit: dea27f08eb3e00c53f5c6c3acb39709b6f64d519
Author: Antony Riakiotakis
Date:   Fri Apr 10 14:24:48 2015 +0200
Branches: GPU_data_request
https://developer.blender.org/rBdea27f08eb3e00c53f5c6c3acb39709b6f64d519

Add compositing and proper back drawing back to new viewport.

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

M	source/blender/editors/space_view3d/view3d_draw.c

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

diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 9b5711c..7e8dd80 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -3706,50 +3706,42 @@ static void view3d_main_area_draw_viewport_new(const bContext *UNUSED(C), Scene
 {
 	unsigned int lay_used = 0;
 	Base *base, *base_edit = NULL; /* object being edited, if any */
+	bool do_compositing = false;
+	RegionView3D *rv3d = ar->regiondata;
 
 #if MCE_TRACE
 	printf("> %s\n", __FUNCTION__);
 #endif /* MCE_TRACE */
 
-	if (UI_GetThemeValue(TH_SHOW_BACK_GRAD)) {
-		glMatrixMode(GL_PROJECTION);
-		glPushMatrix();
-		glLoadIdentity();
-		glMatrixMode(GL_MODELVIEW);
-		glPushMatrix();
-		glLoadIdentity();
+	view3d_main_area_clear(scene, v3d, ar);
 
-		glEnable(GL_DEPTH_TEST);
-		glDepthFunc(GL_ALWAYS);
-		glShadeModel(GL_SMOOTH);
-		glBegin(GL_QUADS);
-		UI_ThemeColor(TH_LOW_GRAD);
-		glVertex3f(-1.0, -1.0, 1.0);
-		glVertex3f(1.0, -1.0, 1.0);
-		UI_ThemeColor(TH_HIGH_GRAD);
-		glVertex3f(1.0, 1.0, 1.0);
-		glVertex3f(-1.0, 1.0, 1.0);
-		glEnd();
-		glShadeModel(GL_FLAT);
+	/* setup view matrices */
+	view3d_main_area_setup_view(scene, v3d, ar, NULL, NULL);
 
-		glDepthFunc(GL_LEQUAL);
-		glDisable(GL_DEPTH_TEST);
+	GPUx_reset_draw_state(); /* for code below which uses GPUx_state */
 
-		glMatrixMode(GL_PROJECTION);
-		glPopMatrix();
+	/* framebuffer fx needed, we need to draw offscreen first */
+	if (v3d->fx_settings.fx_flag) {
+		GPUFXSettings fx_settings;
+		BKE_screen_gpu_fx_validate(&v3d->fx_settings);
+		fx_settings = v3d->fx_settings;
+		if (!rv3d->compositor)
+			rv3d->compositor = GPU_fx_compositor_create();
 
-		glMatrixMode(GL_MODELVIEW);
-		glPopMatrix();
-	}
-	else {
-		UI_ThemeClearColor(TH_HIGH_GRAD);
-		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
-	}
+		if (rv3d->persp == RV3D_CAMOB && v3d->camera)
+			BKE_camera_to_gpu_dof(v3d->camera, &fx_settings);
+		else {
+			fx_settings.dof = NULL;
+		}
 
-	/* setup view matrices */
-	view3d_main_area_setup_view(scene, v3d, ar, NULL, NULL);
+		if (v3d->drawtype < OB_SOLID)
+			fx_settings.ssao = NULL;
 
-	GPUx_reset_draw_state(); /* for code below which uses GPUx_state */
+		do_compositing = GPU_fx_compositor_initialize_passes(rv3d->compositor, &ar->winrct, &ar->drawrct, &fx_settings);
+	}
+
+	/* clear the background */
+	view3d_main_area_clear(scene, v3d, ar);
 
 	drawfloor_new(scene, v3d, grid_unit);
 
@@ -3820,6 +3812,12 @@ static void view3d_main_area_draw_viewport_new(const bContext *UNUSED(C), Scene
 		draw_object(scene, ar, v3d, base_edit, 0);
 	}
 
+	/* post process */
+	if (do_compositing) {
+		GPU_fx_do_composite_pass(rv3d->compositor, rv3d->winmat, rv3d->is_persp, scene, NULL);
+	}
+
+
 	/* play nice with UI drawing code outside view3d */
 	glDisable(GL_DEPTH_TEST);




More information about the Bf-blender-cvs mailing list