2.5 Material:
authorThomas Dinges <blender@dingto.org>
Sun, 14 Jun 2009 18:16:38 +0000 (18:16 +0000)
committerThomas Dinges <blender@dingto.org>
Sun, 14 Jun 2009 18:16:38 +0000 (18:16 +0000)
* Some material button tweaks by William. Thanks.

* Some more material notifiers.

release/ui/buttons_material.py
source/blender/makesrna/intern/rna_material.c

index ca1eba03881a1e891eb654bcb5fca4e7a6bd9ca4..e29fe211424d08934b5aad7272422863255b68ba 100644 (file)
@@ -47,14 +47,14 @@ class MATERIAL_PT_material(MaterialButtonsPanel):
                        layout.itemS()
                
                        layout.itemR(mat, "type", expand=True)
-
-                       row = layout.row()
-                       row.column().itemR(mat, "diffuse_color")
-                       row.column().itemR(mat, "specular_color")
-                       row.column().itemR(mat, "mirror_color")
                        
                        layout.itemR(mat, "alpha", slider=True)
 
+                       row = layout.row()
+                       row.itemR(mat, "shadeless")     
+                       row.itemR(mat, "wireframe")
+                       
+                       
 class MATERIAL_PT_tangent(MaterialButtonsPanel):
        __idname__= "MATERIAL_PT_tangent"
        __label__ = "Tangent Shading"
@@ -68,6 +68,8 @@ class MATERIAL_PT_tangent(MaterialButtonsPanel):
        def draw(self, context):
                layout = self.layout
                tan = context.material.strand
+               mat = context.material
+               layout.active = mat.tangent_shading     
                
                split = layout.split()
                
@@ -111,10 +113,11 @@ class MATERIAL_PT_options(MaterialButtonsPanel):
                sub = split.column()
                sub.itemL(text="Shadows:")
                sub.itemR(mat, "shadows", text="Recieve")
-               sub.itemR(mat, "only_shadow", text="Render Shadows Only")
+               sub.itemR(mat, "transparent_shadows", text="Recieve Transparent")
+               sub.itemR(mat, "only_shadow", text="Shadows Only")
                sub.itemR(mat, "cast_shadows_only", text="Cast Only")
-               sub.itemR(mat, "shadow_casting_alpha", text="Alpha", slider=True)
-               sub.itemR(mat, "transparent_shadows")
+               sub.itemR(mat, "shadow_casting_alpha", text="Casting Alpha", slider=True)
+               
                sub.itemR(mat, "ray_shadow_bias")
                colsub = sub.column()
                colsub.active = mat.ray_shadow_bias
@@ -124,9 +127,9 @@ class MATERIAL_PT_options(MaterialButtonsPanel):
                colsub.active = mat.cast_buffer_shadows
                colsub.itemR(mat, "shadow_buffer_bias", text="Buffer Bias")
 
-class MATERIAL_PT_shading(MaterialButtonsPanel):
-       __idname__= "MATERIAL_PT_shading"
-       __label__ = "Shading"
+class MATERIAL_PT_diffuse(MaterialButtonsPanel):
+       __idname__= "MATERIAL_PT_diffuse"
+       __label__ = "Diffuse"
 
        def poll(self, context):
                mat = context.material
@@ -134,47 +137,68 @@ class MATERIAL_PT_shading(MaterialButtonsPanel):
 
        def draw(self, context):
                layout = self.layout
-               mat = context.material
-               
-               row = layout.row()
-               row.itemR(mat, "shadeless")     
-               row.itemR(mat, "wireframe")
-               
-               #Diffuse
-               layout.itemL(text="Diffuse:")
-               layout.itemR(mat, "diffuse_shader", text="Shader")
-               layout.itemR(mat, "diffuse_ramp", text="Ramp")
+               mat = context.material  
                
                split = layout.split()
                
                sub = split.column()
