[Bf-blender-cvs] [77b7b4e] bake-cycles: Cycles-Bake: Saving different file formats *

Dalai Felinto noreply at git.blender.org
Wed Apr 23 02:47:30 CEST 2014


Commit: 77b7b4efb2773174f789046772e1dc26efcaab3d
Author: Dalai Felinto
Date:   Wed Mar 19 11:58:11 2014 -0300
https://developer.blender.org/rB77b7b4efb2773174f789046772e1dc26efcaab3d

Cycles-Bake: Saving different file formats *

Todo:
* I still can't have PNG to save without alpha
* I think it's always saving as 8 bit

Apart from that UI is working.

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

M	intern/cycles/blender/addon/properties.py
M	intern/cycles/blender/addon/ui.py
M	source/blender/editors/object/object_bake_new.c
M	source/blender/makesrna/RNA_enum_types.h
M	source/blender/makesrna/intern/rna_scene.c

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

diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index 89b9a15..34e3372 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -114,17 +114,107 @@ enum_volume_homogeneous_sampling = (
     ('EQUI_ANGULAR', "Equi-angular", "Use Equi-angular Sampling"),
     )
 
-enum_normal_swizzle = (
-    ('POS_X', "+X", ""),
-    ('POS_Y', "+Y", ""),
-    ('POS_Z', "+Z", ""),
-    ('NEG_X', "-X", ""),
-    ('NEG_Y', "-Y", ""),
-    ('NEG_Z', "-Z", ""),
-    )
+
+def enum_color_depth_items(self, context):
+    """"""
+    def is_float(file_format):
+        return file_format in (
+                'OPEN_EXR',
+                'OPEN_EXR_MULTILAYER',
+                'HDR',
+                )
+
+    file_formats = {
+                'PNG' : ['8','16'],
+                'TIFF' : ['8','16'],
+                'OPEN_EXR' : ['16','32'],
+                'DPX' : ['8', '10', '12', '16'],
+                'JPEG2000' : ['8', '12', '16'],
+                }
+
+    file_format = self.file_format
+    depths = file_formats.get(file_format, ['8'])
+
+    enum_color_depth_items.ret = [(e.identifier, e.name, e.description) for e in \
+            bpy.types.OBJECT_OT_bake.bl_rna.properties['color_depth'].enum_items if \
+            e.identifier in depths]
+
+    if is_float(file_format):
+        floats = {
+                '8' :"8",
+                '10' : "10",
+                '12' : "12",
+                '16' : "Float (Half)",
+                '32' : "Float (Full)",
+                }
+
+        for i, (identifier, name, description) in enumerate(enum_color_depth_items.ret):
+            enum_color_depth_items.ret[i] = (identifier, floats.get(identifier), description)
+
+    return enum_color_depth_items.ret
+
+
+bake_file_formats = ['BMP', 'PNG', 'JPEG', 'OPEN_EXR', 'TIFF', 'TARGA']
+
+class CyclesBakeImageFormatSettings(bpy.types.PropertyGroup):
+    enum_file_format_items = [(e.identifier, e.name, e.description) for e in bpy.types.OBJECT_OT_bake.bl_rna.properties['file_format'].enum_items if e.identifier in bake_file_formats]
+    enum_exr_codec_items = [(e.identifier, e.name, e.description) for e in bpy.types.OBJECT_OT_bake.bl_rna.properties['exr_codec'].enum_items]
+    enum_color_mode_items = [(e.identifier, e.name, e.description) for e in bpy.types.OBJECT_OT_bake.bl_rna.properties['color_mode'].enum_items]
+
+    file_format = EnumProperty(
+            name=bpy.types.OBJECT_OT_bake.bl_rna.properties['file_format'].name,
+            default=bpy.types.OBJECT_OT_bake.bl_rna.properties['file_format'].default,
+            description=bpy.types.OBJECT_OT_bake.bl_rna.properties['file_format'].description,
+            items=enum_file_format_items,
+            )
+
+    exr_codec = EnumProperty(
+            name=bpy.types.OBJECT_OT_bake.bl_rna.properties['exr_codec'].name,
+            default=bpy.types.OBJECT_OT_bake.bl_rna.properties['exr_codec'].default,
+            description=bpy.types.OBJECT_OT_bake.bl_rna.properties['exr_codec'].description,
+            items=enum_exr_codec_items,
+            )
+
+    color_mode = EnumProperty(
+            name=bpy.types.OBJECT_OT_bake.bl_rna.properties['color_mode'].name,
+            default=bpy.types.OBJECT_OT_bake.bl_rna.properties['color_mode'].default,
+            description=bpy.types.OBJECT_OT_bake.bl_rna.properties['color_mode'].description,
+            items=enum_color_mode_items,
+            )
+
+    color_depth = EnumProperty(
+            name=bpy.types.OBJECT_OT_bake.bl_rna.properties['color_depth'].name,
+            description=bpy.types.OBJECT_OT_bake.bl_rna.properties['color_depth'].description,
+            items=enum_color_depth_items,
+            )
+
+    quality = IntProperty(
+            subtype='PERCENTAGE',
+            name=bpy.types.OBJECT_OT_bake.bl_rna.properties['quality'].name,
+            description=bpy.types.OBJECT_OT_bake.bl_rna.properties['quality'].description,
+            default=bpy.types.OBJECT_OT_bake.bl_rna.properties['quality'].default,
+            soft_min=bpy.types.OBJECT_OT_bake.bl_rna.properties['quality'].soft_min,
+            soft_max=bpy.types.OBJECT_OT_bake.bl_rna.properties['quality'].soft_max,
+            min=bpy.types.OBJECT_OT_bake.bl_rna.properties['quality'].hard_min,
+            max=bpy.types.OBJECT_OT_bake.bl_rna.properties['quality'].hard_max,
+            )
+
+    compression = IntProperty(
+            subtype='PERCENTAGE',
+            name=bpy.types.OBJECT_OT_bake.bl_rna.properties['compression'].name,
+            description=bpy.types.OBJECT_OT_bake.bl_rna.properties['compression'].description,
+            default=bpy.types.OBJECT_OT_bake.bl_rna.properties['compression'].default,
+            soft_min=bpy.types.OBJECT_OT_bake.bl_rna.properties['compression'].soft_min,
+            soft_max=bpy.types.OBJECT_OT_bake.bl_rna.properties['compression'].soft_max,
+            min=bpy.types.OBJECT_OT_bake.bl_rna.properties['compression'].hard_min,
+            max=bpy.types.OBJECT_OT_bake.bl_rna.properties['compression'].hard_max,
+            )
 
 
 class CyclesBakeSettings(bpy.types.PropertyGroup):
