1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
21 from bpy.types import Menu, Panel, UIList
23 from bpy.types import (
34 from rna_prop_ui import PropertyPanel
36 from bl_ui.properties_paint_common import brush_texture_settings
39 class TEXTURE_MT_specials(Menu):
40 bl_label = "Texture Specials"
41 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
43 def draw(self, context):
46 layout.operator("texture.slot_copy", icon='COPYDOWN')
47 layout.operator("texture.slot_paste", icon='PASTEDOWN')
50 class TEXTURE_MT_envmap_specials(Menu):
51 bl_label = "Environment Map Specials"
52 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
54 def draw(self, context):
57 layout.operator("texture.envmap_save", icon='IMAGEFILE')
58 layout.operator("texture.envmap_clear", icon='FILE_REFRESH')
59 layout.operator("texture.envmap_clear_all", icon='FILE_REFRESH')
62 class TEXTURE_UL_texslots(UIList):
63 def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
64 # assert(isinstance(item, bpy.types.MaterialTextureSlot)
67 tex = slot.texture if slot else None
68 if self.layout_type in {'DEFAULT', 'COMPACT'}:
70 layout.prop(tex, "name", text="", emboss=False, icon_value=icon)
72 layout.label(text="", icon_value=icon)
73 if tex and isinstance(item, bpy.types.MaterialTextureSlot):
74 layout.prop(ma, "use_textures", text="", index=index)
75 elif self.layout_type == 'GRID':
76 layout.alignment = 'CENTER'
77 layout.label(text="", icon_value=icon)
80 from bl_ui.properties_material import active_node_mat
83 def context_tex_datablock(context):
84 idblock = context.material
86 return active_node_mat(idblock)
88 idblock = context.lamp
92 idblock = context.world
96 idblock = context.brush
100 idblock = context.line_style
104 if context.particle_system:
105 idblock = context.particle_system.settings
110 def id_tex_datablock(bid):
111 if isinstance(bid, Object):
112 if bid.type == 'LAMP':
114 return bid.active_material
119 class TextureButtonsPanel:
120 bl_space_type = 'PROPERTIES'
121 bl_region_type = 'WINDOW'
122 bl_context = "texture"
125 def poll(cls, context):
126 tex = context.texture
127 return tex and (tex.type != 'NONE' or tex.use_nodes) and (context.scene.render.engine in cls.COMPAT_ENGINES)
130 class TEXTURE_PT_context_texture(TextureButtonsPanel, Panel):
132 bl_options = {'HIDE_HEADER'}
133 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
136 def poll(cls, context):
137 engine = context.scene.render.engine
138 # if not (hasattr(context, "texture_slot") or hasattr(context, "texture_node")):
140 return ((context.material or
144 context.line_style or
145 context.particle_system or
146 isinstance(context.space_data.pin_id, ParticleSettings) or
147 context.texture_user) and
148 (engine in cls.COMPAT_ENGINES))
150 def draw(self, context):
153 slot = getattr(context, "texture_slot", None)
154 node = getattr(context, "texture_node", None)
155 space = context.space_data
156 tex = context.texture
157 idblock = context_tex_datablock(context)
158 pin_id = space.pin_id
160 space.use_limited_texture_context = True
162 if space.use_pin_id and not isinstance(pin_id, Texture):
163 idblock = id_tex_datablock(pin_id)
166 if not space.use_pin_id:
167 layout.prop(space, "texture_context", expand=True)
170 if space.texture_context == 'OTHER':
172 layout.template_texture_user()
173 user = context.texture_user
180 row.template_ID(space, "pin_id")
182 propname = context.texture_user_property.identifier
183 row.template_ID(user, propname, new="texture.new")
186 split = layout.split(percentage=0.2)
189 split.label(text="Output:")
190 split.prop(slot, "output_node", text="")
192 split.label(text="Type:")
193 split.prop(tex, "type", text="")
196 tex_collection = (pin_id is None) and (node is None) and (not isinstance(idblock, Brush))
201 row.template_list("TEXTURE_UL_texslots", "", idblock, "texture_slots", idblock, "active_texture_index", rows=2)
203 col = row.column(align=True)
204 col.operator("texture.slot_move", text="", icon='TRIA_UP').type = 'UP'
205 col.operator("texture.slot_move", text="", icon='TRIA_DOWN').type = 'DOWN'
206 col.menu("TEXTURE_MT_specials", icon='DOWNARROW_HLT', text="")
209 layout.template_ID(idblock, "active_texture", new="texture.new")
211 layout.template_ID(node, "texture", new="texture.new")
213 layout.template_ID(idblock, "texture", new="texture.new")
216 layout.template_ID(space, "pin_id")
219 split = layout.split(percentage=0.2)
222 split.label(text="Output:")
223 split.prop(slot, "output_node", text="")
225 split.label(text="Type:")
226 split.prop(tex, "type", text="")
229 class TEXTURE_PT_preview(TextureButtonsPanel, Panel):
231 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
233 def draw(self, context):
236 tex = context.texture
237 slot = getattr(context, "texture_slot", None)
238 idblock = context_tex_datablock(context)
241 layout.template_preview(tex, parent=idblock, slot=slot)
243 layout.template_preview(tex, slot=slot)
245 #Show Alpha Button for Brush Textures, see #29502
246 if context.space_data.texture_context == 'BRUSH':
247 layout.prop(tex, "use_preview_alpha")
250 class TEXTURE_PT_colors(TextureButtonsPanel, Panel):
252 bl_options = {'DEFAULT_CLOSED'}
253 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
255 def draw(self, context):
258 tex = context.texture
260 layout.prop(tex, "use_color_ramp", text="Ramp")
261 if tex.use_color_ramp:
262 layout.template_color_ramp(tex, "color_ramp", expand=True)
264 split = layout.split()
267 col.label(text="RGB Multiply:")
268 sub = col.column(align=True)
269 sub.prop(tex, "factor_red", text="R")
270 sub.prop(tex, "factor_green", text="G")
271 sub.prop(tex, "factor_blue", text="B")
274 col.label(text="Adjust:")
275 col.prop(tex, "intensity")
276 col.prop(tex, "contrast")
277 col.prop(tex, "saturation")
279 col = layout.column()
280 col.prop(tex, "use_clamp", text="Clamp")
282 # Texture Slot Panels #
285 class TextureSlotPanel(TextureButtonsPanel):
286 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
289 def poll(cls, context):
290 if not hasattr(context, "texture_slot"):
293 engine = context.scene.render.engine
294 return TextureButtonsPanel.poll(cls, context) and (engine in cls.COMPAT_ENGINES)
297 # Texture Type Panels #
300 class TextureTypePanel(TextureButtonsPanel):
303 def poll(cls, context):
304 tex = context.texture
305 engine = context.scene.render.engine
306 return tex and ((tex.type == cls.tex_type and not tex.use_nodes) and (engine in cls.COMPAT_ENGINES))
309 class TEXTURE_PT_clouds(TextureTypePanel, Panel):
312 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
314 def draw(self, context):
317 tex = context.texture
319 layout.prop(tex, "cloud_type", expand=True)
320 layout.label(text="Noise:")
321 layout.prop(tex, "noise_type", text="Type", expand=True)
322 layout.prop(tex, "noise_basis", text="Basis")
324 split = layout.split()
327 col.prop(tex, "noise_scale", text="Size")
328 col.prop(tex, "noise_depth", text="Depth")
330 split.prop(tex, "nabla", text="Nabla")
333 class TEXTURE_PT_wood(TextureTypePanel, Panel):
336 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
338 def draw(self, context):
341 tex = context.texture
343 layout.prop(tex, "noise_basis_2", expand=True)
344 layout.prop(tex, "wood_type", expand=True)
346 col = layout.column()
347 col.active = tex.wood_type in {'RINGNOISE', 'BANDNOISE'}
348 col.label(text="Noise:")
349 col.row().prop(tex, "noise_type", text="Type", expand=True)
350 layout.prop(tex, "noise_basis", text="Basis")
352 split = layout.split()
353 split.active = tex.wood_type in {'RINGNOISE', 'BANDNOISE'}
356 col.prop(tex, "noise_scale", text="Size")
357 col.prop(tex, "turbulence")
359 split.prop(tex, "nabla")
362 class TEXTURE_PT_marble(TextureTypePanel, Panel):
365 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
367 def draw(self, context):
370 tex = context.texture
372 layout.prop(tex, "marble_type", expand=True)
373 layout.prop(tex, "noise_basis_2", expand=True)
374 layout.label(text="Noise:")
375 layout.prop(tex, "noise_type", text="Type", expand=True)
376 layout.prop(tex, "noise_basis", text="Basis")
378 split = layout.split()
381 col.prop(tex, "noise_scale", text="Size")
382 col.prop(tex, "noise_depth", text="Depth")
385 col.prop(tex, "turbulence")
386 col.prop(tex, "nabla")
389 class TEXTURE_PT_magic(TextureTypePanel, Panel):
392 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
394 def draw(self, context):
397 tex = context.texture
400 row.prop(tex, "noise_depth", text="Depth")
401 row.prop(tex, "turbulence")
404 class TEXTURE_PT_blend(TextureTypePanel, Panel):
407 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
409 def draw(self, context):
412 tex = context.texture
414 layout.prop(tex, "progression")
418 sub.active = (tex.progression in {'LINEAR', 'QUADRATIC', 'EASING', 'RADIAL'})
419 sub.prop(tex, "use_flip_axis", expand=True)
422 class TEXTURE_PT_stucci(TextureTypePanel, Panel):
425 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
427 def draw(self, context):
430 tex = context.texture
432 layout.prop(tex, "stucci_type", expand=True)
433 layout.label(text="Noise:")
434 layout.prop(tex, "noise_type", text="Type", expand=True)
435 layout.prop(tex, "noise_basis", text="Basis")
438 row.prop(tex, "noise_scale", text="Size")
439 row.prop(tex, "turbulence")
442 class TEXTURE_PT_image(TextureTypePanel, Panel):
445 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
447 def draw(self, context):
450 tex = context.texture
452 layout.template_image(tex, "image", tex.image_user)
455 def texture_filter_common(tex, layout):
456 layout.label(text="Filter:")
457 layout.prop(tex, "filter_type", text="")
458 if tex.use_mipmap and tex.filter_type in {'AREA', 'EWA', 'FELINE'}:
459 if tex.filter_type == 'FELINE':
460 layout.prop(tex, "filter_probes", text="Probes")
462 layout.prop(tex, "filter_eccentricity", text="Eccentricity")
464 layout.prop(tex, "filter_size")
465 layout.prop(tex, "use_filter_size_min")
468 class TEXTURE_PT_image_sampling(TextureTypePanel, Panel):
469 bl_label = "Image Sampling"
470 bl_options = {'DEFAULT_CLOSED'}
472 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
474 def draw(self, context):
475 if context.scene.render.engine == 'BLENDER_GAME':
476 self.draw_bge(context)
478 self.draw_bi(context)
480 def draw_bi(self, context):
483 idblock = context_tex_datablock(context)
484 tex = context.texture
485 slot = getattr(context, "texture_slot", None)
487 split = layout.split()
490 col.label(text="Alpha:")
492 row.active = bool(tex.image and tex.image.use_alpha)
493 row.prop(tex, "use_alpha", text="Use")
494 col.prop(tex, "use_calculate_alpha", text="Calculate")
495 col.prop(tex, "invert_alpha", text="Invert")
497 col.prop(tex, "use_flip_axis", text="Flip X/Y Axis")
501 #Only for Material based textures, not for Lamp/World...
502 if slot and isinstance(idblock, Material):
503 col.prop(tex, "use_normal_map")
505 row.active = tex.use_normal_map
506 row.prop(slot, "normal_map_space", text="")
509 row.active = not tex.use_normal_map
510 row.prop(tex, "use_derivative_map")
512 col.prop(tex, "use_mipmap")
514 row.active = tex.use_mipmap
515 row.prop(tex, "use_mipmap_gauss")
516 col.prop(tex, "use_interpolation")
518 texture_filter_common(tex, col)
520 def draw_bge(self, context):
523 idblock = context_tex_datablock(context)
524 tex = context.texture
525 slot = getattr(context, "texture_slot", None)
527 split = layout.split()
530 col.label(text="Alpha:")
531 col.prop(tex, "use_calculate_alpha", text="Calculate")
532 col.prop(tex, "invert_alpha", text="Invert")
536 #Only for Material based textures, not for Lamp/World...
537 if slot and isinstance(idblock, Material):
538 col.prop(tex, "use_normal_map")
540 row.active = tex.use_normal_map
541 row.prop(slot, "normal_map_space", text="")
544 row.active = not tex.use_normal_map
545 row.prop(tex, "use_derivative_map")
548 class TEXTURE_PT_image_mapping(TextureTypePanel, Panel):
549 bl_label = "Image Mapping"
550 bl_options = {'DEFAULT_CLOSED'}
552 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
554 def draw(self, context):
557 tex = context.texture
559 layout.prop(tex, "extension")
561 split = layout.split()
563 if tex.extension == 'REPEAT':
564 col = split.column(align=True)
565 col.label(text="Repeat:")
566 col.prop(tex, "repeat_x", text="X")
567 col.prop(tex, "repeat_y", text="Y")
569 col = split.column(align=True)
570 col.label(text="Mirror:")
571 row = col.row(align=True)
572 row.prop(tex, "use_mirror_x", text="X")
573 row.active = (tex.repeat_x > 1)
574 row = col.row(align=True)
575 row.prop(tex, "use_mirror_y", text="Y")
576 row.active = (tex.repeat_y > 1)
579 elif tex.extension == 'CHECKER':
580 col = split.column(align=True)
581 row = col.row(align=True)
582 row.prop(tex, "use_checker_even", text="Even")
583 row.prop(tex, "use_checker_odd", text="Odd")
586 col.prop(tex, "checker_distance", text="Distance")
590 split = layout.split()
592 col = split.column(align=True)
593 #col.prop(tex, "crop_rectangle")
594 col.label(text="Crop Minimum:")
595 col.prop(tex, "crop_min_x", text="X")
596 col.prop(tex, "crop_min_y", text="Y")
598 col = split.column(align=True)
599 col.label(text="Crop Maximum:")
600 col.prop(tex, "crop_max_x", text="X")
601 col.prop(tex, "crop_max_y", text="Y")
604 class TEXTURE_PT_envmap(TextureTypePanel, Panel):
605 bl_label = "Environment Map"
606 tex_type = 'ENVIRONMENT_MAP'
607 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
609 def draw(self, context):
612 tex = context.texture
613 env = tex.environment_map
616 row.prop(env, "source", expand=True)
617 row.menu("TEXTURE_MT_envmap_specials", icon='DOWNARROW_HLT', text="")
619 if env.source == 'IMAGE_FILE':
620 layout.template_ID(tex, "image", open="image.open")
621 layout.template_image(tex, "image", tex.image_user, compact=True)
623 layout.prop(env, "mapping")
624 if env.mapping == 'PLANE':
625 layout.prop(env, "zoom")
626 layout.prop(env, "viewpoint_object")
628 split = layout.split()
631 col.prop(env, "layers_ignore")
632 col.prop(env, "resolution")
633 col.prop(env, "depth")
635 col = split.column(align=True)
637 col.label(text="Clipping:")
638 col.prop(env, "clip_start", text="Start")
639 col.prop(env, "clip_end", text="End")
642 class TEXTURE_PT_envmap_sampling(TextureTypePanel, Panel):
643 bl_label = "Environment Map Sampling"
644 bl_options = {'DEFAULT_CLOSED'}
645 tex_type = 'ENVIRONMENT_MAP'
646 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
648 def draw(self, context):
651 tex = context.texture
653 texture_filter_common(tex, layout)
656 class TEXTURE_PT_musgrave(TextureTypePanel, Panel):
657 bl_label = "Musgrave"
658 tex_type = 'MUSGRAVE'
659 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
661 def draw(self, context):
664 tex = context.texture
666 layout.prop(tex, "musgrave_type")
668 split = layout.split()
671 col.prop(tex, "dimension_max", text="Dimension")
672 col.prop(tex, "lacunarity")
673 col.prop(tex, "octaves")
675 musgrave_type = tex.musgrave_type
677 if musgrave_type in {'HETERO_TERRAIN', 'RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL'}:
678 col.prop(tex, "offset")
679 col.prop(tex, "noise_intensity", text="Intensity")
680 if musgrave_type in {'RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL'}:
681 col.prop(tex, "gain")
683 layout.label(text="Noise:")
685 layout.prop(tex, "noise_basis", text="Basis")
688 row.prop(tex, "noise_scale", text="Size")
689 row.prop(tex, "nabla")
692 class TEXTURE_PT_voronoi(TextureTypePanel, Panel):
695 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
697 def draw(self, context):
700 tex = context.texture
702 split = layout.split()
705 col.label(text="Distance Metric:")
706 col.prop(tex, "distance_metric", text="")
708 sub.active = tex.distance_metric == 'MINKOVSKY'
709 sub.prop(tex, "minkovsky_exponent", text="Exponent")
710 col.label(text="Coloring:")
711 col.prop(tex, "color_mode", text="")
712 col.prop(tex, "noise_intensity", text="Intensity")
715 sub = col.column(align=True)
716 sub.label(text="Feature Weights:")
717 sub.prop(tex, "weight_1", text="1", slider=True)
718 sub.prop(tex, "weight_2", text="2", slider=True)
719 sub.prop(tex, "weight_3", text="3", slider=True)
720 sub.prop(tex, "weight_4", text="4", slider=True)
722 layout.label(text="Noise:")
724 row.prop(tex, "noise_scale", text="Size")
725 row.prop(tex, "nabla")
728 class TEXTURE_PT_distortednoise(TextureTypePanel, Panel):
729 bl_label = "Distorted Noise"
730 tex_type = 'DISTORTED_NOISE'
731 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
733 def draw(self, context):
736 tex = context.texture
738 layout.prop(tex, "noise_distortion")
739 layout.prop(tex, "noise_basis", text="Basis")
741 split = layout.split()
744 col.prop(tex, "distortion", text="Distortion")
745 col.prop(tex, "noise_scale", text="Size")
747 split.prop(tex, "nabla")
750 class TEXTURE_PT_voxeldata(TextureButtonsPanel, Panel):
751 bl_label = "Voxel Data"
752 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
755 def poll(cls, context):
756 tex = context.texture
757 engine = context.scene.render.engine
758 return tex and (tex.type == 'VOXEL_DATA' and (engine in cls.COMPAT_ENGINES))
760 def draw(self, context):
763 tex = context.texture
766 layout.prop(vd, "file_format")
767 if vd.file_format in {'BLENDER_VOXEL', 'RAW_8BIT'}:
768 layout.prop(vd, "filepath")
769 if vd.file_format == 'RAW_8BIT':
770 layout.prop(vd, "resolution")
771 elif vd.file_format == 'SMOKE':
772 layout.prop(vd, "domain_object")
773 layout.prop(vd, "smoke_data_type")
774 elif vd.file_format == 'HAIR':
775 layout.prop(vd, "domain_object")
776 layout.prop(vd, "hair_data_type")
777 elif vd.file_format == 'IMAGE_SEQUENCE':
778 layout.template_ID(tex, "image", open="image.open")
779 layout.template_image(tex, "image", tex.image_user, compact=True)
780 #layout.prop(vd, "frame_duration")
782 if vd.file_format in {'BLENDER_VOXEL', 'RAW_8BIT'}:
783 layout.prop(vd, "use_still_frame")
785 row.active = vd.use_still_frame
786 row.prop(vd, "still_frame")
788 layout.prop(vd, "interpolation")
789 layout.prop(vd, "extension")
790 layout.prop(vd, "intensity")
793 class TEXTURE_PT_pointdensity(TextureButtonsPanel, Panel):
794 bl_label = "Point Density"
795 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
798 def poll(cls, context):
799 tex = context.texture
800 engine = context.scene.render.engine
801 return tex and (tex.type == 'POINT_DENSITY' and (engine in cls.COMPAT_ENGINES))
803 def draw(self, context):
806 tex = context.texture
807 pd = tex.point_density
809 layout.prop(pd, "point_source", expand=True)
811 split = layout.split()
814 if pd.point_source == 'PARTICLE_SYSTEM':
815 col.label(text="Object:")
816 col.prop(pd, "object", text="")
819 sub.enabled = bool(pd.object)
821 sub.label(text="System:")
822 sub.prop_search(pd, "particle_system", pd.object, "particle_systems", text="")
823 sub.label(text="Cache:")
824 sub.prop(pd, "particle_cache_space", text="")
826 col.label(text="Object:")
827 col.prop(pd, "object", text="")
828 col.label(text="Cache:")
829 col.prop(pd, "vertex_cache_space", text="")
833 if pd.point_source == 'PARTICLE_SYSTEM':
834 col.label(text="Color Source:")
835 col.prop(pd, "color_source", text="")
836 if pd.color_source in {'PARTICLE_SPEED', 'PARTICLE_VELOCITY'}:
837 col.prop(pd, "speed_scale")
838 if pd.color_source in {'PARTICLE_SPEED', 'PARTICLE_AGE'}:
839 layout.template_color_ramp(pd, "color_ramp", expand=True)
843 col.prop(pd, "radius")
844 col.label(text="Falloff:")
845 col.prop(pd, "falloff", text="")
846 if pd.falloff == 'SOFT':
847 col.prop(pd, "falloff_soft")
848 if pd.falloff == 'PARTICLE_VELOCITY':
849 col.prop(pd, "falloff_speed_scale")
851 col.prop(pd, "use_falloff_curve")
853 if pd.use_falloff_curve:
854 col = layout.column()
855 col.label(text="Falloff Curve")
856 col.template_curve_mapping(pd, "falloff_curve", brush=False)
859 class TEXTURE_PT_pointdensity_turbulence(TextureButtonsPanel, Panel):
860 bl_label = "Turbulence"
861 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
864 def poll(cls, context):
865 tex = context.texture
866 engine = context.scene.render.engine
867 return tex and (tex.type == 'POINT_DENSITY' and (engine in cls.COMPAT_ENGINES))
869 def draw_header(self, context):
870 pd = context.texture.point_density
872 self.layout.prop(pd, "use_turbulence", text="")
874 def draw(self, context):
877 tex = context.texture
878 pd = tex.point_density
879 layout.active = pd.use_turbulence
881 split = layout.split()
884 col.label(text="Influence:")
885 col.prop(pd, "turbulence_influence", text="")
886 col.label(text="Noise Basis:")
887 col.prop(pd, "noise_basis", text="")
891 col.prop(pd, "turbulence_scale")
892 col.prop(pd, "turbulence_depth")
893 col.prop(pd, "turbulence_strength")
896 class TEXTURE_PT_ocean(TextureTypePanel, Panel):
899 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
901 def draw(self, context):
904 tex = context.texture
907 col = layout.column()
908 col.prop(ot, "ocean_object")
909 col.prop(ot, "output")
912 class TEXTURE_PT_mapping(TextureSlotPanel, Panel):
914 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
917 def poll(cls, context):
918 idblock = context_tex_datablock(context)
919 if isinstance(idblock, Brush) and not context.sculpt_object:
922 if not getattr(context, "texture_slot", None):
925 engine = context.scene.render.engine
926 return (engine in cls.COMPAT_ENGINES)
928 def draw(self, context):
931 idblock = context_tex_datablock(context)
933 tex = context.texture_slot
935 if not isinstance(idblock, Brush):
936 split = layout.split(percentage=0.3)
938 col.label(text="Coordinates:")
940 col.prop(tex, "texture_coords", text="")
942 if tex.texture_coords == 'ORCO':
945 if ob and ob.type == 'MESH':
946 split = layout.split(percentage=0.3)
947 split.label(text="Mesh:")
948 split.prop(ob.data, "texco_mesh", text="")
950 elif tex.texture_coords == 'UV':
951 split = layout.split(percentage=0.3)
952 split.label(text="Map:")
954 if ob and ob.type == 'MESH':
955 split.prop_search(tex, "uv_layer", ob.data, "uv_textures", text="")
957 split.prop(tex, "uv_layer", text="")
959 elif tex.texture_coords == 'OBJECT':
960 split = layout.split(percentage=0.3)
961 split.label(text="Object:")
962 split.prop(tex, "object", text="")
964 elif tex.texture_coords == 'ALONG_STROKE':
965 split = layout.split(percentage=0.3)
966 split.label(text="Use Tips:")
967 split.prop(tex, "use_tips", text="")
969 if isinstance(idblock, Brush):
970 if context.sculpt_object or context.image_paint_object:
971 brush_texture_settings(layout, idblock, context.sculpt_object)
973 if isinstance(idblock, FreestyleLineStyle):
974 split = layout.split(percentage=0.3)
975 split.label(text="Projection:")
976 split.prop(tex, "mapping", text="")
978 split = layout.split(percentage=0.3)
981 row.prop(tex, "mapping_x", text="")
982 row.prop(tex, "mapping_y", text="")
983 row.prop(tex, "mapping_z", text="")
985 elif isinstance(idblock, Material):
986 split = layout.split(percentage=0.3)
987 split.label(text="Projection:")
988 split.prop(tex, "mapping", text="")
990 split = layout.split()
993 if tex.texture_coords in {'ORCO', 'UV'}:
994 col.prop(tex, "use_from_dupli")
995 if (idblock.type == 'VOLUME' and tex.texture_coords == 'ORCO'):
996 col.prop(tex, "use_map_to_bounds")
997 elif tex.texture_coords == 'OBJECT':
998 col.prop(tex, "use_from_original")
999 if (idblock.type == 'VOLUME'):
1000 col.prop(tex, "use_map_to_bounds")
1004 col = split.column()
1006 row.prop(tex, "mapping_x", text="")
1007 row.prop(tex, "mapping_y", text="")
1008 row.prop(tex, "mapping_z", text="")
1011 row.column().prop(tex, "offset")
1012 row.column().prop(tex, "scale")
1015 class TEXTURE_PT_influence(TextureSlotPanel, Panel):
1016 bl_label = "Influence"
1017 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
1020 def poll(cls, context):
1021 idblock = context_tex_datablock(context)
1022 if isinstance(idblock, Brush):
1025 if not getattr(context, "texture_slot", None):
1028 engine = context.scene.render.engine
1029 return (engine in cls.COMPAT_ENGINES)
1031 def draw(self, context):
1033 layout = self.layout
1035 idblock = context_tex_datablock(context)
1037 tex = context.texture_slot
1039 def factor_but(layout, toggle, factor, name):
1040 row = layout.row(align=True)
1041 row.prop(tex, toggle, text="")
1042 sub = row.row(align=True)
1043 sub.active = getattr(tex, toggle)
1044 sub.prop(tex, factor, text=name, slider=True)
1045 return sub # XXX, temp. use_map_normal needs to override.
1047 if isinstance(idblock, Material):
1048 if idblock.type in {'SURFACE', 'WIRE'}:
1049 split = layout.split()
1051 col = split.column()
1052 col.label(text="Diffuse:")
1053 factor_but(col, "use_map_diffuse", "diffuse_factor", "Intensity")
1054 factor_but(col, "use_map_color_diffuse", "diffuse_color_factor", "Color")
1055 factor_but(col, "use_map_alpha", "alpha_factor", "Alpha")
1056 factor_but(col, "use_map_translucency", "translucency_factor", "Translucency")
1058 col.label(text="Specular:")
1059 factor_but(col, "use_map_specular", "specular_factor", "Intensity")
1060 factor_but(col, "use_map_color_spec", "specular_color_factor", "Color")
1061 factor_but(col, "use_map_hardness", "hardness_factor", "Hardness")
1063 col = split.column()
1064 col.label(text="Shading:")
1065 factor_but(col, "use_map_ambient", "ambient_factor", "Ambient")
1066 factor_but(col, "use_map_emit", "emit_factor", "Emit")
1067 factor_but(col, "use_map_mirror", "mirror_factor", "Mirror")
1068 factor_but(col, "use_map_raymir", "raymir_factor", "Ray Mirror")
1070 col.label(text="Geometry:")
1071 # XXX replace 'or' when displacement is fixed to not rely on normal influence value.
1072 sub_tmp = factor_but(col, "use_map_normal", "normal_factor", "Normal")
1073 sub_tmp.active = (tex.use_map_normal or tex.use_map_displacement)
1076 factor_but(col, "use_map_warp", "warp_factor", "Warp")
1077 factor_but(col, "use_map_displacement", "displacement_factor", "Displace")
1079 #~ sub = col.column()
1080 #~ sub.active = tex.use_map_translucency or tex.map_emit or tex.map_alpha or tex.map_raymir or tex.map_hardness or tex.map_ambient or tex.map_specularity or tex.map_reflection or tex.map_mirror
1081 #~ sub.prop(tex, "default_value", text="Amount", slider=True)
1082 elif idblock.type == 'HALO':
1083 layout.label(text="Halo:")
1085 split = layout.split()
1087 col = split.column()
1088 factor_but(col, "use_map_color_diffuse", "diffuse_color_factor", "Color")
1089 factor_but(col, "use_map_alpha", "alpha_factor", "Alpha")
1091 col = split.column()
1092 factor_but(col, "use_map_raymir", "raymir_factor", "Size")
1093 factor_but(col, "use_map_hardness", "hardness_factor", "Hardness")
1094 factor_but(col, "use_map_translucency", "translucency_factor", "Add")
1095 elif idblock.type == 'VOLUME':
1096 layout.label(text="Volume:")
1098 split = layout.split()
1100 col = split.column()
1101 factor_but(col, "use_map_density", "density_factor", "Density")
1102 factor_but(col, "use_map_emission", "emission_factor", "Emission")
1103 factor_but(col, "use_map_scatter", "scattering_factor", "Scattering")
1104 factor_but(col, "use_map_reflect", "reflection_factor", "Reflection")
1106 col = split.column()
1108 factor_but(col, "use_map_color_emission", "emission_color_factor", "Emission Color")
1109 factor_but(col, "use_map_color_transmission", "transmission_color_factor", "Transmission Color")
1110 factor_but(col, "use_map_color_reflection", "reflection_color_factor", "Reflection Color")
1112 layout.label(text="Geometry:")
1114 split = layout.split()
1116 col = split.column()
1117 factor_but(col, "use_map_warp", "warp_factor", "Warp")
1119 col = split.column()
1120 factor_but(col, "use_map_displacement", "displacement_factor", "Displace")
1122 elif isinstance(idblock, Lamp):
1123 split = layout.split()
1125 col = split.column()
1126 factor_but(col, "use_map_color", "color_factor", "Color")
1128 col = split.column()
1129 factor_but(col, "use_map_shadow", "shadow_factor", "Shadow")
1131 elif isinstance(idblock, World):
1132 split = layout.split()
1134 col = split.column()
1135 factor_but(col, "use_map_blend", "blend_factor", "Blend")
1136 factor_but(col, "use_map_horizon", "horizon_factor", "Horizon")
1138 col = split.column()
1139 factor_but(col, "use_map_zenith_up", "zenith_up_factor", "Zenith Up")
1140 factor_but(col, "use_map_zenith_down", "zenith_down_factor", "Zenith Down")
1141 elif isinstance(idblock, ParticleSettings):
1142 split = layout.split()
1144 col = split.column()
1145 col.label(text="General:")
1146 factor_but(col, "use_map_time", "time_factor", "Time")
1147 factor_but(col, "use_map_life", "life_factor", "Lifetime")
1148 factor_but(col, "use_map_density", "density_factor", "Density")
1149 factor_but(col, "use_map_size", "size_factor", "Size")
1151 col = split.column()
1152 col.label(text="Physics:")
1153 factor_but(col, "use_map_velocity", "velocity_factor", "Velocity")
1154 factor_but(col, "use_map_damp", "damp_factor", "Damp")
1155 factor_but(col, "use_map_gravity", "gravity_factor", "Gravity")
1156 factor_but(col, "use_map_field", "field_factor", "Force Fields")
1158 layout.label(text="Hair:")
1160 split = layout.split()
1162 col = split.column()
1163 factor_but(col, "use_map_length", "length_factor", "Length")
1164 factor_but(col, "use_map_clump", "clump_factor", "Clump")
1166 col = split.column()
1167 factor_but(col, "use_map_kink_amp", "kink_amp_factor", "Kink Amplitude")
1168 factor_but(col, "use_map_kink_freq", "kink_freq_factor", "Kink Frequency")
1169 factor_but(col, "use_map_rough", "rough_factor", "Rough")
1171 elif isinstance(idblock, FreestyleLineStyle):
1172 split = layout.split()
1174 col = split.column()
1175 factor_but(col, "use_map_color_diffuse", "diffuse_color_factor", "Color")
1176 col = split.column()
1177 factor_but(col, "use_map_alpha", "alpha_factor", "Alpha")
1181 if not isinstance(idblock, ParticleSettings):
1182 split = layout.split()
1184 col = split.column()
1185 col.prop(tex, "blend_type", text="Blend")
1186 col.prop(tex, "use_rgb_to_intensity")
1187 # color is used on gray-scale textures even when use_rgb_to_intensity is disabled.
1188 col.prop(tex, "color", text="")
1190 col = split.column()
1191 col.prop(tex, "invert", text="Negative")
1192 col.prop(tex, "use_stencil")
1194 if isinstance(idblock, Material) or isinstance(idblock, World):
1195 col.prop(tex, "default_value", text="DVar", slider=True)
1197 if isinstance(idblock, Material):
1198 layout.label(text="Bump Mapping:")
1200 # only show bump settings if activated but not for normal-map images
1204 sub.active = (tex.use_map_normal or tex.use_map_warp) and not (tex.texture.type == 'IMAGE' and (tex.texture.use_normal_map or tex.texture.use_derivative_map))
1205 sub.prop(tex, "bump_method", text="Method")
1207 # the space setting is supported for: derivative-maps + bump-maps (DEFAULT,BEST_QUALITY), not for normal-maps
1209 sub.active = (tex.use_map_normal or tex.use_map_warp) and not (tex.texture.type == 'IMAGE' and tex.texture.use_normal_map) and ((tex.bump_method in {'BUMP_LOW_QUALITY', 'BUMP_MEDIUM_QUALITY', 'BUMP_BEST_QUALITY'}) or (tex.texture.type == 'IMAGE' and tex.texture.use_derivative_map))
1210 sub.prop(tex, "bump_objectspace", text="Space")
1213 class TEXTURE_PT_custom_props(TextureButtonsPanel, PropertyPanel, Panel):
1214 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
1215 _context_path = "texture"
1216 _property_type = Texture
1218 if __name__ == "__main__": # only for live edit.
1219 bpy.utils.register_module(__name__)