[Bf-blender-cvs] [68536d4] bake-cycles: Cycles-Bake: User Interface

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


Commit: 68536d4ec35a09d23e3b0bf63f1207ae62183b3b
Author: Dalai Felinto
Date:   Tue Mar 11 17:26:47 2014 -0300
https://developer.blender.org/rB68536d4ec35a09d23e3b0bf63f1207ae62183b3b

Cycles-Bake: User Interface

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

M	intern/cycles/blender/addon/properties.py
M	intern/cycles/blender/addon/ui.py

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

diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index 2b05c21..89b9a15 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -21,7 +21,8 @@ from bpy.props import (BoolProperty,
                        EnumProperty,
                        FloatProperty,
                        IntProperty,
-                       PointerProperty)
+                       PointerProperty,
+                       StringProperty)
 
 # enums
 
@@ -113,6 +114,142 @@ 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", ""),
+    )
+
+
+class CyclesBakeSettings(bpy.types.PropertyGroup):
+    type = EnumProperty(
+            name="Type",
+            default='COMBINED',
+            description="Type of pass to bake",
+            items = (
+                ('COMBINED', "Combined", ""),
+                ('AO', "Ambient Occlusion", ""),
+                ('NORMAL', "Normal", ""),
+                ('UV', "UV", ""),
+                ('EMIT', "Emit", ""),
+                ('ENVIRONMENT', "Environment", ""),
+                ('DIFFUSE_DIRECT', "Diffuse Direct", ""),
+                ('DIFFUSE_INDIRECT', "Diffuse Indirect", ""),
+                ('DIFFUSE_COLOR', "Diffuse Color", ""),
+                ('GLOSSY_DIRECT', "Glossy Direct", ""),
+                ('GLOSSY_INDIRECT', "Glossy Indirect", ""),
+                ('GLOSSY_COLOR', "Glossy Color", ""),
+                ('TRANSMISSION_DIRECT', "Transmission Direct", ""),
+                ('TRANSMISSION_INDIRECT', "Transmission Indirect", ""),
+                ('TRANSMISSION_COLOR', "Transmission Color", ""),
+                ('SUBSURFACE_DIRECT', "Subsurface Direct", ""),
+                ('SUBSURFACE_INDIRECT', "Subsurface Indirect", ""),
+                ('SUBSURFACE_COLOR', "Subsurface Color", ""),
+                ),
+            )
+
+    is_save_external = BoolProperty(
+            name="External",
+            description="Save the image externally (ignore face assigned Image "
+                        "datablocks)",
+            default=True,
+            )
+
+    filepath = StringProperty(
+            subtype='FILE_PATH',
+            name="File Path",
+            default="//",
+            description="Image filepath to use when saving externally",
+            )
+
+    width = IntProperty(
+            subtype='PIXEL',
+            min=1,
+            soft_min=64,
+            soft_max=4096,
+            default=512,
+            name="Width",
+            description="Horizontal dimension of the baking map",
+            )
+
+    height = IntProperty(
+            subtype='PIXEL',
+            min=1,
+            soft_min=64,
+            soft_max=4096,
+            default=512,
+            name="Height",
+            description="Vertical dimension of the baking map",
+            )
+
+    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",
+            )
+
+    use_selected_to_active = BoolProperty(
+            name="Selected to Active",
+            description="Bake shading on the surface of selected objects to "
+                        "the active object",
+            default=False,
+            )
+
+    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",
+            )
+
+    custom_cage = StringProperty(
+            name="Custom Cage",
+            description="Name of the object to use as cage (so the rays are casted from it)",
+            )
+
+    normal_space = EnumProperty(
+            name="Normal Space",
+            default='WORLD',
+            description="Choose normal space for baking",
+            items = (
+                ('WORLD', "World", "Bake the normals in world space"),
+                ('OBJECT', "Object", "Bake the normals in object space"),
+                ('TANGENT', "Tangent", "Bake the normals in tangent space"),
+                ),
+            )
+
+    normal_r = EnumProperty(
+            name="R",
+            default='NEG_X',
+            description="Axis to bake in red channel",
+            items = enum_normal_swizzle,
+            )
+
+    normal_g = EnumProperty(
+            name="G",
+            default='NEG_Y',
+            description="Axis to bake in green channel",
+            items = enum_normal_swizzle,
+            )
+
+    normal_b = EnumProperty(
+            name="B",
+            default='NEG_Z',
+            description="Axis to bake in blue channel",
+            items = enum_normal_swizzle,
+            )
+
 
 class CyclesRenderSettings(bpy.types.PropertyGroup):
     @classmethod
