32c572d849b03ad63c58a0784242e75c7dd6de9d
[blender.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     return idblock
64
65
66 class TextureButtonsPanel():
67     bl_space_type = 'PROPERTIES'
68     bl_region_type = 'WINDOW'
69     bl_context = "texture"
70
71
72 class TEXTURE_PT_preview(TextureButtonsPanel, bpy.types.Panel):
73     bl_label = "Preview"
74     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
75
76     @staticmethod
77     def poll(context):
78         tex = context.texture
79         return tex and (tex.type != 'NONE' or tex.use_nodes) and (context.scene.render.engine in __class__.COMPAT_ENGINES)
80
81     def draw(self, context):
82         layout = self.layout
83
84         tex = context.texture
85         slot = getattr(context, "texture_slot", None)
86         idblock = context_tex_datablock(context)
87
88         if idblock:
89             layout.template_preview(tex, parent=idblock, slot=slot)
90         else:
91             layout.template_preview(tex, slot=slot)
92
93
94 class TEXTURE_PT_context_texture(TextureButtonsPanel, bpy.types.Panel):
95     bl_label = ""
96     bl_show_header = False
97     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
98
99     @staticmethod
100     def poll(context):
101         engine = context.scene.render.engine
102         if not hasattr(context, "texture_slot"):
103             return False
104         return ((context.material or context.world or context.lamp or context.brush or context.texture)
105             and (engine in __class__.COMPAT_ENGINES))
106
107     def draw(self, context):
108         layout = self.layout
109         slot = context.texture_slot
110         node = context.texture_node
111         space = context.space_data
112         tex = context.texture
113         idblock = context_tex_datablock(context)
114         tex_collection = space.pin_id == None and type(idblock) != bpy.types.Brush and not node
115
116         if tex_collection:
117             row = layout.row()
118
119             row.template_list(idblock, "texture_slots", idblock, "active_texture_index", rows=2)
120
121             col = row.column(align=True)
122             col.operator("texture.slot_move", text="", icon='TRIA_UP').type = 'UP'
123             col.operator("texture.slot_move", text="", icon='TRIA_DOWN').type = 'DOWN'
124             col.menu("TEXTURE_MT_specials", icon='DOWNARROW_HLT', text="")
125
126         split = layout.split(percentage=0.65)
127         col = split.column()
128
129         if tex_collection:
130             col.template_ID(idblock, "active_texture", new="texture.new")
131         elif node:
132             col.template_ID(node, "texture", new="texture.new")
133         elif idblock:
134             col.template_ID(idblock, "texture", new="texture.new")
135
136         if space.pin_id:
137             col.template_ID(space, "pin_id")
138
139         col = split.column()
140
141         if not space.pin_id:
142             col.prop(space, "brush_texture", text="Brush", toggle=True)
143
144         if tex:
145             split = layout.split(percentage=0.2)
146
147             if tex.use_nodes:
148
149                 if slot:
150                     split.label(text="Output:")
151                     split.prop(slot, "output_node", text="")
152
153             else:
154                 split.label(text="Type:")
155                 split.prop(tex, "type", text="")
156
157
158 class TEXTURE_PT_custom_props(TextureButtonsPanel, PropertyPanel, bpy.types.Panel):
159     _context_path = "texture"
160     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
161
162     @staticmethod
163     def poll(context): # use alternate poll since NONE texture type is ok
164         engine = context.scene.render.engine
165         return context.texture and (engine in __class__.COMPAT_ENGINES)
166
167
168 class TEXTURE_PT_colors(TextureButtonsPanel, bpy.types.Panel):
169     bl_label = "Colors"
170     bl_default_closed = True
171     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
172
173     @staticmethod
174     def poll(context):
175         tex = context.texture
176         return tex and (tex.type != 'NONE' or tex.use_nodes) and (context.scene.render.engine in __class__.COMPAT_ENGINES)
177
178     def draw(self, context):
179         layout = self.layout
180
181         tex = context.texture
182
183         layout.prop(tex, "use_color_ramp", text="Ramp")
184         if tex.use_color_ramp:
185             layout.template_color_ramp(tex, "color_ramp", expand=True)
186
187         split = layout.split()
188
189         col = split.column()
190         col.label(text="RGB Multiply:")
191         sub = col.column(align=True)
192         sub.prop(tex, "factor_red", text="R")
193         sub.prop(tex, "factor_green", text="G")
194         sub.prop(tex, "factor_blue", text="B")
195
196         col = split.column()
197         col.label(text="Adjust:")
198         col.prop(tex, "brightness")
199         col.prop(tex, "contrast")
200         col.prop(tex, "saturation")
201
202 # Texture Slot Panels #
203
204
205 class TextureSlotPanel(TextureButtonsPanel):
206     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
207
208     @staticmethod
209     def poll(context):
210         if not hasattr(context, "texture_slot"):
211             return False
212
213         engine = context.scene.render.engine
214         return TextureButtonsPanel.poll(self, context) and (engine in __class__.COMPAT_ENGINES)
215
216
217 class TEXTURE_PT_mapping(TextureSlotPanel, bpy.types.Panel):
218     bl_label = "Mapping"
219     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
220
221     @staticmethod
222     def poll(context):
223         idblock = context_tex_datablock(context)
224         if type(idblock) == bpy.types.Brush and not context.sculpt_object:
225             return False
226
227         if not getattr(context, "texture_slot", None):
228             return False
229
230         engine = context.scene.render.engine
231         return (engine in __class__.COMPAT_ENGINES)
232
233     def draw(self, context):
234         layout = self.layout
235
236         idblock = context_tex_datablock(context)
237
238         tex = context.texture_slot
239         # textype = context.texture
240
241         if type(idblock) != bpy.types.Brush:
242             split = layout.split(percentage=0.3)
243             col = split.column()
244             col.label(text="Coordinates:")
245             col = split.column()
246             col.prop(tex, "texture_coordinates", text="")
247
248             if tex.texture_coordinates == 'ORCO':
249                 """
250                 ob = context.object
251                 if ob and ob.type == 'MESH':
252                     split = layout.split(percentage=0.3)
253                     split.label(text="Mesh:")
254                     split.prop(ob.data, "texco_mesh", text="")
255                 """
256             elif tex.texture_coordinates == 'UV':
257                 split = layout.split(percentage=0.3)
258                 split.label(text="Layer:")
259                 ob = context.object
260                 if ob and ob.type == 'MESH':
261                     split.prop_object(tex, "uv_layer", ob.data, "uv_textures", text="")
262                 else:
263                     split.prop(tex, "uv_layer", text="")
264
265             elif tex.texture_coordinates == 'OBJECT':
266                 split = layout.split(percentage=0.3)
267                 split.label(text="Object:")
268                 split.prop(tex, "object", text="")
269
270         if type(idblock) == bpy.types.Brush:
271             if context.sculpt_object:
272                 layout.label(text="Brush Mapping:")
273                 layout.prop(tex, "map_mode", expand=True)
274
275                 row = layout.row()
276                 row.active = tex.map_mode in ('FIXED', 'TILED')
277                 row.prop(tex, "angle")
278         else:
279             if type(idblock) == bpy.types.Material:
280                 split = layout.split(percentage=0.3)
281                 split.label(text="Projection:")
282                 split.prop(tex, "mapping", text="")
283
284                 split = layout.split()
285
286                 col = split.column()
287                 if tex.texture_coordinates in ('ORCO', 'UV'):
288                     col.prop(tex, "from_dupli")
289                 elif tex.texture_coordinates == 'OBJECT':
290                     col.prop(tex, "from_original")
291                 else:
292                     col.label()
293
294                 col = split.column()
295                 row = col.row()
296                 row.prop(tex, "x_mapping", text="")
297                 row.prop(tex, "y_mapping", text="")
298                 row.prop(tex, "z_mapping", text="")
299
300         split = layout.split()
301
302         col = split.column()
303         col.prop(tex, "offset")
304
305         col = split.column()
306
307         col.prop(tex, "size")
308
309
310 class TEXTURE_PT_influence(TextureSlotPanel, bpy.types.Panel):
311     bl_label = "Influence"
312     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
313
314     @staticmethod
315     def poll(context):
316         idblock = context_tex_datablock(context)
317         if type(idblock) == bpy.types.Brush:
318             return False
319
320         if not getattr(context, "texture_slot", None):
321             return False
322
323         engine = context.scene.render.engine
324         return (engine in __class__.COMPAT_ENGINES)
325
326     def draw(self, context):
327
328         layout = self.layout
329
330         idblock = context_tex_datablock(context)
331
332         # textype = context.texture
333         tex = context.texture_slot
334
335         def factor_but(layout, active, toggle, factor, name):
336             row = layout.row(align=True)
337             row.prop(tex, toggle, text="")
338             sub = row.row()
339             sub.active = active
340             sub.prop(tex, factor, text=name, slider=True)
341
342         if type(idblock) == bpy.types.Material:
343             if idblock.type in ('SURFACE', 'HALO', 'WIRE'):
344                 split = layout.split()
345
346                 col = split.column()
347                 col.label(text="Diffuse:")
348                 factor_but(col, tex.map_diffuse, "map_diffuse", "diffuse_factor", "Intensity")
349                 factor_but(col, tex.map_colordiff, "map_colordiff", "colordiff_factor", "Color")
350                 factor_but(col, tex.map_alpha, "map_alpha", "alpha_factor", "Alpha")
351                 factor_but(col, tex.map_translucency, "map_translucency", "translucency_factor", "Translucency")
352
353                 col.label(text="Specular:")
354                 factor_but(col, tex.map_specular, "map_specular", "specular_factor", "Intensity")
355                 factor_but(col, tex.map_colorspec, "map_colorspec", "colorspec_factor", "Color")
356                 factor_but(col, tex.map_hardness, "map_hardness", "hardness_factor", "Hardness")
357
358                 col = split.column()
359                 col.label(text="Shading:")
360                 factor_but(col, tex.map_ambient, "map_ambient", "ambient_factor", "Ambient")
361                 factor_but(col, tex.map_emit, "map_emit", "emit_factor", "Emit")
362                 factor_but(col, tex.map_mirror, "map_mirror", "mirror_factor", "Mirror")
363                 factor_but(col, tex.map_raymir, "map_raymir", "raymir_factor", "Ray Mirror")
364
365                 col.label(text="Geometry:")
366                 # XXX replace 'or' when displacement is fixed to not rely on normal influence value.
367                 factor_but(col, (tex.map_normal or tex.map_displacement), "map_normal", "normal_factor", "Normal")
368                 factor_but(col, tex.map_warp, "map_warp", "warp_factor", "Warp")
369                 factor_but(col, tex.map_displacement, "map_displacement", "displacement_factor", "Displace")
370
371                 #sub = col.column()
372                 #sub.active = tex.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
373                 #sub.prop(tex, "default_value", text="Amount", slider=True)
374             elif idblock.type == 'VOLUME':
375                 split = layout.split()
376
377                 col = split.column()
378                 factor_but(col, tex.map_density, "map_density", "density_factor", "Density")
379                 factor_but(col, tex.map_emission, "map_emission", "emission_factor", "Emission")
380                 factor_but(col, tex.map_scattering, "map_scattering", "scattering_factor", "Scattering")
381                 factor_but(col, tex.map_reflection, "map_reflection", "reflection_factor", "Reflection")
382
383                 col = split.column()
384                 col.label(text=" ")
385                 factor_but(col, tex.map_coloremission, "map_coloremission", "coloremission_factor", "Emission Color")
386                 factor_but(col, tex.map_colortransmission, "map_colortransmission", "colortransmission_factor", "Transmission Color")
387                 factor_but(col, tex.map_colorreflection, "map_colorreflection", "colorreflection_factor", "Reflection Color")
388
389         elif type(idblock) == bpy.types.Lamp:
390             split = layout.split()
391
392             col = split.column()
393             factor_but(col, tex.map_color, "map_color", "color_factor", "Color")
394
395             col = split.column()
396             factor_but(col, tex.map_shadow, "map_shadow", "shadow_factor", "Shadow")
397
398         elif type(idblock) == bpy.types.World:
399             split = layout.split()
400
401             col = split.column()
402             factor_but(col, tex.map_blend, "map_blend", "blend_factor", "Blend")
403             factor_but(col, tex.map_horizon, "map_horizon", "horizon_factor", "Horizon")
404
405             col = split.column()
406             factor_but(col, tex.map_zenith_up, "map_zenith_up", "zenith_up_factor", "Zenith Up")
407             factor_but(col, tex.map_zenith_down, "map_zenith_down", "zenith_down_factor", "Zenith Down")
408
409         layout.separator()
410
411         split = layout.split()
412
413         col = split.column()
414         col.prop(tex, "blend_type", text="Blend")
415         col.prop(tex, "rgb_to_intensity")
416         sub = col.column()
417         sub.active = tex.rgb_to_intensity
418         sub.prop(tex, "color", text="")
419
420         col = split.column()
421         col.prop(tex, "negate", text="Negative")
422         col.prop(tex, "stencil")
423
424         if type(idblock) in (bpy.types.Material, bpy.types.World):
425             col.prop(tex, "default_value", text="DVar", slider=True)
426
427 # Texture Type Panels #
428
429
430 class TextureTypePanel(TextureButtonsPanel):
431     pass
432
433
434 class TEXTURE_PT_clouds(TextureTypePanel, bpy.types.Panel):
435     bl_label = "Clouds"
436     tex_type = 'CLOUDS'
437     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
438
439     @staticmethod
440     def poll(context):
441         tex = context.texture
442         engine = context.scene.render.engine
443         return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
444
445     def draw(self, context):
446         layout = self.layout
447
448         tex = context.texture
449
450         layout.prop(tex, "stype", expand=True)
451         layout.label(text="Noise:")
452         layout.prop(tex, "noise_type", text="Type", expand=True)
453         layout.prop(tex, "noise_basis", text="Basis")
454
455         split = layout.split()
456
457         col = split.column()
458         col.prop(tex, "noise_size", text="Size")
459         col.prop(tex, "noise_depth", text="Depth")
460
461         col = split.column()
462         col.prop(tex, "nabla", text="Nabla")
463
464
465 class TEXTURE_PT_wood(TextureTypePanel, bpy.types.Panel):
466     bl_label = "Wood"
467     tex_type = 'WOOD'
468     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
469
470     @staticmethod
471     def poll(context):
472         tex = context.texture
473         engine = context.scene.render.engine
474         return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
475
476     def draw(self, context):
477         layout = self.layout
478
479         tex = context.texture
480
481         layout.prop(tex, "noisebasis2", expand=True)
482         layout.prop(tex, "stype", expand=True)
483
484         col = layout.column()
485         col.active = tex.stype in ('RINGNOISE', 'BANDNOISE')
486         col.label(text="Noise:")
487         col.row().prop(tex, "noise_type", text="Type", expand=True)
488         layout.prop(tex, "noise_basis", text="Basis")
489
490         split = layout.split()
491         split.active = tex.stype in ('RINGNOISE', 'BANDNOISE')
492
493         col = split.column()
494         col.prop(tex, "noise_size", text="Size")
495         col.prop(tex, "turbulence")
496
497         col = split.column()
498         col.prop(tex, "nabla")
499
500
501 class TEXTURE_PT_marble(TextureTypePanel, bpy.types.Panel):
502     bl_label = "Marble"
503     tex_type = 'MARBLE'
504     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
505
506     @staticmethod
507     def poll(context):
508         tex = context.texture
509         engine = context.scene.render.engine
510         return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
511
512     def draw(self, context):
513         layout = self.layout
514
515         tex = context.texture
516
517         layout.prop(tex, "stype", expand=True)
518         layout.prop(tex, "noisebasis2", expand=True)
519         layout.label(text="Noise:")
520         layout.prop(tex, "noise_type", text="Type", expand=True)
521         layout.prop(tex, "noise_basis", text="Basis")
522
523         split = layout.split()
524
525         col = split.column()
526         col.prop(tex, "noise_size", text="Size")
527         col.prop(tex, "noise_depth", text="Depth")
528
529         col = split.column()
530         col.prop(tex, "turbulence")
531         col.prop(tex, "nabla")
532
533
534 class TEXTURE_PT_magic(TextureTypePanel, bpy.types.Panel):
535     bl_label = "Magic"
536     tex_type = 'MAGIC'
537     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
538
539     @staticmethod
540     def poll(context):
541         tex = context.texture
542         engine = context.scene.render.engine
543         return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
544
545     def draw(self, context):
546         layout = self.layout
547
548         tex = context.texture
549
550         split = layout.split()
551
552         col = split.column()
553         col.prop(tex, "noise_depth", text="Depth")
554
555         col = split.column()
556         col.prop(tex, "turbulence")
557
558
559 class TEXTURE_PT_blend(TextureTypePanel, bpy.types.Panel):
560     bl_label = "Blend"
561     tex_type = 'BLEND'
562     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
563
564     @staticmethod
565     def poll(context):
566         tex = context.texture
567         engine = context.scene.render.engine
568         return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
569
570     def draw(self, context):
571         layout = self.layout
572
573         tex = context.texture
574
575         layout.prop(tex, "progression")
576
577         sub = layout.row()
578
579         sub.active = (tex.progression in ('LINEAR', 'QUADRATIC', 'EASING', 'RADIAL'))
580         sub.prop(tex, "flip_axis", expand=True)
581
582
583 class TEXTURE_PT_stucci(TextureTypePanel, bpy.types.Panel):
584     bl_label = "Stucci"
585     tex_type = 'STUCCI'
586     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
587
588     @staticmethod
589     def poll(context):
590         tex = context.texture
591         engine = context.scene.render.engine
592         return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
593
594     def draw(self, context):
595         layout = self.layout
596
597         tex = context.texture
598
599         layout.prop(tex, "stype", expand=True)
600         layout.label(text="Noise:")
601         layout.prop(tex, "noise_type", text="Type", expand=True)
602         layout.prop(tex, "noise_basis", text="Basis")
603
604         split = layout.split()
605
606         col = split.column()
607         col.prop(tex, "noise_size", text="Size")
608
609         col = split.column()
610         col.prop(tex, "turbulence")
611
612
613 class TEXTURE_PT_image(TextureTypePanel, bpy.types.Panel):
614     bl_label = "Image"
615     tex_type = 'IMAGE'
616     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
617
618     @staticmethod
619     def poll(context):
620         tex = context.texture
621         engine = context.scene.render.engine
622         return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
623
624     def draw(self, context):
625         layout = self.layout
626
627         tex = context.texture
628
629         layout.template_image(tex, "image", tex.image_user)
630
631
632 def texture_filter_common(tex, layout):
633     layout.label(text="Filter:")
634     layout.prop(tex, "filter", text="")
635     if tex.mipmap and tex.filter in ('AREA', 'EWA', 'FELINE'):
636         if tex.filter == 'FELINE':
637             layout.prop(tex, "filter_probes", text="Probes")
638         else:
639             layout.prop(tex, "filter_eccentricity", text="Eccentricity")
640
641     layout.prop(tex, "filter_size")
642     layout.prop(tex, "filter_size_minimum")
643
644
645 class TEXTURE_PT_image_sampling(TextureTypePanel, bpy.types.Panel):
646     bl_label = "Image Sampling"
647     bl_default_closed = True
648     tex_type = 'IMAGE'
649     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
650
651     @staticmethod
652     def poll(context):
653         tex = context.texture
654         engine = context.scene.render.engine
655         return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
656
657     def draw(self, context):
658         layout = self.layout
659
660         tex = context.texture
661         # slot = context.texture_slot
662
663         split = layout.split()
664
665         col = split.column()
666         col.label(text="Alpha:")
667         col.prop(tex, "use_alpha", text="Use")
668         col.prop(tex, "calculate_alpha", text="Calculate")
669         col.prop(tex, "invert_alpha", text="Invert")
670         col.separator()
671         col.prop(tex, "flip_axis", text="Flip X/Y Axis")
672
673         col = split.column()
674
675         col.prop(tex, "normal_map")
676         row = col.row()
677         row.active = tex.normal_map
678         row.prop(tex, "normal_space", text="")
679
680         col.prop(tex, "mipmap")
681         row = col.row()
682         row.active = tex.mipmap
683         row.prop(tex, "mipmap_gauss")
684         col.prop(tex, "interpolation")
685
686         texture_filter_common(tex, col)
687
688
689 class TEXTURE_PT_image_mapping(TextureTypePanel, bpy.types.Panel):
690     bl_label = "Image Mapping"
691     bl_default_closed = True
692     tex_type = 'IMAGE'
693     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
694
695     @staticmethod
696     def poll(context):
697         tex = context.texture
698         engine = context.scene.render.engine
699         return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
700
701     def draw(self, context):
702         layout = self.layout
703
704         tex = context.texture
705
706         layout.prop(tex, "extension")
707
708         split = layout.split()
709
710         if tex.extension == 'REPEAT':
711             col = split.column(align=True)
712             col.label(text="Repeat:")
713             col.prop(tex, "repeat_x", text="X")
714             col.prop(tex, "repeat_y", text="Y")
715
716             col = split.column(align=True)
717             col.label(text="Mirror:")
718             col.prop(tex, "mirror_x", text="X")
719             col.prop(tex, "mirror_y", text="Y")
720             layout.separator()
721
722         elif tex.extension == 'CHECKER':
723             col = split.column(align=True)
724             row = col.row()
725             row.prop(tex, "checker_even", text="Even")
726             row.prop(tex, "checker_odd", text="Odd")
727
728             col = split.column()
729             col.prop(tex, "checker_distance", text="Distance")
730
731             layout.separator()
732
733         split = layout.split()
734
735         col = split.column(align=True)
736         #col.prop(tex, "crop_rectangle")
737         col.label(text="Crop Minimum:")
738         col.prop(tex, "crop_min_x", text="X")
739         col.prop(tex, "crop_min_y", text="Y")
740
741         col = split.column(align=True)
742         col.label(text="Crop Maximum:")
743         col.prop(tex, "crop_max_x", text="X")
744         col.prop(tex, "crop_max_y", text="Y")
745
746
747 class TEXTURE_PT_plugin(TextureTypePanel, bpy.types.Panel):
748     bl_label = "Plugin"
749     tex_type = 'PLUGIN'
750     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
751
752     @staticmethod
753     def poll(context):
754         tex = context.texture
755         engine = context.scene.render.engine
756         return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
757
758     def draw(self, context):
759         layout = self.layout
760
761         # tex = context.texture
762
763         layout.label(text="Nothing yet")
764
765
766 class TEXTURE_PT_envmap(TextureTypePanel, bpy.types.Panel):
767     bl_label = "Environment Map"
768     tex_type = 'ENVIRONMENT_MAP'
769     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
770
771     @staticmethod
772     def poll(context):
773         tex = context.texture
774         engine = context.scene.render.engine
775         return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
776
777     def draw(self, context):
778         layout = self.layout
779
780         tex = context.texture
781         env = tex.environment_map
782
783
784         row = layout.row()
785         row.prop(env, "source", expand=True)
786         row.menu("TEXTURE_MT_envmap_specials", icon='DOWNARROW_HLT', text="")
787
788         if env.source == 'IMAGE_FILE':
789             layout.template_ID(tex, "image", open="image.open")
790             layout.template_image(tex, "image", tex.image_user, compact=True)
791         else:
792             layout.prop(env, "mapping")
793             if env.mapping == 'PLANE':
794                 layout.prop(env, "zoom")
795             layout.prop(env, "viewpoint_object")
796
797             split = layout.split()
798
799             col = split.column()
800             col.prop(env, "ignore_layers")
801             col.prop(env, "resolution")
802             col.prop(env, "depth")
803
804             col = split.column(align=True)
805
806             col.label(text="Clipping:")
807             col.prop(env, "clip_start", text="Start")
808             col.prop(env, "clip_end", text="End")
809
810
811 class TEXTURE_PT_envmap_sampling(TextureTypePanel, bpy.types.Panel):
812     bl_label = "Environment Map Sampling"
813     bl_default_closed = True
814     tex_type = 'ENVIRONMENT_MAP'
815     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
816
817     @staticmethod
818     def poll(context):
819         tex = context.texture
820         engine = context.scene.render.engine
821         return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
822
823     def draw(self, context):
824         layout = self.layout
825
826         tex = context.texture
827
828         texture_filter_common(tex, layout)
829
830
831 class TEXTURE_PT_musgrave(TextureTypePanel, bpy.types.Panel):
832     bl_label = "Musgrave"
833     tex_type = 'MUSGRAVE'
834     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
835
836     @staticmethod
837     def poll(context):
838         tex = context.texture
839         engine = context.scene.render.engine
840         return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
841
842     def draw(self, context):
843         layout = self.layout
844
845         tex = context.texture
846
847         layout.prop(tex, "musgrave_type")
848
849         split = layout.split()
850
851         col = split.column()
852         col.prop(tex, "highest_dimension", text="Dimension")
853         col.prop(tex, "lacunarity")
854         col.prop(tex, "octaves")
855
856         col = split.column()
857         if (tex.musgrave_type in ('HETERO_TERRAIN', 'RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL')):
858             col.prop(tex, "offset")
859         if (tex.musgrave_type in ('RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL')):
860             col.prop(tex, "gain")
861             col.prop(tex, "noise_intensity", text="Intensity")
862
863         layout.label(text="Noise:")
864
865         layout.prop(tex, "noise_basis", text="Basis")
866
867         split = layout.split()
868
869         col = split.column()
870         col.prop(tex, "noise_size", text="Size")
871
872         col = split.column()
873         col.prop(tex, "nabla")
874
875
876 class TEXTURE_PT_voronoi(TextureTypePanel, bpy.types.Panel):
877     bl_label = "Voronoi"
878     tex_type = 'VORONOI'
879     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
880
881     @staticmethod
882     def poll(context):
883         tex = context.texture
884         engine = context.scene.render.engine
885         return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
886
887     def draw(self, context):
888         layout = self.layout
889
890         tex = context.texture
891
892         split = layout.split()
893
894         col = split.column()
895         col.label(text="Distance Metric:")
896         col.prop(tex, "distance_metric", text="")
897         sub = col.column()
898         sub.active = tex.distance_metric == 'MINKOVSKY'
899         sub.prop(tex, "minkovsky_exponent", text="Exponent")
900         col.label(text="Coloring:")
901         col.prop(tex, "coloring", text="")
902         col.prop(tex, "noise_intensity", text="Intensity")
903
904         col = split.column()
905         sub = col.column(align=True)
906         sub.label(text="Feature Weights:")
907         sub.prop(tex, "weight_1", text="1", slider=True)
908         sub.prop(tex, "weight_2", text="2", slider=True)
909         sub.prop(tex, "weight_3", text="3", slider=True)
910         sub.prop(tex, "weight_4", text="4", slider=True)
911
912         layout.label(text="Noise:")
913
914         split = layout.split()
915
916         col = split.column()
917         col.prop(tex, "noise_size", text="Size")
918
919         col = split.column()
920         col.prop(tex, "nabla")
921
922
923 class TEXTURE_PT_distortednoise(TextureTypePanel, bpy.types.Panel):
924     bl_label = "Distorted Noise"
925     tex_type = 'DISTORTED_NOISE'
926     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
927
928     @staticmethod
929     def poll(context):
930         tex = context.texture
931         engine = context.scene.render.engine
932         return tex and ((tex.type == __class__.tex_type and not tex.use_nodes) and (engine in __class__.COMPAT_ENGINES))
933
934     def draw(self, context):
935         layout = self.layout
936
937         tex = context.texture
938
939         layout.prop(tex, "noise_distortion")
940         layout.prop(tex, "noise_basis", text="Basis")
941
942         split = layout.split()
943
944         col = split.column()
945         col.prop(tex, "distortion", text="Distortion")
946         col.prop(tex, "noise_size", text="Size")
947
948         col = split.column()
949         col.prop(tex, "nabla")
950
951
952 class TEXTURE_PT_voxeldata(TextureButtonsPanel, bpy.types.Panel):
953     bl_label = "Voxel Data"
954     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
955
956     @staticmethod
957     def poll(context):
958         tex = context.texture
959         engine = context.scene.render.engine
960         return tex and (tex.type == 'VOXEL_DATA' and (engine in __class__.COMPAT_ENGINES))
961
962     def draw(self, context):
963         layout = self.layout
964
965         tex = context.texture
966         vd = tex.voxeldata
967
968         layout.prop(vd, "file_format")
969         if vd.file_format in ['BLENDER_VOXEL', 'RAW_8BIT']:
970             layout.prop(vd, "source_path")
971         if vd.file_format == 'RAW_8BIT':
972             layout.prop(vd, "resolution")
973         elif vd.file_format == 'SMOKE':
974             layout.prop(vd, "domain_object")
975             layout.prop(vd, "smoke_data_type")
976         elif vd.file_format == 'IMAGE_SEQUENCE':
977             layout.template_ID(tex, "image", open="image.open")
978             layout.template_image(tex, "image", tex.image_user, compact=True)
979             #layout.prop(vd, "frames")
980
981         layout.prop(vd, "still")
982         row = layout.row()
983         row.active = vd.still
984         row.prop(vd, "still_frame_number")
985
986         layout.prop(vd, "interpolation")
987         layout.prop(vd, "extension")
988         layout.prop(vd, "intensity")
989
990
991 class TEXTURE_PT_pointdensity(TextureButtonsPanel, bpy.types.Panel):
992     bl_label = "Point Density"
993     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
994
995     @staticmethod
996     def poll(context):
997         tex = context.texture
998         engine = context.scene.render.engine
999         return tex and (tex.type == 'POINT_DENSITY' and (engine in __class__.COMPAT_ENGINES))
1000
1001     def draw(self, context):
1002         layout = self.layout
1003
1004         tex = context.texture
1005         pd = tex.pointdensity
1006
1007         layout.prop(pd, "point_source", expand=True)
1008
1009         split = layout.split()
1010
1011         col = split.column()
1012         if pd.point_source == 'PARTICLE_SYSTEM':
1013             col.label(text="Object:")
1014             col.prop(pd, "object", text="")
1015
1016             sub = col.column()
1017             sub.enabled = bool(pd.object)
1018             if pd.object:
1019                 sub.label(text="System:")
1020                 sub.prop_object(pd, "particle_system", pd.object, "particle_systems", text="")
1021             sub.label(text="Cache:")
1022             sub.prop(pd, "particle_cache", text="")
1023         else:
1024             col.label(text="Object:")
1025             col.prop(pd, "object", text="")
1026             col.label(text="Cache:")
1027             col.prop(pd, "vertices_cache", text="")
1028
1029         col.separator()
1030
1031         col.label(text="Color Source:")
1032         col.prop(pd, "color_source", text="")
1033         if pd.color_source in ('PARTICLE_SPEED', 'PARTICLE_VELOCITY'):
1034             col.prop(pd, "speed_scale")
1035         if pd.color_source in ('PARTICLE_SPEED', 'PARTICLE_AGE'):
1036             layout.template_color_ramp(pd, "color_ramp", expand=True)
1037
1038         col = split.column()
1039         col.label()
1040         col.prop(pd, "radius")
1041         col.label(text="Falloff:")
1042         col.prop(pd, "falloff", text="")
1043         if pd.falloff == 'SOFT':
1044             col.prop(pd, "falloff_softness")
1045
1046
1047 class TEXTURE_PT_pointdensity_turbulence(TextureButtonsPanel, bpy.types.Panel):
1048     bl_label = "Turbulence"
1049     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
1050
1051     @staticmethod
1052     def poll(context):
1053         tex = context.texture
1054         engine = context.scene.render.engine
1055         return tex and (tex.type == 'POINT_DENSITY' and (engine in __class__.COMPAT_ENGINES))
1056
1057     def draw_header(self, context):
1058         layout = self.layout
1059
1060         tex = context.texture
1061         pd = tex.pointdensity
1062
1063         layout.prop(pd, "turbulence", text="")
1064
1065     def draw(self, context):
1066         layout = self.layout
1067
1068         tex = context.texture
1069         pd = tex.pointdensity
1070         layout.active = pd.turbulence
1071
1072         split = layout.split()
1073
1074         col = split.column()
1075         col.label(text="Influence:")
1076         col.prop(pd, "turbulence_influence", text="")
1077         col.label(text="Noise Basis:")
1078         col.prop(pd, "noise_basis", text="")
1079
1080         col = split.column()
1081         col.label()
1082         col.prop(pd, "turbulence_size")
1083         col.prop(pd, "turbulence_depth")
1084         col.prop(pd, "turbulence_strength")
1085
1086
1087 def register():
1088     pass
1089
1090
1091 def unregister():
1092     pass
1093
1094 if __name__ == "__main__":
1095     register()