Bugfix 26578
[blender.git] / release / scripts / startup / bl_ui / properties_texture.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
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.
7 #
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.
12 #
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.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from rna_prop_ui import PropertyPanel
22
23
24 class TEXTURE_MT_specials(bpy.types.Menu):
25     bl_label = "Texture Specials"
26     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
27
28     def draw(self, context):
29         layout = self.layout
30
31         layout.operator("texture.slot_copy", icon='COPYDOWN')
32         layout.operator("texture.slot_paste", icon='PASTEDOWN')
33
34
35 class TEXTURE_MT_envmap_specials(bpy.types.Menu):
36     bl_label = "Environment Map Specials"
37     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
38
39     def draw(self, context):
40         layout = self.layout
41
42         layout.operator("texture.envmap_save", icon='IMAGEFILE')
43         layout.operator("texture.envmap_clear", icon='FILE_REFRESH')
44         layout.operator("texture.envmap_clear_all", icon='FILE_REFRESH')
45
46 from bl_ui.properties_material import active_node_mat
47
48
49 def context_tex_datablock(context):
50     idblock = context.material
51     if idblock:
52         return active_node_mat(idblock)
53
54     idblock = context.lamp
55     if idblock:
56         return idblock
57
58     idblock = context.world
59     if idblock:
60         return idblock
61
62     idblock = context.brush
63     if idblock:
64         return idblock
65
66     if context.particle_system:
67         idblock = context.particle_system.settings
68
69     return idblock
70
71
72 class TextureButtonsPanel():
73     bl_space_type = 'PROPERTIES'
74     bl_region_type = 'WINDOW'
75     bl_context = "texture"
76
77     @classmethod
78     def poll(cls, context):
79         tex = context.texture
80         return tex and (tex.type != 'NONE' or tex.use_nodes) and (context.scene.render.engine in cls.COMPAT_ENGINES)
81
82
83 class TEXTURE_PT_context_texture(TextureButtonsPanel, bpy.types.Panel):
84     bl_label = ""
85     bl_options = {'HIDE_HEADER'}
86     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
87
88     @classmethod
89     def poll(cls, context):
90         engine = context.scene.render.engine
91         if not hasattr(context, "texture_slot"):
92             return False
93         return ((context.material or context.world or context.lamp or context.brush or context.texture or context.particle_system or isinstance(context.space_data.pin_id, bpy.types.ParticleSettings))
94             and (engine in cls.COMPAT_ENGINES))
95
96     def draw(self, context):
97         layout = self.layout
98         slot = context.texture_slot
99         node = context.texture_node
100         space = context.space_data
101         tex = context.texture
102         idblock = context_tex_datablock(context)
103         pin_id = space.pin_id
104
105         if space.use_pin_id and not isinstance(pin_id, bpy.types.Texture):
106             idblock = pin_id
107             pin_id = None
108
109         if not space.use_pin_id:
110             layout.prop(space, "texture_context", expand=True)
111
112         tex_collection = (pin_id is None) and (node is None) and (not isinstance(idblock, bpy.types.Brush))
113
114         if tex_collection:
115             row = layout.row()
116
117             row.template_list(idblock, "texture_slots", idblock, "active_texture_index", rows=2)
118
119             col = row.column(align=True)
120             col.operator("texture.slot_move", text="", icon='TRIA_UP').type = 'UP'
121             col.operator("texture.slot_move", text="", icon='TRIA_DOWN').type = 'DOWN'
122             col.menu("TEXTURE_MT_specials", icon='DOWNARROW_HLT', text="")
123
124         split = layout.split(percentage=0.65)
125         col = split.column()
126
127         if tex_collection:
128             col.template_ID(idblock, "active_texture", new="texture.new")
129         elif node:
130             col.template_ID(node, "texture", new="texture.new")
131         elif idblock:
132             col.template_ID(idblock, "texture", new="texture.new")
133
134         if pin_id:
135             col.template_ID(space, "pin_id")
136
137         col = split.column()
138
139         if tex:
140             split = layout.split(percentage=0.2)
141
142             if tex.use_nodes:
143
144                 if slot:
145                     split.label(text="Output:")
146                     split.prop(slot, "output_node", text="")
147
148             else:
149                 split.label(text="Type:")
150                 split.prop(tex, "type", text="")
151
152
153 class TEXTURE_PT_preview(TextureButtonsPanel, bpy.types.Panel):
154     bl_label = "Preview"
155     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
156
157     def draw(self, context):
158         layout = self.layout
159
160         tex = context.texture
161         slot = getattr(context, "texture_slot", None)
162         idblock = context_tex_datablock(context)
163
164         if idblock:
165             layout.template_preview(tex, parent=idblock, slot=slot)
166         else:
167             layout.template_preview(tex, slot=slot)
168
169
170 class TEXTURE_PT_colors(TextureButtonsPanel, bpy.types.Panel):
171     bl_label = "Colors"
172     bl_options = {'DEFAULT_CLOSED'}
173     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
174
175     def draw(self, context):
176         layout = self.layout
177
178         tex = context.texture
179
180         layout.prop(tex, "use_color_ramp", text="Ramp")
181         if tex.use_color_ramp:
182             layout.template_color_ramp(tex, "color_ramp", expand=True)
183
184         split = layout.split()
185
186         col = split.column()
187         col.label(text="RGB Multiply:")
188         sub = col.column(align=True)
189         sub.prop(tex, "factor_red", text="R")
190         sub.prop(tex, "factor_green", text="G")
191         sub.prop(tex, "factor_blue", text="B")
192
193         col = split.column()
194         col.label(text="Adjust:")
195         col.prop(tex, "intensity")
196         col.prop(tex, "contrast")
197         col.prop(tex, "saturation")
198
199 # Texture Slot Panels #
200
201
202 class TextureSlotPanel(TextureButtonsPanel):
203     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
204
205     @classmethod
206     def poll(cls, context):
207         if not hasattr(context, "texture_slot"):
208             return False
209
210         engine = context.scene.render.engine
211         return TextureButtonsPanel.poll(self, context) and (engine in cls.COMPAT_ENGINES)
212
213
214 # Texture Type Panels #
215
216
217 class TextureTypePanel(TextureButtonsPanel):
218
219     @classmethod
220     def poll(cls, context):
221         tex = context.texture
222         engine = context.scene.render.engine
223         return tex and ((tex.type == cls.tex_type and not tex.use_nodes) and (engine in cls.COMPAT_ENGINES))
224
225
226 class TEXTURE_PT_clouds(TextureTypePanel, bpy.types.Panel):
227     bl_label = "Clouds"
228     tex_type = 'CLOUDS'
229     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
230
231     def draw(self, context):
232         layout = self.layout
233
234         tex = context.texture
235
236         layout.prop(tex, "cloud_type", expand=True)
237         layout.label(text="Noise:")
238         layout.prop(tex, "noise_type", text="Type", expand=True)
239         layout.prop(tex, "noise_basis", text="Basis")
240
241         split = layout.split()
242
243         col = split.column()
244         col.prop(tex, "noise_scale", text="Size")
245         col.prop(tex, "noise_depth", text="Depth")
246
247         split.prop(tex, "nabla", text="Nabla")
248
249
250 class TEXTURE_PT_wood(TextureTypePanel, bpy.types.Panel):
251     bl_label = "Wood"
252     tex_type = 'WOOD'
253     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
254
255     def draw(self, context):
256         layout = self.layout
257
258         tex = context.texture
259
260         layout.prop(tex, "noisebasis_2", expand=True)
261         layout.prop(tex, "wood_type", expand=True)
262
263         col = layout.column()
264         col.active = tex.wood_type in {'RINGNOISE', 'BANDNOISE'}
265         col.label(text="Noise:")
266         col.row().prop(tex, "noise_type", text="Type", expand=True)
267         layout.prop(tex, "noise_basis", text="Basis")
268
269         split = layout.split()
270         split.active = tex.wood_type in {'RINGNOISE', 'BANDNOISE'}
271
272         col = split.column()
273         col.prop(tex, "noise_scale", text="Size")
274         col.prop(tex, "turbulence")
275
276         split.prop(tex, "nabla")
277
278
279 class TEXTURE_PT_marble(TextureTypePanel, bpy.types.Panel):
280     bl_label = "Marble"
281     tex_type = 'MARBLE'
282     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
283
284     def draw(self, context):
285         layout = self.layout
286
287         tex = context.texture
288
289         layout.prop(tex, "marble_type", expand=True)
290         layout.prop(tex, "noisebasis_2", expand=True)
291         layout.label(text="Noise:")
292         layout.prop(tex, "noise_type", text="Type", expand=True)
293         layout.prop(tex, "noise_basis", text="Basis")
294
295         split = layout.split()
296
297         col = split.column()
298         col.prop(tex, "noise_scale", text="Size")
299         col.prop(tex, "noise_depth", text="Depth")
300
301         col = split.column()
302         col.prop(tex, "turbulence")
303         col.prop(tex, "nabla")
304
305
306 class TEXTURE_PT_magic(TextureTypePanel, bpy.types.Panel):
307     bl_label = "Magic"
308     tex_type = 'MAGIC'
309     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
310
311     def draw(self, context):
312         layout = self.layout
313
314         tex = context.texture
315
316         row = layout.row()
317         row.prop(tex, "noise_depth", text="Depth")
318         row.prop(tex, "turbulence")
319
320
321 class TEXTURE_PT_blend(TextureTypePanel, bpy.types.Panel):
322     bl_label = "Blend"
323     tex_type = 'BLEND'
324     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
325
326     def draw(self, context):
327         layout = self.layout
328
329         tex = context.texture
330
331         layout.prop(tex, "progression")
332
333         sub = layout.row()
334
335         sub.active = (tex.progression in {'LINEAR', 'QUADRATIC', 'EASING', 'RADIAL'})
336         sub.prop(tex, "use_flip_axis", expand=True)
337
338
339 class TEXTURE_PT_stucci(TextureTypePanel, bpy.types.Panel):
340     bl_label = "Stucci"
341     tex_type = 'STUCCI'
342     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
343
344     def draw(self, context):
345         layout = self.layout
346
347         tex = context.texture
348
349         layout.prop(tex, "stucci_type", expand=True)
350         layout.label(text="Noise:")
351         layout.prop(tex, "noise_type", text="Type", expand=True)
352         layout.prop(tex, "noise_basis", text="Basis")
353
354         row = layout.row()
355         row.prop(tex, "noise_scale", text="Size")
356         row.prop(tex, "turbulence")
357
358
359 class TEXTURE_PT_image(TextureTypePanel, bpy.types.Panel):
360     bl_label = "Image"
361     tex_type = 'IMAGE'
362     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
363
364     def draw(self, context):
365         layout = self.layout
366
367         tex = context.texture
368
369         layout.template_image(tex, "image", tex.image_user)
370
371
372 def texture_filter_common(tex, layout):
373     layout.label(text="Filter:")
374     layout.prop(tex, "filter_type", text="")
375     if tex.use_mipmap and tex.filter_type in {'AREA', 'EWA', 'FELINE'}:
376         if tex.filter_type == 'FELINE':
377             layout.prop(tex, "filter_probes", text="Probes")
378         else:
379             layout.prop(tex, "filter_eccentricity", text="Eccentricity")
380
381     layout.prop(tex, "filter_size")
382     layout.prop(tex, "use_filter_size_min")
383
384
385 class TEXTURE_PT_image_sampling(TextureTypePanel, bpy.types.Panel):
386     bl_label = "Image Sampling"
387     bl_options = {'DEFAULT_CLOSED'}
388     tex_type = 'IMAGE'
389     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
390
391     def draw(self, context):
392         layout = self.layout
393
394         idblock = context_tex_datablock(context)
395         tex = context.texture
396         slot = context.texture_slot
397
398         split = layout.split()
399
400         col = split.column()
401         col.label(text="Alpha:")
402         col.prop(tex, "use_alpha", text="Use")
403         col.prop(tex, "use_calculate_alpha", text="Calculate")
404         col.prop(tex, "invert_alpha", text="Invert")
405         col.separator()
406         col.prop(tex, "use_flip_axis", text="Flip X/Y Axis")
407
408         col = split.column()
409
410         #Only for Material based textures, not for Lamp/World...
411         if isinstance(idblock, bpy.types.Material):
412             col.prop(tex, "use_normal_map")
413             row = col.row()
414             row.active = tex.use_normal_map
415             row.prop(slot, "normal_map_space", text="")
416
417         col.prop(tex, "use_mipmap")
418         row = col.row()
419         row.active = tex.use_mipmap
420         row.prop(tex, "use_mipmap_gauss")
421         col.prop(tex, "use_interpolation")
422
423         texture_filter_common(tex, col)
424
425
426 class TEXTURE_PT_image_mapping(TextureTypePanel, bpy.types.Panel):
427     bl_label = "Image Mapping"
428     bl_options = {'DEFAULT_CLOSED'}
429     tex_type = 'IMAGE'
430     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
431
432     def draw(self, context):
433         layout = self.layout
434
435         tex = context.texture
436
437         layout.prop(tex, "extension")
438
439         split = layout.split()
440
441         if tex.extension == 'REPEAT':
442             col = split.column(align=True)
443             col.label(text="Repeat:")
444             col.prop(tex, "repeat_x", text="X")
445             col.prop(tex, "repeat_y", text="Y")
446
447             col = split.column(align=True)
448             col.label(text="Mirror:")
449             row = col.row()
450             row.prop(tex, "use_mirror_x", text="X")
451             row.active = (tex.repeat_x > 1)
452             row = col.row()
453             row.prop(tex, "use_mirror_y", text="Y")
454             row.active = (tex.repeat_y > 1)
455             layout.separator()
456
457         elif tex.extension == 'CHECKER':
458             col = split.column(align=True)
459             row = col.row()
460             row.prop(tex, "use_checker_even", text="Even")
461             row.prop(tex, "use_checker_odd", text="Odd")
462
463             col = split.column()
464             col.prop(tex, "checker_distance", text="Distance")
465
466             layout.separator()
467
468         split = layout.split()
469
470         col = split.column(align=True)
471         #col.prop(tex, "crop_rectangle")
472         col.label(text="Crop Minimum:")
473         col.prop(tex, "crop_min_x", text="X")
474         col.prop(tex, "crop_min_y", text="Y")
475
476         col = split.column(align=True)
477         col.label(text="Crop Maximum:")
478         col.prop(tex, "crop_max_x", text="X")
479         col.prop(tex, "crop_max_y", text="Y")
480
481
482 class TEXTURE_PT_envmap(TextureTypePanel, bpy.types.Panel):
483     bl_label = "Environment Map"
484     tex_type = 'ENVIRONMENT_MAP'
485     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
486
487     def draw(self, context):
488         layout = self.layout
489
490         tex = context.texture
491         env = tex.environment_map
492
493         row = layout.row()
494         row.prop(env, "source", expand=True)
495         row.menu("TEXTURE_MT_envmap_specials", icon='DOWNARROW_HLT', text="")
496
497         if env.source == 'IMAGE_FILE':
498             layout.template_ID(tex, "image", open="image.open")
499             layout.template_image(tex, "image", tex.image_user, compact=True)
500         else:
501             layout.prop(env, "mapping")
502             if env.mapping == 'PLANE':
503                 layout.prop(env, "zoom")
504             layout.prop(env, "viewpoint_object")
505
506             split = layout.split()
507
508             col = split.column()
509             col.prop(env, "layers_ignore")
510             col.prop(env, "resolution")
511             col.prop(env, "depth")
512
513             col = split.column(align=True)
514
515             col.label(text="Clipping:")
516             col.prop(env, "clip_start", text="Start")
517             col.prop(env, "clip_end", text="End")
518
519
520 class TEXTURE_PT_envmap_sampling(TextureTypePanel, bpy.types.Panel):
521     bl_label = "Environment Map Sampling"
522     bl_options = {'DEFAULT_CLOSED'}
523     tex_type = 'ENVIRONMENT_MAP'
524     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
525
526     def draw(self, context):
527         layout = self.layout
528
529         tex = context.texture
530
531         texture_filter_common(tex, layout)
532
533
534 class TEXTURE_PT_musgrave(TextureTypePanel, bpy.types.Panel):
535     bl_label = "Musgrave"
536     tex_type = 'MUSGRAVE'
537     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
538
539     def draw(self, context):
540         layout = self.layout
541
542         tex = context.texture
543
544         layout.prop(tex, "musgrave_type")
545
546         split = layout.split()
547
548         col = split.column()
549         col.prop(tex, "dimension_max", text="Dimension")
550         col.prop(tex, "lacunarity")
551         col.prop(tex, "octaves")
552
553         musgrave_type = tex.musgrave_type
554         col = split.column()
555         if musgrave_type in {'HETERO_TERRAIN', 'RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL'}:
556             col.prop(tex, "offset")
557         if musgrave_type in {'MULTIFRACTAL', 'RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL'}:
558             col.prop(tex, "noise_intensity", text="Intensity")
559         if musgrave_type in {'RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL'}:
560             col.prop(tex, "gain")
561
562         layout.label(text="Noise:")
563
564         layout.prop(tex, "noise_basis", text="Basis")
565
566         row = layout.row()
567         row.prop(tex, "noise_scale", text="Size")
568         row.prop(tex, "nabla")
569
570
571 class TEXTURE_PT_voronoi(TextureTypePanel, bpy.types.Panel):
572     bl_label = "Voronoi"
573     tex_type = 'VORONOI'
574     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
575
576     def draw(self, context):
577         layout = self.layout
578
579         tex = context.texture
580
581         split = layout.split()
582
583         col = split.column()
584         col.label(text="Distance Metric:")
585         col.prop(tex, "distance_metric", text="")
586         sub = col.column()
587         sub.active = tex.distance_metric == 'MINKOVSKY'
588         sub.prop(tex, "minkovsky_exponent", text="Exponent")
589         col.label(text="Coloring:")
590         col.prop(tex, "color_mode", text="")
591         col.prop(tex, "noise_intensity", text="Intensity")
592
593         col = split.column()
594         sub = col.column(align=True)
595         sub.label(text="Feature Weights:")
596         sub.prop(tex, "weight_1", text="1", slider=True)
597         sub.prop(tex, "weight_2", text="2", slider=True)
598         sub.prop(tex, "weight_3", text="3", slider=True)
599         sub.prop(tex, "weight_4", text="4", slider=True)
600
601         layout.label(text="Noise:")
602         row = layout.row()
603         row.prop(tex, "noise_scale", text="Size")
604         row.prop(tex, "nabla")
605
606
607 class TEXTURE_PT_distortednoise(TextureTypePanel, bpy.types.Panel):
608     bl_label = "Distorted Noise"
609     tex_type = 'DISTORTED_NOISE'
610     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
611
612     def draw(self, context):
613         layout = self.layout
614
615         tex = context.texture
616
617         layout.prop(tex, "noise_distortion")
618         layout.prop(tex, "noise_basis", text="Basis")
619
620         split = layout.split()
621
622         col = split.column()
623         col.prop(tex, "distortion", text="Distortion")
624         col.prop(tex, "noise_scale", text="Size")
625
626         split.prop(tex, "nabla")
627
628
629 class TEXTURE_PT_voxeldata(TextureButtonsPanel, bpy.types.Panel):
630     bl_label = "Voxel Data"
631     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
632
633     @classmethod
634     def poll(cls, context):
635         tex = context.texture
636         engine = context.scene.render.engine
637         return tex and (tex.type == 'VOXEL_DATA' and (engine in cls.COMPAT_ENGINES))
638
639     def draw(self, context):
640         layout = self.layout
641
642         tex = context.texture
643         vd = tex.voxel_data
644
645         layout.prop(vd, "file_format")
646         if vd.file_format in {'BLENDER_VOXEL', 'RAW_8BIT'}:
647             layout.prop(vd, "filepath")
648         if vd.file_format == 'RAW_8BIT':
649             layout.prop(vd, "resolution")
650         elif vd.file_format == 'SMOKE':
651             layout.prop(vd, "domain_object")
652             layout.prop(vd, "smoke_data_type")
653         elif vd.file_format == 'IMAGE_SEQUENCE':
654             layout.template_ID(tex, "image", open="image.open")
655             layout.template_image(tex, "image", tex.image_user, compact=True)
656             #layout.prop(vd, "frame_duration")
657
658         if vd.file_format in {'BLENDER_VOXEL', 'RAW_8BIT'}:
659             layout.prop(vd, "use_still_frame")
660             row = layout.row()
661             row.active = vd.use_still_frame
662             row.prop(vd, "still_frame")
663
664         layout.prop(vd, "interpolation")
665         layout.prop(vd, "extension")
666         layout.prop(vd, "intensity")
667
668
669 class TEXTURE_PT_pointdensity(TextureButtonsPanel, bpy.types.Panel):
670     bl_label = "Point Density"
671     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
672
673     @classmethod
674     def poll(cls, context):
675         tex = context.texture
676         engine = context.scene.render.engine
677         return tex and (tex.type == 'POINT_DENSITY' and (engine in cls.COMPAT_ENGINES))
678
679     def draw(self, context):
680         layout = self.layout
681
682         tex = context.texture
683         pd = tex.point_density
684
685         layout.prop(pd, "point_source", expand=True)
686
687         split = layout.split()
688
689         col = split.column()
690         if pd.point_source == 'PARTICLE_SYSTEM':
691             col.label(text="Object:")
692             col.prop(pd, "object", text="")
693
694             sub = col.column()
695             sub.enabled = bool(pd.object)
696             if pd.object:
697                 sub.label(text="System:")
698                 sub.prop_search(pd, "particle_system", pd.object, "particle_systems", text="")
699             sub.label(text="Cache:")
700             sub.prop(pd, "particle_cache_space", text="")
701         else:
702             col.label(text="Object:")
703             col.prop(pd, "object", text="")
704             col.label(text="Cache:")
705             col.prop(pd, "vertex_cache_space", text="")
706
707         col.separator()
708
709         if pd.point_source == 'PARTICLE_SYSTEM':
710             col.label(text="Color Source:")
711             col.prop(pd, "color_source", text="")
712             if pd.color_source in {'PARTICLE_SPEED', 'PARTICLE_VELOCITY'}:
713                 col.prop(pd, "speed_scale")
714             if pd.color_source in {'PARTICLE_SPEED', 'PARTICLE_AGE'}:
715                 layout.template_color_ramp(pd, "color_ramp", expand=True)
716
717         col = split.column()
718         col.label()
719         col.prop(pd, "radius")
720         col.label(text="Falloff:")
721         col.prop(pd, "falloff", text="")
722         if pd.falloff == 'SOFT':
723             col.prop(pd, "falloff_soft")
724
725
726 class TEXTURE_PT_pointdensity_turbulence(TextureButtonsPanel, bpy.types.Panel):
727     bl_label = "Turbulence"
728     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
729
730     @classmethod
731     def poll(cls, context):
732         tex = context.texture
733         engine = context.scene.render.engine
734         return tex and (tex.type == 'POINT_DENSITY' and (engine in cls.COMPAT_ENGINES))
735
736     def draw_header(self, context):
737         pd = context.texture.point_density
738
739         self.layout.prop(pd, "use_turbulence", text="")
740
741     def draw(self, context):
742         layout = self.layout
743
744         tex = context.texture
745         pd = tex.point_density
746         layout.active = pd.use_turbulence
747
748         split = layout.split()
749
750         col = split.column()
751         col.label(text="Influence:")
752         col.prop(pd, "turbulence_influence", text="")
753         col.label(text="Noise Basis:")
754         col.prop(pd, "noise_basis", text="")
755
756         col = split.column()
757         col.label()
758         col.prop(pd, "turbulence_scale")
759         col.prop(pd, "turbulence_depth")
760         col.prop(pd, "turbulence_strength")
761
762
763 class TEXTURE_PT_mapping(TextureSlotPanel, bpy.types.Panel):
764     bl_label = "Mapping"
765     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
766
767     @classmethod
768     def poll(cls, context):
769         idblock = context_tex_datablock(context)
770         if isinstance(idblock, bpy.types.Brush) and not context.sculpt_object:
771             return False
772
773         if not getattr(context, "texture_slot", None):
774             return False
775
776         engine = context.scene.render.engine
777         return (engine in cls.COMPAT_ENGINES)
778
779     def draw(self, context):
780         layout = self.layout
781
782         idblock = context_tex_datablock(context)
783
784         tex = context.texture_slot
785         # textype = context.texture
786
787         if not isinstance(idblock, bpy.types.Brush):
788             split = layout.split(percentage=0.3)
789             col = split.column()
790             col.label(text="Coordinates:")
791             col = split.column()
792             col.prop(tex, "texture_coords", text="")
793
794             if tex.texture_coords == 'ORCO':
795                 """
796                 ob = context.object
797                 if ob and ob.type == 'MESH':
798                     split = layout.split(percentage=0.3)
799                     split.label(text="Mesh:")
800                     split.prop(ob.data, "texco_mesh", text="")
801                 """
802             elif tex.texture_coords == 'UV':
803                 split = layout.split(percentage=0.3)
804                 split.label(text="Layer:")
805                 ob = context.object
806                 if ob and ob.type == 'MESH':
807                     split.prop_search(tex, "uv_layer", ob.data, "uv_textures", text="")
808                 else:
809                     split.prop(tex, "uv_layer", text="")
810
811             elif tex.texture_coords == 'OBJECT':
812                 split = layout.split(percentage=0.3)
813                 split.label(text="Object:")
814                 split.prop(tex, "object", text="")
815
816         if isinstance(idblock, bpy.types.Brush):
817             if context.sculpt_object:
818                 layout.label(text="Brush Mapping:")
819                 layout.prop(tex, "map_mode", expand=True)
820
821                 row = layout.row()
822                 row.active = tex.map_mode in {'FIXED', 'TILED'}
823                 row.prop(tex, "angle")
824         else:
825             if isinstance(idblock, bpy.types.Material):
826                 split = layout.split(percentage=0.3)
827                 split.label(text="Projection:")
828                 split.prop(tex, "mapping", text="")
829
830                 split = layout.split()
831
832                 col = split.column()
833                 if tex.texture_coords in {'ORCO', 'UV'}:
834                     col.prop(tex, "use_from_dupli")
835                 elif tex.texture_coords == 'OBJECT':
836                     col.prop(tex, "use_from_original")
837                 else:
838                     col.label()
839
840                 col = split.column()
841                 row = col.row()
842                 row.prop(tex, "mapping_x", text="")
843                 row.prop(tex, "mapping_y", text="")
844                 row.prop(tex, "mapping_z", text="")
845
846         row = layout.row()
847         row.column().prop(tex, "offset")
848         row.column().prop(tex, "scale")
849
850
851 class TEXTURE_PT_influence(TextureSlotPanel, bpy.types.Panel):
852     bl_label = "Influence"
853     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
854
855     @classmethod
856     def poll(cls, context):
857         idblock = context_tex_datablock(context)
858         if isinstance(idblock, bpy.types.Brush):
859             return False
860
861         if not getattr(context, "texture_slot", None):
862             return False
863
864         engine = context.scene.render.engine
865         return (engine in cls.COMPAT_ENGINES)
866
867     def draw(self, context):
868
869         layout = self.layout
870
871         idblock = context_tex_datablock(context)
872
873         # textype = context.texture
874         tex = context.texture_slot
875
876         def factor_but(layout, toggle, factor, name):
877             row = layout.row(align=True)
878             row.prop(tex, toggle, text="")
879             sub = row.row()
880             sub.active = getattr(tex, toggle)
881             sub.prop(tex, factor, text=name, slider=True)
882             return sub  # XXX, temp. use_map_normal needs to override.
883
884         if isinstance(idblock, bpy.types.Material):
885             if idblock.type in {'SURFACE', 'WIRE'}:
886                 split = layout.split()
887
888                 col = split.column()
889                 col.label(text="Diffuse:")
890                 factor_but(col, "use_map_diffuse", "diffuse_factor", "Intensity")
891                 factor_but(col, "use_map_color_diffuse", "diffuse_color_factor", "Color")
892                 factor_but(col, "use_map_alpha", "alpha_factor", "Alpha")
893                 factor_but(col, "use_map_translucency", "translucency_factor", "Translucency")
894
895                 col.label(text="Specular:")
896                 factor_but(col, "use_map_specular", "specular_factor", "Intensity")
897                 factor_but(col, "use_map_color_spec", "specular_color_factor", "Color")
898                 factor_but(col, "use_map_hardness", "hardness_factor", "Hardness")
899
900                 col = split.column()
901                 col.label(text="Shading:")
902                 factor_but(col, "use_map_ambient", "ambient_factor", "Ambient")
903                 factor_but(col, "use_map_emit", "emit_factor", "Emit")
904                 factor_but(col, "use_map_mirror", "mirror_factor", "Mirror")
905                 factor_but(col, "use_map_raymir", "raymir_factor", "Ray Mirror")
906
907                 col.label(text="Geometry:")
908                 # XXX replace 'or' when displacement is fixed to not rely on normal influence value.
909                 sub_tmp = factor_but(col, "use_map_normal", "normal_factor", "Normal")
910                 sub_tmp.active = (tex.use_map_normal or tex.use_map_displacement)
911                 # END XXX
912
913                 factor_but(col, "use_map_warp", "warp_factor", "Warp")
914                 factor_but(col, "use_map_displacement", "displacement_factor", "Displace")
915
916                 #sub = col.column()
917                 #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
918                 #sub.prop(tex, "default_value", text="Amount", slider=True)
919             elif idblock.type == 'HALO':
920                 layout.label(text="Halo:")
921
922                 split = layout.split()
923
924                 col = split.column()
925                 factor_but(col, "use_map_color_diffuse", "diffuse_color_factor", "Color")
926                 factor_but(col, "use_map_alpha", "alpha_factor", "Alpha")
927
928                 col = split.column()
929                 factor_but(col, "use_map_raymir", "raymir_factor", "Size")
930                 factor_but(col, "use_map_hardness", "hardness_factor", "Hardness")
931                 factor_but(col, "use_map_translucency", "translucency_factor", "Add")
932             elif idblock.type == 'VOLUME':
933                 split = layout.split()
934
935                 col = split.column()
936                 factor_but(col, "use_map_density", "density_factor", "Density")
937                 factor_but(col, "use_map_emission", "emission_factor", "Emission")
938                 factor_but(col, "use_map_scatter", "scattering_factor", "Scattering")
939                 factor_but(col, "use_map_reflect", "reflection_factor", "Reflection")
940
941                 col = split.column()
942                 col.label(text=" ")
943                 factor_but(col, "use_map_color_emission", "emission_color_factor", "Emission Color")
944                 factor_but(col, "use_map_color_transmission", "transmission_color_factor", "Transmission Color")
945                 factor_but(col, "use_map_color_reflection", "reflection_color_factor", "Reflection Color")
946
947         elif isinstance(idblock, bpy.types.Lamp):
948             split = layout.split()
949
950             col = split.column()
951             factor_but(col, "use_map_color", "color_factor", "Color")
952
953             col = split.column()
954             factor_but(col, "use_map_shadow", "shadow_factor", "Shadow")
955
956         elif isinstance(idblock, bpy.types.World):
957             split = layout.split()
958
959             col = split.column()
960             factor_but(col, "use_map_blend", "blend_factor", "Blend")
961             factor_but(col, "use_map_horizon", "horizon_factor", "Horizon")
962
963             col = split.column()
964             factor_but(col, "use_map_zenith_up", "zenith_up_factor", "Zenith Up")
965             factor_but(col, "use_map_zenith_down", "zenith_down_factor", "Zenith Down")
966         elif isinstance(idblock, bpy.types.ParticleSettings):
967             split = layout.split()
968
969             col = split.column()
970             col.label(text="General:")
971             factor_but(col, "use_map_time", "time_factor", "Time")
972             factor_but(col, "use_map_life", "life_factor", "Lifetime")
973             factor_but(col, "use_map_density", "density_factor", "Density")
974             factor_but(col, "use_map_size", "size_factor", "Size")
975
976             col = split.column()
977             col.label(text="Physics:")
978             factor_but(col, "use_map_velocity", "velocity_factor", "Velocity")
979             factor_but(col, "use_map_damp", "damp_factor", "Damp")
980             factor_but(col, "use_map_gravity", "gravity_factor", "Gravity")
981             factor_but(col, "use_map_field", "field_factor", "Force Fields")
982
983             layout.label(text="Hair:")
984
985             split = layout.split()
986
987             col = split.column()
988             factor_but(col, "use_map_length", "length_factor", "Length")
989             factor_but(col, "use_map_clump", "clump_factor", "Clump")
990
991             col = split.column()
992             factor_but(col, "use_map_kink", "kink_factor", "Kink")
993             factor_but(col, "use_map_rough", "rough_factor", "Rough")
994
995         layout.separator()
996
997         if not isinstance(idblock, bpy.types.ParticleSettings):
998             split = layout.split()
999
1000             col = split.column()
1001             col.prop(tex, "blend_type", text="Blend")
1002             col.prop(tex, "use_rgb_to_intensity")
1003             # color is used on grayscale textures even when use_rgb_to_intensity is disabled.
1004             col.prop(tex, "color", text="")
1005
1006             col = split.column()
1007             col.prop(tex, "invert", text="Negative")
1008             col.prop(tex, "use_stencil")
1009
1010         if isinstance(idblock, bpy.types.Material) or isinstance(idblock, bpy.types.World):
1011             col.prop(tex, "default_value", text="DVar", slider=True)
1012
1013         if isinstance(idblock, bpy.types.Material):
1014             layout.label(text="Bump Mapping:")
1015
1016             # only show bump settings if activated but not for normalmap images
1017             row = layout.row()
1018             row.active = (tex.use_map_normal or tex.use_map_warp) and not (tex.texture.type == 'IMAGE' and tex.texture.use_normal_map)
1019
1020             row.prop(tex, "bump_method", text="Method")
1021
1022             sub = row.row()
1023             sub.active = tex.bump_method in {'BUMP_DEFAULT', 'BUMP_BEST_QUALITY'}
1024             sub.prop(tex, "bump_objectspace", text="Space")
1025
1026
1027 class TEXTURE_PT_custom_props(TextureButtonsPanel, PropertyPanel, bpy.types.Panel):
1028     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
1029     _context_path = "texture"
1030     _property_type = bpy.types.Texture