@@ -470,6 +607,11 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
                             "but time can be saved by manually stopping the render when the noise is low enough)",
                 default=False,
                 )
+        cls.bake = PointerProperty(
+                name="Cycles Bake Settings",
+                description="Cycles bake settings",
+                type=CyclesBakeSettings,
+                )
 
     @classmethod
     def unregister(cls):
@@ -881,6 +1023,7 @@ class CyclesCurveSettings(bpy.types.PropertyGroup):
 
 
 def register():
+    bpy.utils.register_class(CyclesBakeSettings)
     bpy.utils.register_class(CyclesRenderSettings)
     bpy.utils.register_class(CyclesCameraSettings)
     bpy.utils.register_class(CyclesMaterialSettings)
@@ -894,6 +1037,7 @@ def register():
 
 def unregister():
     bpy.utils.unregister_class(CyclesRenderSettings)
+    bpy.utils.unregister_class(CyclesBakeSettings)
     bpy.utils.unregister_class(CyclesCameraSettings)
     bpy.utils.unregister_class(CyclesMaterialSettings)
     bpy.utils.unregister_class(CyclesLampSettings)
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index a064b4f..8284de0 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -1226,6 +1226,66 @@ class CyclesRender_PT_CurveRendering(CyclesButtonsPanel, Panel):
         row.prop(ccscene, "maximum_width", text="Max Ext.")
 
 
+
+
+class CyclesRender_PT_bake(CyclesButtonsPanel, Panel):
+    bl_label = "Bake"
+    bl_context = "render"
+    bl_options = {'DEFAULT_CLOSED'}
+    COMPAT_ENGINES = {'CYCLES'}
+
+    def draw(self, context):
+        layout = self.layout
+
+        scene = context.scene
+        cbk = scene.cycles.bake
+
+        props = layout.operator("object.bake", icon='RENDER_STILL')
+
+        props.type = cbk.type
+        props.is_save_external = cbk.is_save_external
+        props.filepath = cbk.filepath
+        props.width = cbk.width
+        props.height = cbk.height
+        props.margin = cbk.margin
+        props.use_selected_to_active = cbk.use_selected_to_active
+        props.cage_extrusion = cbk.cage_extrusion
+        props.custom_cage = cbk.custom_cage
+        props.normal_space = cbk.normal_space
+        props.normal_r = cbk.normal_r
+        props.normal_g = cbk.normal_g
+        props.normal_b = cbk.normal_b
+
+        col = layout.column()
+        col.prop(cbk, "type")
+        #col.prop(cbk, "is_save_external")
+        col.prop(cbk, "filepath")
+
+        row = col.row(align=True)
+        row.prop(cbk, "width")
+        row.prop(cbk, "height")
+
+        col.prop(cbk, "margin")
+
+        col.separator()
+        col.prop(cbk, "use_selected_to_active")
+
+        if cbk.type == 'NORMAL':
+            sub = col.column()
+            sub.active = cbk.use_selected_to_active
+            sub.prop(cbk, "cage_extrusion")
+            sub.prop_search(cbk, "custom_cage", scene, "objects")
+
+            col.separator()
+            col.prop(cbk, "normal_space")
+
+            row = col.row(align=True)
+            row.label(text = "Swizzle:")
+            row.prop(cbk, "normal_r", text="")
+            row.prop(cbk, "normal_g", text="")
+            row.prop(cbk, "normal_b", text="")
+
+
 class CyclesParticle_PT_CurveSettings(CyclesButtonsPanel, Panel):
     bl_label = "Cycles Hair Settings"
     bl_context = "particle"




More information about the Bf-blender-cvs mailing list