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