-               sub.itemR(mat, "diffuse_reflection", text="Reflection")
-               sub.itemR(mat, "roughness")
-               sub.itemR(mat, "params1_4")
-               
-               sub = split.column()
-               sub.itemR(mat, "darkness")
+               sub.itemR(mat, "diffuse_color", text="")
+               sub.itemR(mat, "diffuse_reflection", text="Reflection", slider=True)
                sub.itemR(mat, "emit")
                sub.itemR(mat, "ambient", slider=True)
                sub.itemR(mat, "translucency", slider=True)
+               
+               sub = split.column()
                sub.itemR(mat, "object_color")
                sub.itemR(mat, "vertex_color_light")
                sub.itemR(mat, "vertex_color_paint")
                sub.itemR(mat, "cubic")
                
-               layout.itemS()
+               layout.itemR(mat, "diffuse_shader", text="Shader")
+               split = layout.split()
+               sub = split.column()
+               if mat.diffuse_shader == 'OREN_NAYAR':
+                               sub.itemR(mat, "roughness")
+               if mat.diffuse_shader == 'MINNAERT':
+                       sub.itemR(mat, "darkness")
+               sub = split.column()
+               sub.itemR(mat, "params1_4", text="")
+               
+               layout.itemR(mat, "diffuse_ramp", text="Ramp")
+
+class MATERIAL_PT_specular(MaterialButtonsPanel):
+       __idname__= "MATERIAL_PT_specular"
+       __label__ = "Specular"
+
+       def poll(self, context):
+               mat = context.material
+               return (mat and mat.type != "HALO")
+
+       def draw(self, context):
+               layout = self.layout
+               mat = context.material
+               
+               split = layout.split()
+               
+               sub = split.column()
+               sub.itemR(mat, "specular_color", text="")
+               sub = split.column()
+               sub.itemR(mat, "specularity", text="Intensity", slider=True)
                
-               #Specular
-               layout.itemL(text="Specular:")
                layout.itemR(mat, "spec_shader", text="Shader")
+               
+               split = layout.split()
+               
+               sub = split.column()
+               if (mat.spec_shader in ('COOKTORR', 'PHONG', 'BLINN')):
+                       sub.itemR(mat, "specular_hardness", text="Hardness")
+               if (mat.spec_shader in ('BLINN')):
+                       sub.itemR(mat, "specular_refraction", text="IOR")
+               if (mat.spec_shader in ('WARDISO')):
+                       sub.itemR(mat, "specular_slope", text="Slope")
+               
                layout.itemR(mat, "specular_ramp", text="Ramp")
 
-               flow = layout.column_flow()
-               flow.itemR(mat, "specularity", text="Intensity")
-               flow.itemR(mat, "specular_hardness", text="Hardness")
-               flow.itemR(mat, "specular_refraction", text="IOR")
-               flow.itemR(mat, "specular_slope", text="Slope")
-
 class MATERIAL_PT_sss(MaterialButtonsPanel):
        __idname__= "MATERIAL_PT_sss"
        __label__ = "Subsurface Scattering"
@@ -194,21 +218,23 @@ class MATERIAL_PT_sss(MaterialButtonsPanel):
                sss = context.material.subsurface_scattering
                layout.active = sss.enabled     
                
-               flow = layout.column_flow()
-               flow.itemR(sss, "error_tolerance")
-               flow.itemR(sss, "ior")
-               flow.itemR(sss, "scale")
-               
-               row = layout.row()
-               row.column().itemR(sss, "color")
-               row.column().itemR(sss, "radius")
+               split = layout.split()
                
-               flow = layout.column_flow()
-               flow.itemR(sss, "color_factor", slider=True)
-               flow.itemR(sss, "texture_factor", slider=True)
-               flow.itemR(sss, "front")
-               flow.itemR(sss, "back")
+               sub = split.column()
+               sub.itemR(sss, "ior")
+               sub.itemR(sss, "scale")
+               sub.itemR(sss, "radius", text="RGB Radius")
+               sub.itemR(sss, "error_tolerance")
                
