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