+    enum_normal_space_items = [(e.identifier, e.name, e.description) for e in bpy.types.OBJECT_OT_bake.bl_rna.properties['normal_space'].enum_items]
+    enum_normal_swizzle_items = [(e.identifier, e.name, e.description) for e in bpy.types.OBJECT_OT_bake.bl_rna.properties['normal_r'].enum_items]
+
     type = EnumProperty(
             name="Type",
             default='COMBINED',
@@ -160,39 +250,48 @@ class CyclesBakeSettings(bpy.types.PropertyGroup):
 
     filepath = StringProperty(
             subtype='FILE_PATH',
-            name="File Path",
             default="//",
-            description="Image filepath to use when saving externally",
+            name=bpy.types.OBJECT_OT_bake.bl_rna.properties['filepath'].name,
+            description=bpy.types.OBJECT_OT_bake.bl_rna.properties['filepath'].description,
+            )
+
+    image_settings = PointerProperty(
+            name="Image Format Settings",
+            description="Image Format Settings",
+            type=CyclesBakeImageFormatSettings,
             )
 
     width = IntProperty(
             subtype='PIXEL',
-            min=1,
-            soft_min=64,
-            soft_max=4096,
-            default=512,
-            name="Width",
-            description="Horizontal dimension of the baking map",
+            name=bpy.types.OBJECT_OT_bake.bl_rna.properties['width'].name,
+            description=bpy.types.OBJECT_OT_bake.bl_rna.properties['width'].description,
+            default=bpy.types.OBJECT_OT_bake.bl_rna.properties['width'].default,
+            soft_min=bpy.types.OBJECT_OT_bake.bl_rna.properties['width'].soft_min,
+            soft_max=bpy.types.OBJECT_OT_bake.bl_rna.properties['width'].soft_max,
+            min=bpy.types.OBJECT_OT_bake.bl_rna.properties['width'].hard_min,
+            max=bpy.types.OBJECT_OT_bake.bl_rna.properties['width'].hard_max,
             )
 
     height = IntProperty(
             subtype='PIXEL',
-            min=1,
-            soft_min=64,
-            soft_max=4096,
-            default=512,
-            name="Height",
-            description="Vertical dimension of the baking map",
+            name=bpy.types.OBJECT_OT_bake.bl_rna.properties['height'].name,
+            description=bpy.types.OBJECT_OT_bake.bl_rna.properties['height'].description,
+            default=bpy.types.OBJECT_OT_bake.bl_rna.properties['height'].default,
+            soft_min=bpy.types.OBJECT_OT_bake.bl_rna.properties['height'].soft_min,
+            soft_max=bpy.types.OBJECT_OT_bake.bl_rna.properties['height'].soft_max,
+            min=bpy.types.OBJECT_OT_bake.bl_rna.properties['height'].hard_min,
+            max=bpy.types.OBJECT_OT_bake.bl_rna.properties['height'].hard_max,
             )
 
     margin = IntProperty(
             subtype='PIXEL',
-            min=0,
-            soft_min=0,
-            soft_max=64,
-            default=16,
-            name="Margin",
-            description="Extends the baked result as a post process filter",
+            name=bpy.types.OBJECT_OT_bake.bl_rna.properties['margin'].name,
+            description=bpy.types.OBJECT_OT_bake.bl_rna.properties['margin'].description,
+            default=bpy.types.OBJECT_OT_bake.bl_rna.properties['margin'].default,
+            soft_min=bpy.types.OBJECT_OT_bake.bl_rna.properties['margin'].soft_min,
+            soft_max=bpy.types.OBJECT_OT_bake.bl_rna.properties['margin'].soft_max,
+            min=bpy.types.OBJECT_OT_bake.bl_rna.properties['margin'].hard_min,
+            max=bpy.types.OBJECT_OT_bake.bl_rna.properties['margin'].hard_max,
             )
 
     use_selected_to_active = BoolProperty(
@@ -205,49 +304,46 @@ class CyclesBakeSettings(bpy.types.PropertyGroup):
     cage_extrusion = FloatProperty(
             subtype='DISTANCE',
             unit='LENGTH',
-            name="Cage Extrusion",
-            min=0.0,
-            soft_max=1.0,
-            default=0.0,
-            description="Distance to use for the inward ray cast when using "
-                        "selected to active",
+            name=bpy.types.OBJECT_OT_bake.bl_rna.properties['cage_extrusion'].name,
+            description=bpy.types.OBJECT_OT_bake.bl_rna.properties['cage_extrusion'].description,
+            default=bpy.types.OBJECT_OT_bake.bl_rna.properties['cage_extrusion'].default,
+            soft_min=bpy.types.OBJECT_OT_bake.bl_rna.properties['cage_extrusion'].soft_min,
+            soft_max=bpy.types.OBJECT_OT_bake.bl_rna.properties['cage_extrusion'].soft_max,
+            min=bpy.types.OBJECT_OT_bake.bl_rna.properties['cage_extrusion'].hard_min,
+            max=bpy.types.OBJECT_OT_bake.bl_rna.properties['cage_extrusion'].hard_max,
             )
 
     custom_cage = StringProperty(
-            name="Custom Cage",
-            description="Name of the object to use as cage (so the rays are casted from it)",
+            name=bpy.types.OBJECT_OT_bake.bl_rna.properties['custom_cage'].name,
+            description=bpy.types.OBJECT_OT_bake.bl_rna.properties['custom_cage'].description,
             )
 
 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list