[Bf-blender-cvs] [b550e78] viewport_experiments: Use own file for GPU option types.

Antony Riakiotakis noreply at git.blender.org
Tue Nov 4 14:32:05 CET 2014


Commit: b550e788f28cee3fee2680464fc72395f2cce39f
Author: Antony Riakiotakis
Date:   Tue Nov 4 13:02:30 2014 +0100
Branches: viewport_experiments
https://developer.blender.org/rBb550e788f28cee3fee2680464fc72395f2cce39f

Use own file for GPU option types.

* Add gpu options for depth of field to camera - still inactive.
* GPUFXOptions now passed to the compositing system startup
so users can swap options if they wish to

This commit changes read-write data again, people should reset their
values again (sorry for that but this is still WIP)

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

M	release/scripts/startup/bl_ui/properties_data_camera.py
M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/CMakeLists.txt
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/editors/space_view3d/space_view3d.c
M	source/blender/gpu/intern/gpu_compositing.c
M	source/blender/makesdna/DNA_camera_types.h
A	source/blender/makesdna/DNA_gpu_types.h
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesdna/intern/makesdna.c
M	source/blender/makesrna/intern/rna_camera.c
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/makesrna/intern/rna_space.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_camera.py b/release/scripts/startup/bl_ui/properties_data_camera.py
index 0600c87..357a3e1 100644
--- a/release/scripts/startup/bl_ui/properties_data_camera.py
+++ b/release/scripts/startup/bl_ui/properties_data_camera.py
@@ -172,6 +172,36 @@ class DATA_PT_camera_dof(CameraButtonsPanel, Panel):
         col.active = cam.dof_object is None
         col.prop(cam, "dof_distance", text="Distance")
 
+        col.label("Real Time Viewport values")
+        dof_options = cam.gpu_dof
+        subcol = col.column(align=True)
+        subcol.prop(dof_options, "dof_focus_distance")
+        subcol.prop(dof_options, "dof_fstop")
+        subcol.prop(dof_options, "dof_focal_length")
+        subcol.prop(dof_options, "dof_sensor")
+
+
+class DATA_PT_camera_gpu_dof(Panel):
+    bl_label = "GPU Depth of Field"
+    bl_space_type = 'PROPERTIES'
+    bl_region_type = 'WINDOW'
+    bl_context = "data"
+
+    def draw(self, context):
+        layout = self.layout
+
+        cam = context.camera
+
+        dof_options = cam.gpu_dof
+        col = layout.column(align=True)
+        col.prop(dof_options, "dof_fstop")
+        col.prop(dof_options, "dof_focal_length")
+        col.prop(dof_options, "dof_sensor")
+
+    @classmethod
+    def poll(cls, context):
+        return context.camera
+
 
 class DATA_PT_camera_display(CameraButtonsPanel, Panel):
     bl_label = "Display"
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index a3dc508..88febb2 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -2898,21 +2898,23 @@ class VIEW3D_PT_view3d_shading(Panel):
 
             col.prop(view, "depth_of_field")
             if view.depth_of_field:
+                dof_options = fxoptions.dof_options
                 subcol = col.column(align=True)
-                subcol.prop(fxoptions, "dof_focus_distance")
+                subcol.prop(dof_options, "dof_focus_distance")
                 #fstop is preferable?..
                 #subcol.prop(view, "dof_aperture")
-                subcol.prop(fxoptions, "dof_fstop")
-                subcol.prop(fxoptions, "dof_focal_length")
-                subcol.prop(fxoptions, "dof_sensor")
+                subcol.prop(dof_options, "dof_fstop")
+                subcol.prop(dof_options, "dof_focal_length")
+                subcol.prop(dof_options, "dof_sensor")
             col.prop(view, "ssao")
             if view.ssao:
+                ssao_options = fxoptions.ssao_options
                 subcol = col.column(align=True)
