[Bf-blender-cvs] [5aca575d85f] blender2.8: Eevee: Add Rotation and ratio parameters to DoF.

Clément Foucault noreply at git.blender.org
Fri May 12 16:31:19 CEST 2017


Commit: 5aca575d85f3d1172420fee60040ffc48a88dd45
Author: Clément Foucault
Date:   Thu May 11 19:08:59 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB5aca575d85f3d1172420fee60040ffc48a88dd45

Eevee: Add Rotation and ratio parameters to DoF.

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

M	release/scripts/startup/bl_ui/properties_data_camera.py
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/draw/engines/eevee/eevee_effects.c
M	source/blender/draw/engines/eevee/shaders/effect_dof_vert.glsl
M	source/blender/makesdna/DNA_gpu_types.h
M	source/blender/makesrna/intern/rna_scene.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_camera.py b/release/scripts/startup/bl_ui/properties_data_camera.py
index b5271431795..9d5895a2f66 100644
--- a/release/scripts/startup/bl_ui/properties_data_camera.py
+++ b/release/scripts/startup/bl_ui/properties_data_camera.py
@@ -234,15 +234,25 @@ class DATA_PT_camera_dof(CameraButtonsPanel, Panel):
         sub.active = (cam.dof_object is None)
         sub.prop(cam, "dof_distance", text="Distance")
 
-        hq_support = dof_options.is_hq_supported
-        col = split.column(align=True)
-        col.label("Viewport:")
-        sub = col.column()
-        sub.active = hq_support
-        sub.prop(dof_options, "use_high_quality")
-        col.prop(dof_options, "fstop")
-        if dof_options.use_high_quality and hq_support:
-            col.prop(dof_options, "blades")
+        if context.scene.render.engine == 'BLENDER_EEVEE':
+            col = split.column(align=True)
+            col.label("Aperture:")
+            engine = context.scene.render.engine
+            sub = col.column(align=True)
+            sub.prop(dof_options, "fstop")
+            sub.prop(dof_options, "blades")
+            sub.prop(dof_options, "rotation")
+            sub.prop(dof_options, "ratio")
+        else:
+            hq_support = dof_options.is_hq_supported
+            col = split.column(align=True)
+            col.label("Viewport:")
+            sub = col.column()
+            sub.active = hq_support
+            sub.prop(dof_options, "use_high_quality")
+            col.prop(dof_options, "fstop")
+            if dof_options.use_high_quality and hq_support:
+                col.prop(dof_options, "blades")
 
 
 class DATA_PT_camera_display(CameraButtonsPanel, Panel):
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index a0468be6791..ea7a6316466 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -29,6 +29,8 @@
 #define DNA_DEPRECATED_ALLOW
 
 #include "DNA_object_types.h"
+#include "DNA_camera_types.h"
+#include "DNA_gpu_types.h"
 #include "DNA_layer_types.h"
 #include "DNA_material_types.h"
 #include "DNA_scene_types.h"
@@ -253,6 +255,13 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
 				}
 			}
 		}
+
+	}
+
+	if (!DNA_struct_elem_find(fd->filesdna, "GPUDOFSettings", "float", "ratio"))	{
+		for (Camera *ca = main->camera.first; ca; ca = ca->id.next) {
+			ca->gpu_dof.ratio = 1.0f;
+		}
 	}
 
 	if (!DNA_struct_elem_find(fd->filesdna, "SceneLayer", "IDProperty", "*properties")) {
diff --git a/source/blender/draw/engines/eevee/eevee_effects.c b/source/blender/draw/engines/eevee/eevee_effects.c
index d150bf1720c..d5e712601ad 100644
--- a/source/blender/draw/engines/eevee/eevee_effects.c
+++ b/source/blender/draw/engines/eevee/eevee_effects.c
@@ -314,8 +314,8 @@ void EEVEE_effects_init(EEVEE_Data *vedata)
 			/* TODO UI Options */
 			float fstop = cam->gpu_dof.fstop;
 			float blades = cam->gpu_dof.num_blades;
-			float rotation = 0.0f;
-			float ratio = 1.0f;
+			float rotation = cam->gpu_dof.rotation;
+			float ratio = 1.0f / cam->gpu_dof.ratio;
 			float sensor = BKE_camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y);
 			float focus_dist = BKE_camera_object_dof_distance(v3d->camera);
 			float focal_len = cam->lens;
diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_vert.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_vert.glsl
index e75ffe236f1..0f5c5e5b16b 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_dof_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_dof_vert.glsl
@@ -74,7 +74,7 @@ void step_scatter()
 	/* Generate Triangle */
 	particlecoord = gl_Position.xy;
 
-	gl_Position.xy *= coc * texel_size;
+	gl_Position.xy *= coc * texel_size * vec2(bokeh_ratio, 1.0);
 	gl_Position.xy -= 1.0 - 0.5 * texel_size; /* NDC Bottom left */
 	gl_Position.xy += (0.5 + vec2(texelco) * 2.0) * texel_size;
 }
diff --git a/source/blender/makesdna/DNA_gpu_types.h b/source/blender/makesdna/DNA_gpu_types.h
index 967cb7284dc..be34309572f 100644
--- a/source/blender/makesdna/DNA_gpu_types.h
+++ b/source/blender/makesdna/DNA_gpu_types.h
@@ -38,6 +38,8 @@ typedef struct GPUDOFSettings {
 	float fstop;
 	float focal_length;
 	float sensor;
+	float rotation;
+	float ratio;
 	int num_blades;
 	int high_quality;
 } GPUDOFSettings;
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 94ef4aed62a..4603a0d17b5 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -5911,6 +5911,17 @@ static void rna_def_gpu_dof_fx(BlenderRNA *brna)
 	RNA_def_property_int_funcs(prop, NULL, "rna_GPUDOFSettings_blades_set", NULL);
 	RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
 
+	prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ANGLE);
+	RNA_def_property_ui_text(prop, "Rotation", "Rotation of blades in apperture");
+	RNA_def_property_range(prop, -M_PI, M_PI);
+	RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+	prop = RNA_def_property(srna, "ratio", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_ui_text(prop, "Ratio", "Distortion to simulate anamorphic lens bokeh");
+	RNA_def_property_range(prop, 0.0000001f, FLT_MAX);
+	RNA_def_property_ui_range(prop, 0.25f, 4.0f, 0.1, 3);
+	RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
 	prop = RNA_def_property(srna, "use_high_quality", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "high_quality", 1);
 	RNA_def_property_ui_text(prop, "High Quality", "Use high quality depth of field");




More information about the Bf-blender-cvs mailing list