+               sub = split.column()
+               sub.itemR(sss, "color", text="")
+               sub.itemL(text="Blend:")
+               sub.itemR(sss, "color_factor", slider=True)
+               sub.itemR(sss, "texture_factor", slider=True)
+               sub.itemL(text="Scattering Weight:")
+               sub.itemR(sss, "front")
+               sub.itemR(sss, "back")
+
 class MATERIAL_PT_raymir(MaterialButtonsPanel):
        __idname__= "MATERIAL_PT_raymir"
        __label__ = "Ray Mirror"
@@ -226,12 +252,14 @@ class MATERIAL_PT_raymir(MaterialButtonsPanel):
        def draw(self, context):
                layout = self.layout
                raym = context.material.raytrace_mirror
+               mat = context.material
                
                layout.active = raym.enabled
                
                split = layout.split()
                
                sub = split.column()
+               sub.itemR(mat, "mirror_color", text="")
                sub.itemR(raym, "reflect", text="RayMir", slider=True)
                sub.itemR(raym, "fresnel")
                sub.itemR(raym, "fresnel_fac", text="Fac", slider=True)
@@ -304,7 +332,7 @@ class MATERIAL_PT_halo(MaterialButtonsPanel):
                split = layout.split()
                
                col = split.column()
-               col.itemL(text="General Settings:")
+               col.itemR(mat, "diffuse_color", text="")
                col.itemR(halo, "size")
                col.itemR(halo, "hardness")
                col.itemR(halo, "add", slider=True)
@@ -317,15 +345,17 @@ class MATERIAL_PT_halo(MaterialButtonsPanel):
                col.itemR(halo, "soft")
 
                col = split.column()
-               col = col.column(align=True)
+               col = col.column()
                col.itemR(halo, "ring")
                colsub = col.column()
                colsub.active = halo.ring
                colsub.itemR(halo, "rings")
+               colsub.itemR(mat, "mirror_color", text="")
                col.itemR(halo, "lines")
                colsub = col.column()
                colsub.active = halo.lines
                colsub.itemR(halo, "line_number", text="Lines")
+               colsub.itemR(mat, "specular_color", text="")
                col.itemR(halo, "star")
                colsub = col.column()
                colsub.active = halo.star
@@ -341,7 +371,8 @@ class MATERIAL_PT_halo(MaterialButtonsPanel):
 
 bpy.types.register(MATERIAL_PT_preview)
 bpy.types.register(MATERIAL_PT_material)
-bpy.types.register(MATERIAL_PT_shading)
+bpy.types.register(MATERIAL_PT_diffuse)
+bpy.types.register(MATERIAL_PT_specular)
 bpy.types.register(MATERIAL_PT_raymir)
 bpy.types.register(MATERIAL_PT_raytransp)
 bpy.types.register(MATERIAL_PT_sss)
index 780985707833bf54237a0ec26f83a2b9d3d5296e..3facfab16f61c308e170ee8859627cfadecd45cc 100644 (file)
@@ -753,6 +753,7 @@ void rna_def_material_specularity(StructRNA *srna)
        RNA_def_property_float_sdna(prop, NULL, "spec");
        RNA_def_property_range(prop, 0, 1);
        RNA_def_property_ui_text(prop, "Specularity Intensity", "");
+       RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL);
 
        /* XXX: this field is also used for Halo hardness. should probably be fixed in DNA */
        /* I guess it's fine. Specular is disabled when mat type is Halo. --DingTo */
@@ -760,11 +761,13 @@ void rna_def_material_specularity(StructRNA *srna)
        RNA_def_property_float_sdna(prop, NULL, "har");
        RNA_def_property_range(prop, 1, 511);
        RNA_def_property_ui_text(prop, "Specular Hardness", "");
+       RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL);
 
        prop= RNA_def_property(srna, "specular_refraction", PROP_FLOAT, PROP_NONE);
        RNA_def_property_float_sdna(prop, NULL, "refrac");
        RNA_def_property_range(prop, 1, 10);
        RNA_def_property_ui_text(prop, "Specular IOR", "");