-                subcol.prop(fxoptions, "ssao_darkening")
-                subcol.prop(fxoptions, "ssao_distance_max")
-                subcol.prop(fxoptions, "ssao_attenuation")
-                subcol.prop(fxoptions, "ssao_ray_sample_mode")
-                subcol.prop(fxoptions, "ssao_color")
+                subcol.prop(ssao_options, "ssao_darkening")
+                subcol.prop(ssao_options, "ssao_distance_max")
+                subcol.prop(ssao_options, "ssao_attenuation")
+                subcol.prop(ssao_options, "ssao_ray_sample_mode")
+                subcol.prop(ssao_options, "ssao_color")
 
 
 class VIEW3D_PT_view3d_motion_tracking(Panel):
diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt
index 0d30952..ae799d0 100644
--- a/source/blender/CMakeLists.txt
+++ b/source/blender/CMakeLists.txt
@@ -46,6 +46,7 @@ set(SRC_DNA_INC
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_freestyle_types.h
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_genfile.h
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_gpencil_types.h
+	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_gpu_types.h
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_group_types.h
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_image_types.h
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_ipo_types.h
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index b1e745f..1ab7b89 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6406,6 +6406,9 @@ static bool direct_link_screen(FileData *fd, bScreen *sc)
 
 				if (v3d->fxoptions) {
 					v3d->fxoptions = newdataadr(fd, v3d->fxoptions);
+
+					v3d->fxoptions->dof_options = newdataadr(fd, v3d->fxoptions->dof_options);
+					v3d->fxoptions->ssao_options = newdataadr(fd, v3d->fxoptions->ssao_options);
 				}
 				
 				blo_do_versions_view3d_split_250(v3d, &sl->regionbase);
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 2fb2d9c..637da6f 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2640,7 +2640,11 @@ static void write_screens(WriteData *wd, ListBase *scrbase)
 					for (bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next)
 						writestruct(wd, DATA, "BGpic", 1, bgpic);
 					if (v3d->localvd) writestruct(wd, DATA, "View3D", 1, v3d->localvd);
-					if (v3d->fxoptions) writestruct(wd, DATA, "GPUFXOptions", 1, v3d->fxoptions);
+					if (v3d->fxoptions) {
+						writestruct(wd, DATA, "GPUFXOptions", 1, v3d->fxoptions);
+						writestruct(wd, DATA, "GPUDOFOptions", 1, v3d->fxoptions->dof_options);
+						writestruct(wd, DATA, "GPUSSAOOptions", 1, v3d->fxoptions->ssao_options);
+					}
 				}
 				else if (sl->spacetype==SPACE_IPO) {
 					SpaceIpo *sipo= (SpaceIpo *)sl;
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 95fb39b..77dbf5c 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -420,8 +420,11 @@ static void view3d_free(SpaceLink *sl)
 		MEM_freeN(vd->defmaterial);
 	}
 
-	if (vd->fxoptions)
+	if (vd->fxoptions) {
+		MEM_freeN(vd->fxoptions->dof_options);
+		MEM_freeN(vd->fxoptions->ssao_options);
 		MEM_freeN(vd->fxoptions);
+	}
 }
 
 
@@ -463,7 +466,12 @@ static SpaceLink *view3d_duplicate(SpaceLink *sl)
 	}
 
 	v3dn->properties_storage = NULL;
-	v3dn->fxoptions = MEM_dupallocN(v3do->fxoptions);
+	if (v3do->fxoptions)
+	{
+		v3dn->fxoptions = MEM_callocN(sizeof(GPUFXOptions), "view3d fx options");
+		v3dn->fxoptions->dof_options = MEM_dupallocN(v3do->fxoptions->dof_options);
+		v3dn->fxoptions->ssao_options = MEM_dupallocN(v3do->fxoptions->ssao_options);
+	}
 
 	return (SpaceLink *)v3dn;
 }
diff --git a/source/blender/gpu/intern/gpu_compositing.c b/source/blender/gpu/intern/gpu_compositing.c
index 40f0f87..d441535 100644
--- a/source/blender/gpu/intern/gpu_compositing.c
+++ b/source/blender/gpu/intern/gpu_compositing.c
@@ -41,6 +41,7 @@
 #include "DNA_scene_types.h"
 #include "DNA_object_types.h"
 #include "DNA_camera_types.h"
