Added ramp input and blend settings in RNA and layouts.
authorWilliam Reynish <william@reynish.com>
Sun, 2 Aug 2009 01:00:15 +0000 (01:00 +0000)
committerWilliam Reynish <william@reynish.com>
Sun, 2 Aug 2009 01:00:15 +0000 (01:00 +0000)
release/ui/buttons_material.py
source/blender/makesrna/intern/rna_material.c

index c04fbd7e1da161b08c96f571440428450f31bc5a..7153dce3074b62516f8661b103300ddcf9f86225 100644 (file)
@@ -1,12 +1,6 @@
        
 import bpy
 
-# If python version is less than 2.4, try to get set stuff from module
-try:
-       set
-except:
-       from sets import Set as set
-
 class MaterialButtonsPanel(bpy.types.Panel):
        __space_type__ = "BUTTONS_WINDOW"
        __region_type__ = "WINDOW"
@@ -240,8 +234,18 @@ class MATERIAL_PT_diffuse(MaterialButtonsPanel):
                        row.itemR(mat, "diffuse_fresnel", text="Fresnel")
                        row.itemR(mat, "diffuse_fresnel_factor", text="Factor")
                        
-               elif mat.use_diffuse_ramp:
+               if mat.use_diffuse_ramp:
+                       layout.itemS()
                        layout.template_color_ramp(mat.diffuse_ramp, expand=True)
+                       layout.itemS()
+                       row = layout.row()
+                       split = row.split(percentage=0.3)
+                       split.itemL(text="Input:")
+                       split.itemR(mat, "diffuse_ramp_input", text="")
+                       split = row.split(percentage=0.3)
+                       split.itemL(text="Blend:")
+                       split.itemR(mat, "diffuse_ramp_blend", text="")
+                       
                
 class MATERIAL_PT_specular(MaterialButtonsPanel):
        __label__ = "Specular"
@@ -282,7 +286,16 @@ class MATERIAL_PT_specular(MaterialButtonsPanel):
                        row.itemR(mat, "specular_toon_smooth", text="Smooth")
                
                if mat.use_specular_ramp:
+                       layout.itemS()
                        layout.template_color_ramp(mat.specular_ramp, expand=True)
+                       layout.itemS()
+                       row = layout.row()
+                       split = row.split(percentage=0.3)
+                       split.itemL(text="Input:")
+                       split.itemR(mat, "specular_ramp_input", text="")
+                       split = row.split(percentage=0.3)
+                       split.itemL(text="Blend:")
+                       split.itemR(mat, "specular_ramp_blend", text="")
                
 class MATERIAL_PT_sss(MaterialButtonsPanel):
        __label__ = "Subsurface Scattering"
index d7c677d05f3dd46b06417e2c682709f28e7606b2..eb908bcd2bdbebd62bc454880272e895043a4b7d 100644 (file)
@@ -477,6 +477,32 @@ static void rna_def_material_mtex(BlenderRNA *brna)
 static void rna_def_material_colors(StructRNA *srna)
 {
        PropertyRNA *prop;
+       
+       static EnumPropertyItem prop_ramp_blend_diffuse_items[] = {
+               {MA_RAMP_BLEND, "MIX", 0, "Mix", ""},
+               {MA_RAMP_ADD, "ADD", 0, "Add", ""},
+               {MA_RAMP_MULT, "MULTIPLY", 0, "Multiply", ""},
+               {MA_RAMP_SUB, "SUBTRACT", 0, "Subtract", ""},
+               {MA_RAMP_SCREEN, "SCREEN", 0, "Screen", ""},
+               {MA_RAMP_DIV, "DIVIDE", 0, "Divide", ""},
+               {MA_RAMP_DIFF, "DIFFERENCE", 0, "Difference", ""},
+               {MA_RAMP_DARK, "DARKEN", 0, "Darken", ""},
+               {MA_RAMP_LIGHT, "LIGHTEN", 0, "Lighten", ""},
+               {MA_RAMP_OVERLAY, "OVERLAY", 0, "Overlay", ""},
+               {MA_RAMP_DODGE, "DODGE", 0, "Dodge", ""},
+               {MA_RAMP_BURN, "BURN", 0, "Burn", ""},
+               {MA_RAMP_HUE, "HUE", 0, "Hue", ""},
+               {MA_RAMP_SAT, "SATURATION", 0, "Saturation", ""},
+               {MA_RAMP_VAL, "VALUE", 0, "Value", ""},
+               {MA_RAMP_COLOR, "COLOR", 0, "Color", ""},
+               {0, NULL, 0, NULL, NULL}};
+
+       static EnumPropertyItem prop_ramp_input_items[] = {
+               {MA_RAMP_IN_SHADER, "SHADER", 0, "Shader", ""},
+               {MA_RAMP_IN_ENERGY, "ENERGY", 0, "Energy", ""},
+               {MA_RAMP_IN_NOR, "NORMAL", 0, "Normal", ""},
+               {MA_RAMP_IN_RESULT, "RESULT", 0, "Result", ""},
+               {0, NULL, 0, NULL, NULL}};
 
        prop= RNA_def_property(srna, "diffuse_color", PROP_FLOAT, PROP_COLOR);
        RNA_def_property_float_sdna(prop, NULL, "r");
@@ -523,6 +549,31 @@ static void rna_def_material_colors(StructRNA *srna)
        RNA_def_property_pointer_sdna(prop, NULL, "ramp_spec");
        RNA_def_property_struct_type(prop, "ColorRamp");
        RNA_def_property_ui_text(prop, "Specular Ramp", "Color ramp used to affect specular shading.");
+       
+       prop= RNA_def_property(srna, "diffuse_ramp_blend", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "rampblend_col");
+       RNA_def_property_enum_items(prop, prop_ramp_blend_diffuse_items);
+       RNA_def_property_ui_text(prop, "Diffuse Ramp Blend", "");
+       RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING_DRAW, NULL);
+       
+       prop= RNA_def_property(srna, "specular_ramp_blend", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "rampblend_spec");
+       RNA_def_property_enum_items(prop, prop_ramp_blend_diffuse_items);
+       RNA_def_property_ui_text(prop, "Diffuse Ramp Blend", "");
+       RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING_DRAW, NULL);
+
+       prop= RNA_def_property(srna, "diffuse_ramp_input", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "rampin_col");
+       RNA_def_property_enum_items(prop, prop_ramp_input_items);
+       RNA_def_property_ui_text(prop, "Diffuse Ramp Input", "");
+       RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL);
+       
+       prop= RNA_def_property(srna, "specular_ramp_input", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "rampin_spec");
+       RNA_def_property_enum_items(prop, prop_ramp_input_items);
+       RNA_def_property_ui_text(prop, "Specular Ramp Input", "");
+       RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL);
+
 }
 
 static void rna_def_material_diffuse(StructRNA *srna)