+       RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL);
 
        /* XXX: evil "param" field also does specular stuff */
 
@@ -772,6 +775,7 @@ void rna_def_material_specularity(StructRNA *srna)
        RNA_def_property_float_sdna(prop, NULL, "rms");
        RNA_def_property_range(prop, 0, 0.4);
        RNA_def_property_ui_text(prop, "Specular Slope", "The standard deviation of surface slope.");
+       RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL);
 }
 
 void rna_def_material_strand(BlenderRNA *brna)
@@ -787,48 +791,58 @@ void rna_def_material_strand(BlenderRNA *brna)
        prop= RNA_def_property(srna, "tangent_shading", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TANGENT_STR);
        RNA_def_property_ui_text(prop, "Tangent Shading", "Uses direction of strands as normal for tangent-shading.");
+       RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL);
        
        prop= RNA_def_property(srna, "surface_diffuse", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_STR_SURFDIFF);
        RNA_def_property_ui_text(prop, "Surface Diffuse", "Make diffuse shading more similar to shading the surface.");
+       RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL);
 
        prop= RNA_def_property(srna, "blend_distance", PROP_FLOAT, PROP_NONE);
        RNA_def_property_float_sdna(prop, NULL, "strand_surfnor");
        RNA_def_property_range(prop, 0, 10);
        RNA_def_property_ui_text(prop, "Blend Distance", "Distance in Blender units over which to blend in the surface normal.");
+       RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL);
 
        prop= RNA_def_property(srna, "blender_units", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_STR_B_UNITS);
        RNA_def_property_ui_text(prop, "Blender Units", "Use Blender units for widths instead of pixels.");
+       RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL);
 
        prop= RNA_def_property(srna, "start_size", PROP_FLOAT, PROP_UNSIGNED);
        RNA_def_property_float_sdna(prop, NULL, "strand_sta");
        RNA_def_property_float_funcs(prop, NULL, NULL, "rna_MaterialStrand_start_size_range");
        RNA_def_property_ui_text(prop, "Start Size", "Start size of strands in pixels Blender units.");
+       RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL);
 
        prop= RNA_def_property(srna, "end_size", PROP_FLOAT, PROP_UNSIGNED);
        RNA_def_property_float_sdna(prop, NULL, "strand_end");
        RNA_def_property_float_funcs(prop, NULL, NULL, "rna_MaterialStrand_end_size_range");
        RNA_def_property_ui_text(prop, "End Size", "Start size of strands in pixels or Blender units.");
+       RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL);
 
        prop= RNA_def_property(srna, "min_size", PROP_FLOAT, PROP_UNSIGNED);
        RNA_def_property_float_sdna(prop, NULL, "strand_min");
        RNA_def_property_range(prop, 0.001, 10);
        RNA_def_property_ui_text(prop, "Minimum Size", "Minimum size of strands in pixels.");
+       RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL);
 
        prop= RNA_def_property(srna, "shape", PROP_FLOAT, PROP_NONE);
        RNA_def_property_float_sdna(prop, NULL, "strand_ease");
        RNA_def_property_range(prop, -0.9, 0.9);
        RNA_def_property_ui_text(prop, "Shape", "Positive values make strands rounder, negative makes strands spiky.");
+       RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL);
 
        prop= RNA_def_property(srna, "width_fade", PROP_FLOAT, PROP_NONE);
        RNA_def_property_float_sdna(prop, NULL, "strand_widthfade");
        RNA_def_property_range(prop, 0, 2);
        RNA_def_property_ui_text(prop, "Width Fade", "Transparency along the width of the strand.");
+       RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL);
 
        prop= RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE);
        RNA_def_property_string_sdna(prop, NULL, "strand_uvname");
        RNA_def_property_ui_text(prop, "UV Layer", "Name of UV layer to override.");
+       RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL);
 }
 
 void RNA_def_material(BlenderRNA *brna)