+#include "DNA_gpu_types.h"
 
 #include "GPU_extensions.h"
 #include "GPU_compositing.h"
@@ -212,10 +213,19 @@ bool GPU_initialize_fx_passes(GPUFX *fx, rcti *rect, rcti *scissor_rect, int fxf
 
 	fx->effects = 0;
 
-	if (!fxflags) {
+	if (!fxflags || !options) {
 		cleanup_fx_gl_data(fx, true);
 		return false;
 	}
+
+	/* disable effects if no options passed for them */
+	if (!options->dof_options) {
+		fxflags &= ~V3D_FX_DEPTH_OF_FIELD;
+	}
+	if (!options->ssao_options) {
+		fxflags &= ~V3D_FX_SSAO;
+	}
+
 	
 	fx->num_passes = 0;
 	/* dof really needs a ping-pong buffer to work */
@@ -337,7 +347,6 @@ bool GPU_fx_do_composite_pass(GPUFX *fx, float projmat[4][4], bool is_persp, str
 	int numslots = 0;
 	float invproj[4][4];
 	int i;
-	GPUFXOptions *options = &fx->options;
 	/* number of passes left. when there are no more passes, the result is passed to the frambuffer */
 	int passes_left = fx->num_passes;
 	/* view vectors for the corners of the view frustum. Can be used to recreate the world space position easily */
@@ -396,6 +405,7 @@ bool GPU_fx_do_composite_pass(GPUFX *fx, float projmat[4][4], bool is_persp, str
 		GPUShader *ssao_shader;
 		ssao_shader = GPU_shader_get_builtin_fx_shader(GPU_SHADER_FX_SSAO, is_persp);
 		if (ssao_shader) {
+			GPUSSAOOptions *options = fx->options.ssao_options;
 			int color_uniform, depth_uniform;
 			int ssao_uniform, ssao_color_uniform, viewvecs_uniform, ssao_sample_params_uniform;
 			int ssao_jitter_uniform, ssao_direction_uniform;
@@ -494,6 +504,7 @@ bool GPU_fx_do_composite_pass(GPUFX *fx, float projmat[4][4], bool is_persp, str
 
 	/* second pass, dof */
 	if (fx->effects & V3D_FX_DEPTH_OF_FIELD) {
+		GPUDOFOptions *options = fx->options.dof_options;
 		GPUShader *dof_shader_pass1, *dof_shader_pass2, *dof_shader_pass3, *dof_shader_pass4, *dof_shader_pass5;
 		float dof_params[4];
 		float scale = scene->unit.system ? scene->unit.scale_length : 1.0f;
diff --git a/source/blender/makesdna/DNA_camera_types.h b/source/blender/makesdna/DNA_camera_types.h
index c99494c..8a57007 100644
--- a/source/blender/makesdna/DNA_camera_types.h
+++ b/source/blender/makesdna/DNA_camera_types.h
@@ -33,7 +33,7 @@
 #define __DNA_CAMERA_TYPES_H__
 
 #include "DNA_defs.h"
-
+#include "DNA_gpu_types.h"
 #include "DNA_ID.h"
 
 #ifdef __cplusplus
@@ -65,6 +65,7 @@ typedef struct Camera {
 	struct Ipo *ipo  DNA_DEPRECATED; /* old animation system, deprecated for 2.5 */
 	
 	struct Object *dof_ob;
+	struct GPUDOFOptions gpu_dof;
 
 	char sensor_fit;
 	char pad[7];
diff --git a/source/blender/makesdna/DNA_gpu_types.h b/source/blender/makesdna/DNA_gpu_types.h
new file mode 100644
index 0000000..67436c6
--- /dev/null
+++ b/source/blender/makesdna/DNA_gpu_types.h
@@ -0,0 +1,58 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list