Skip to content
Snippets Groups Projects
shading_properties.py 67.2 KiB
Newer Older
  • Learn to ignore specific revisions
  • Maurice Raybaud's avatar
    Maurice Raybaud committed
                    self.layout.prop(mat, "use_transparency", text="")
    
            def draw(self, context):
                layout = self.layout
    
                base_mat = context.material
                mat = active_node_mat(context.material)
                rayt = mat.raytrace_transparency
    
                if simple_material(base_mat):
                    row = layout.row()
                    row.active = mat.use_transparency
                    row.prop(mat, "transparency_method", expand=True)
    
                split = layout.split()
                split.active = base_mat.use_transparency
    
                col = split.column()
                col.prop(mat, "alpha")
                row = col.row()
                row.active = (base_mat.transparency_method != 'MASK') and (not mat.use_shadeless)
                row.prop(mat, "specular_alpha", text="Specular")
    
                col = split.column()
                col.active = (not mat.use_shadeless)
                col.prop(rayt, "fresnel")
                sub = col.column()
                sub.active = (rayt.fresnel > 0.0)
                sub.prop(rayt, "fresnel_factor", text="Blend")
    
                if base_mat.transparency_method == 'RAYTRACE':
                    layout.separator()
                    split = layout.split()
                    split.active = base_mat.use_transparency
    
                    col = split.column()
                    col.prop(rayt, "ior")
                    col.prop(rayt, "filter")
                    col.prop(rayt, "falloff")
                    col.prop(rayt, "depth_max")
                    col.prop(rayt, "depth")
    
                    col = split.column()
                    col.label(text="Gloss:")
                    col.prop(rayt, "gloss_factor", text="Amount")
                    sub = col.column()
                    sub.active = rayt.gloss_factor < 1.0
                    sub.prop(rayt, "gloss_threshold", text="Threshold")
                    sub.prop(rayt, "gloss_samples", text="Samples")
    
    
        class MATERIAL_PT_mirror(MaterialButtonsPanel, Panel):
            bl_label = "Mirror"
            bl_options = {'DEFAULT_CLOSED'}
            COMPAT_ENGINES = {'BLENDER_RENDER'}
    
            @classmethod
            def poll(cls, context):
                mat = context.material
                engine = context.scene.render.engine
                return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
    
            def draw_header(self, context):
                raym = active_node_mat(context.material).raytrace_mirror
    
                self.layout.prop(raym, "use", text="")
    
            def draw(self, context):
                layout = self.layout
    
                mat = active_node_mat(context.material)
                raym = mat.raytrace_mirror
    
                layout.active = raym.use
    
                split = layout.split()
    
                col = split.column()
                col.prop(raym, "reflect_factor")
                col.prop(mat, "mirror_color", text="")
    
                col = split.column()
                col.prop(raym, "fresnel")
                sub = col.column()
                sub.active = (raym.fresnel > 0.0)
                sub.prop(raym, "fresnel_factor", text="Blend")
    
                split = layout.split()
    
                col = split.column()
                col.separator()
                col.prop(raym, "depth")
                col.prop(raym, "distance", text="Max Dist")
                col.separator()
                sub = col.split(percentage=0.4)
                sub.active = (raym.distance > 0.0)
                sub.label(text="Fade To:")
                sub.prop(raym, "fade_to", text="")
    
                col = split.column()
                col.label(text="Gloss:")
                col.prop(raym, "gloss_factor", text="Amount")
                sub = col.column()
                sub.active = (raym.gloss_factor < 1.0)
                sub.prop(raym, "gloss_threshold", text="Threshold")
                sub.prop(raym, "gloss_samples", text="Samples")
                sub.prop(raym, "gloss_anisotropic", text="Anisotropic")
    
    
        class MATERIAL_PT_sss(MaterialButtonsPanel, Panel):
            bl_label = "Subsurface Scattering"
            bl_options = {'DEFAULT_CLOSED'}
            COMPAT_ENGINES = {'BLENDER_RENDER'}
    
            @classmethod
            def poll(cls, context):
                mat = context.material
                engine = context.scene.render.engine
                return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
    
            def draw_header(self, context):
                mat = active_node_mat(context.material)
                sss = mat.subsurface_scattering
    
                self.layout.active = (not mat.use_shadeless)
                self.layout.prop(sss, "use", text="")
    
            def draw(self, context):
                layout = self.layout
    
                mat = active_node_mat(context.material)
                sss = mat.subsurface_scattering
    
                layout.active = (sss.use) and (not mat.use_shadeless)
    
                row = layout.row().split()
                sub = row.row(align=True).split(align=True, percentage=0.75)
                sub.menu("MATERIAL_MT_sss_presets", text=bpy.types.MATERIAL_MT_sss_presets.bl_label)
                sub.operator("material.sss_preset_add", text="", icon='ZOOMIN')
                sub.operator("material.sss_preset_add", text="", icon='ZOOMOUT').remove_active = True
    
                split = layout.split()
    
                col = split.column()
                col.prop(sss, "ior")
                col.prop(sss, "scale")
                col.prop(sss, "color", text="")
                col.prop(sss, "radius", text="RGB Radius", expand=True)
    
                col = split.column()
                sub = col.column(align=True)
                sub.label(text="Blend:")
                sub.prop(sss, "color_factor", text="Color")
                sub.prop(sss, "texture_factor", text="Texture")
                sub.label(text="Scattering Weight:")
                sub.prop(sss, "front")
                sub.prop(sss, "back")
                col.separator()
                col.prop(sss, "error_threshold", text="Error")
    
    
        class MATERIAL_PT_halo(MaterialButtonsPanel, Panel):
            bl_label = "Halo"
            COMPAT_ENGINES = {'BLENDER_RENDER'}
    
            @classmethod
            def poll(cls, context):
                mat = context.material
                engine = context.scene.render.engine
                return mat and (mat.type == 'HALO') and (engine in cls.COMPAT_ENGINES)
    
            def draw(self, context):
                layout = self.layout
    
                mat = context.material  # don't use node material
                halo = mat.halo
    
                def number_but(layout, toggle, number, name, color):
                    row = layout.row(align=True)
                    row.prop(halo, toggle, text="")
                    sub = row.column(align=True)
                    sub.active = getattr(halo, toggle)
                    sub.prop(halo, number, text=name, translate=False)
                    if not color == "":
                        sub.prop(mat, color, text="")
    
                split = layout.split()
    
                col = split.column()
                col.prop(mat, "alpha")
                col.prop(mat, "diffuse_color", text="")
                col.prop(halo, "seed")
    
                col = split.column()
                col.prop(halo, "size")
                col.prop(halo, "hardness")
                col.prop(halo, "add")
    
                layout.label(text="Options:")
    
                split = layout.split()
                col = split.column()
                col.prop(halo, "use_texture")
                col.prop(halo, "use_vertex_normal")
                col.prop(halo, "use_extreme_alpha")
                col.prop(halo, "use_shaded")
                col.prop(halo, "use_soft")
    
                col = split.column()
                number_but(col, "use_ring", "ring_count", iface_("Rings"), "mirror_color")
                number_but(col, "use_lines", "line_count", iface_("Lines"), "specular_color")
                number_but(col, "use_star", "star_tip_count", iface_("Star Tips"), "")
    
    
        class MATERIAL_PT_flare(MaterialButtonsPanel, Panel):
            bl_label = "Flare"
            COMPAT_ENGINES = {'BLENDER_RENDER'}
    
            @classmethod
            def poll(cls, context):
                mat = context.material
                engine = context.scene.render.engine
                return mat and (mat.type == 'HALO') and (engine in cls.COMPAT_ENGINES)
    
            def draw_header(self, context):
                halo = context.material.halo
    
                self.layout.prop(halo, "use_flare_mode", text="")
    
            def draw(self, context):
                layout = self.layout
    
                mat = context.material  # don't use node material
                halo = mat.halo
    
                layout.active = halo.use_flare_mode
    
                split = layout.split()
    
                col = split.column()
                col.prop(halo, "flare_size", text="Size")
                col.prop(halo, "flare_boost", text="Boost")
                col.prop(halo, "flare_seed", text="Seed")
    
                col = split.column()
                col.prop(halo, "flare_subflare_count", text="Subflares")
                col.prop(halo, "flare_subflare_size", text="Subsize")
    
        """
    
    
    
    # ------------------------------ End Old Blender Internal Props ------------------------------ #
    
    Maurice Raybaud's avatar
    Maurice Raybaud committed
    
    
    classes = (
        RenderPovSettingsMaterial,
        MaterialRaytraceTransparency,
        MaterialRaytraceMirror,
        MaterialSubsurfaceScattering,
        MaterialStrandSettings,
    )
    
    
    def register():
        for cls in classes:
            register_class(cls)
    
        bpy.types.Material.pov = PointerProperty(type=RenderPovSettingsMaterial)
        bpy.types.Material.pov_raytrace_transparency = PointerProperty(
            type=MaterialRaytraceTransparency
        )
        bpy.types.Material.pov_subsurface_scattering = PointerProperty(
            type=MaterialSubsurfaceScattering
        )
        bpy.types.Material.strand = PointerProperty(type=MaterialStrandSettings)
        bpy.types.Material.pov_raytrace_mirror = PointerProperty(type=MaterialRaytraceMirror)
    
    
    def unregister():
        del bpy.types.Material.pov_subsurface_scattering
        del bpy.types.Material.strand
        del bpy.types.Material.pov_raytrace_mirror
        del bpy.types.Material.pov_raytrace_transparency
        del bpy.types.Material.pov
    
        for cls in reversed(classes):
            unregister_class(cls)