Stamp info back only for float buffer. (next commit add unsigned char).
[blender.git] / release / ui / buttons_texture.py
1
2 import bpy
3
4 class TextureButtonsPanel(bpy.types.Panel):
5         __space_type__ = "PROPERTIES"
6         __region_type__ = "WINDOW"
7         __context__ = "texture"
8         
9         def poll(self, context):
10                 tex = context.texture
11                 return (tex and (tex.type != 'NONE' or tex.use_nodes))
12                 
13 class TEXTURE_PT_preview(TextureButtonsPanel):
14         __label__ = "Preview"
15
16         def draw(self, context):
17                 layout = self.layout
18                 
19                 tex = context.texture
20                 ma = context.material
21                 la = context.lamp
22                 wo = context.world
23                 br = context.brush
24                 
25                 if ma:
26                         layout.template_preview(tex, parent=ma)
27                 elif la:
28                         layout.template_preview(tex, parent=la)
29                 elif wo:
30                         layout.template_preview(tex, parent=wo)
31                 elif br:
32                         layout.template_preview(tex, parent=br)
33                 else:
34                         layout.template_preview(tex)
35                         
36 class TEXTURE_PT_context_texture(TextureButtonsPanel):
37         __show_header__ = False
38
39         def poll(self, context):
40                 return (context.material or context.world or context.lamp or context.brush or context.texture)
41
42         def draw(self, context):
43                 layout = self.layout
44
45                 tex = context.texture
46                 
47                 id = context.material
48                 if not id: id = context.lamp
49                 if not id: id = context.world
50                 if not id: id = context.brush
51                 
52                 space = context.space_data
53
54                 if id:
55                         row = layout.row()
56                         row.template_list(id, "textures", id, "active_texture_index", rows=2)
57                         
58                 split = layout.split(percentage=0.65)
59
60                 if id:
61                         split.template_ID(id, "active_texture", new="texture.new")
62                 elif tex:
63                         split.template_ID(space, "pin_id")
64
65                 if (not space.pin_id) and (
66                         context.sculpt_object or
67                         context.vertex_paint_object or
68                         context.weight_paint_object or
69                         context.texture_paint_object
70                 ):
71                         split.itemR(space, "brush_texture", text="Brush", toggle=True)
72
73                 if tex:
74                         layout.itemR(tex, "use_nodes")
75                         
76                         split = layout.split(percentage=0.2)
77                         
78                         if tex.use_nodes:
79                                 slot = context.texture_slot
80                                 split.itemL(text="Output:")
81                                 split.itemR(slot, "output_node", text="")
82
83                         else:
84                                 split.itemL(text="Type:")
85                                 split.itemR(tex, "type", text="")
86                         
87 class TEXTURE_PT_colors(TextureButtonsPanel):
88         __label__ = "Colors"
89         __default_closed__ = True
90
91         def draw(self, context):
92                 layout = self.layout
93                 
94                 tex = context.texture
95
96                 layout.itemR(tex, "use_color_ramp", text="Ramp")
97                 if tex.use_color_ramp:
98                         layout.template_color_ramp(tex.color_ramp, expand=True)
99
100                 split = layout.split()
101                 
102                 split.itemR(tex, "rgb_factor", text="Multiply RGB")
103
104                 col = split.column()
105                 col.itemL(text="Adjust:")
106                 col.itemR(tex, "brightness")
107                 col.itemR(tex, "contrast")
108                         
109 # Texture Slot Panels #
110                         
111 class TextureSlotPanel(TextureButtonsPanel):
112         def poll(self, context):
113                 return (
114                         context.texture_slot and 
115                         TextureButtonsPanel.poll(self, context)
116                 )
117                                 
118 class TEXTURE_PT_mapping(TextureSlotPanel):
119         __label__ = "Mapping"
120         
121         def draw(self, context):
122                 layout = self.layout
123                 
124                 ma = context.material
125                 la = context.lamp
126                 wo = context.world
127                 br = context.brush
128                 tex = context.texture_slot
129                 textype = context.texture
130
131                 if not br:
132                         split = layout.split(percentage=0.3)
133                         col = split.column()
134                         col.itemL(text="Coordinates:")
135                         col = split.column()
136                         col.itemR(tex, "texture_coordinates", text="")
137
138                         if tex.texture_coordinates == 'ORCO':
139                                 """
140                                 ob = context.object
141                                 if ob and ob.type == 'MESH':
142                                         split = layout.split(percentage=0.3)
143                                         split.itemL(text="Mesh:")
144                                         split.itemR(ob.data, "texco_mesh", text="")
145                                 """
146                         elif tex.texture_coordinates == 'UV':
147                                 split = layout.split(percentage=0.3)
148                                 split.itemL(text="Layer:")
149                                 split.itemR(tex, "uv_layer", text="")
150                         elif tex.texture_coordinates == 'OBJECT':
151                                 split = layout.split(percentage=0.3)
152                                 split.itemL(text="Object:")
153                                 split.itemR(tex, "object", text="")
154                         
155                 if ma:
156                         split = layout.split(percentage=0.3)
157                         split.itemL(text="Projection:")
158                         split.itemR(tex, "mapping", text="")
159
160                         split = layout.split()
161                         
162                         col = split.column()
163                         if tex.texture_coordinates in ('ORCO', 'UV'):
164                                 col.itemR(tex, "from_dupli")
165                         elif tex.texture_coordinates == 'OBJECT':
166                                 col.itemR(tex, "from_original")
167                         else:
168                                 col.itemL()
169                         
170                         col = split.column()
171                         row = col.row()
172                         row.itemR(tex, "x_mapping", text="")
173                         row.itemR(tex, "y_mapping", text="")
174                         row.itemR(tex, "z_mapping", text="")
175
176                 if br:
177                         layout.itemR(tex, "brush_map_mode", expand=True)
178                         
179                         row = layout.row()
180                         row.active = tex.brush_map_mode in ('FIXED', 'TILED')
181                         row.itemR(tex, "angle")
182
183                         row = layout.row()
184                         row.active = tex.brush_map_mode in ('TILED', '3D')
185                         row.column().itemR(tex, "size")
186                 else:
187                         row = layout.row()
188                         row.column().itemR(tex, "offset")
189                         row.column().itemR(tex, "size")
190
191 class TEXTURE_PT_influence(TextureSlotPanel):
192         __label__ = "Influence"
193         
194         def draw(self, context):
195                 layout = self.layout
196                 
197                 ma = context.material
198                 la = context.lamp
199                 wo = context.world
200                 br = context.brush
201                 textype = context.texture
202                 tex = context.texture_slot
203
204                 def factor_but(layout, active, toggle, factor, name):
205                         row = layout.row(align=True)
206                         row.itemR(tex, toggle, text="")
207                         sub = row.row()
208                         sub.active = active
209                         sub.itemR(tex, factor, text=name, slider=True)
210                 
211                 if ma:
212                         split = layout.split()
213                         
214                         col = split.column()
215                         col.itemL(text="Diffuse:")
216                         factor_but(col, tex.map_diffuse, "map_diffuse", "diffuse_factor", "Intensity")
217                         factor_but(col, tex.map_colordiff, "map_colordiff", "colordiff_factor", "Color")
218                         factor_but(col, tex.map_alpha, "map_alpha", "alpha_factor", "Alpha")
219                         factor_but(col, tex.map_translucency, "map_translucency", "translucency_factor", "Translucency")
220
221                         col.itemL(text="Specular:")
222                         factor_but(col, tex.map_specular, "map_specular", "specular_factor", "Intensity")
223                         factor_but(col, tex.map_colorspec, "map_colorspec", "colorspec_factor", "Color")
224                         factor_but(col, tex.map_hardness, "map_hardness", "hardness_factor", "Hardness")
225
226                         col = split.column()
227                         col.itemL(text="Shading:")
228                         factor_but(col, tex.map_ambient, "map_ambient", "ambient_factor", "Ambient")
229                         factor_but(col, tex.map_emit, "map_emit", "emit_factor", "Emit")
230                         factor_but(col, tex.map_mirror, "map_mirror", "mirror_factor", "Mirror")
231                         factor_but(col, tex.map_raymir, "map_raymir", "raymir_factor", "Ray Mirror")
232
233                         col.itemL(text="Geometry:")
234                         factor_but(col, tex.map_normal, "map_normal", "normal_factor", "Normal")
235                         factor_but(col, tex.map_warp, "map_warp", "warp_factor", "Warp")
236                         factor_but(col, tex.map_displacement, "map_displacement", "displacement_factor", "Displace")
237
238                         #sub = col.column()
239                         #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
240                         #sub.itemR(tex, "default_value", text="Amount", slider=True)
241                 elif la:
242                         row = layout.row()
243                         factor_but(row, tex.map_color, "map_color", "color_factor", "Color")
244                         factor_but(row, tex.map_shadow, "map_shadow", "shadow_factor", "Shadow")
245                 elif wo:
246                         split = layout.split()
247                         
248                         col = split.column()
249                         factor_but(col, tex.map_blend, "map_blend", "blend_factor", "Blend")
250                         factor_but(col, tex.map_horizon, "map_horizon", "horizon_factor", "Horizon")
251
252                         col = split.column()
253                         factor_but(col, tex.map_zenith_up, "map_zenith_up", "zenith_up_factor", "Zenith Up")
254                         factor_but(col, tex.map_zenith_down, "map_zenith_down", "zenith_down_factor", "Zenith Down")
255
256                 layout.itemS()
257                 
258                 split = layout.split()
259
260                 col = split.column()
261                 col.itemR(tex, "blend_type", text="Blend")
262                 col.itemR(tex, "rgb_to_intensity")
263                 sub = col.column()
264                 sub.active = tex.rgb_to_intensity
265                 sub.itemR(tex, "color", text="")
266
267                 col = split.column()
268                 col.itemR(tex, "negate", text="Negative")
269                 col.itemR(tex, "stencil")
270                 if ma or wo:
271                         col.itemR(tex, "default_value", text="DVar", slider=True)
272
273 # Texture Type Panels #
274
275 class TextureTypePanel(TextureButtonsPanel):
276         def poll(self, context):
277                 tex = context.texture
278                 return (tex and tex.type == self.tex_type and not tex.use_nodes)
279
280 class TEXTURE_PT_clouds(TextureTypePanel):
281         __label__ = "Clouds"
282         tex_type = 'CLOUDS'
283
284         def draw(self, context):
285                 layout = self.layout
286                 
287                 tex = context.texture
288                 
289                 layout.itemR(tex, "stype", expand=True)
290                 layout.itemL(text="Noise:")
291                 layout.itemR(tex, "noise_type", text="Type", expand=True)
292                 layout.itemR(tex, "noise_basis", text="Basis")
293                 
294                 flow = layout.column_flow()
295                 flow.itemR(tex, "noise_size", text="Size")
296                 flow.itemR(tex, "noise_depth", text="Depth")
297                 flow.itemR(tex, "nabla", text="Nabla")
298
299 class TEXTURE_PT_wood(TextureTypePanel):
300         __label__ = "Wood"
301         tex_type = 'WOOD'
302
303         def draw(self, context):
304                 layout = self.layout
305                 
306                 tex = context.texture
307                 
308                 layout.itemR(tex, "noisebasis2", expand=True)
309                 layout.itemR(tex, "stype", expand=True)
310                 
311                 col = layout.column()
312                 col.active = tex.stype in ('RINGNOISE', 'BANDNOISE')
313                 col.itemL(text="Noise:")
314                 col.row().itemR(tex, "noise_type", text="Type", expand=True)
315                 col.itemR(tex, "noise_basis", text="Basis")
316                 
317                 flow = layout.column_flow()
318                 flow.active = tex.stype in ('RINGNOISE', 'BANDNOISE')
319                 flow.itemR(tex, "noise_size", text="Size")
320                 flow.itemR(tex, "turbulence")
321                 flow.itemR(tex, "nabla")
322                 
323 class TEXTURE_PT_marble(TextureTypePanel):
324         __label__ = "Marble"
325         tex_type = 'MARBLE'
326         
327         def draw(self, context):
328                 layout = self.layout
329                 
330                 tex = context.texture
331                 
332                 layout.itemR(tex, "stype", expand=True)
333                 layout.itemR(tex, "noisebasis2", expand=True)
334                 layout.itemL(text="Noise:")
335                 layout.itemR(tex, "noise_type", text="Type", expand=True)
336                 layout.itemR(tex, "noise_basis", text="Basis")
337                 
338                 flow = layout.column_flow()     
339                 flow.itemR(tex, "noise_size", text="Size")
340                 flow.itemR(tex, "noise_depth", text="Depth")
341                 flow.itemR(tex, "turbulence")
342                 flow.itemR(tex, "nabla")
343
344 class TEXTURE_PT_magic(TextureTypePanel):
345         __label__ = "Magic"
346         tex_type = 'MAGIC'
347         
348         def draw(self, context):
349                 layout = self.layout
350                 
351                 tex = context.texture
352                         
353                 row = layout.row()
354                 row.itemR(tex, "noise_depth", text="Depth")
355                 row.itemR(tex, "turbulence")
356
357 class TEXTURE_PT_blend(TextureTypePanel):
358         __label__ = "Blend"
359         tex_type = 'BLEND'
360         
361         def draw(self, context):
362                 layout = self.layout
363                 
364                 tex = context.texture
365
366                 layout.itemR(tex, "progression")
367                 layout.itemR(tex, "flip_axis")
368                         
369 class TEXTURE_PT_stucci(TextureTypePanel):
370         __label__ = "Stucci"
371         tex_type = 'STUCCI'
372         
373         def draw(self, context):
374                 layout = self.layout
375                 
376                 tex = context.texture
377                 
378                 layout.itemR(tex, "stype", expand=True)
379                 layout.itemL(text="Noise:")
380                 layout.itemR(tex, "noise_type", text="Type", expand=True)
381                 layout.itemR(tex, "noise_basis", text="Basis")
382                 
383                 row = layout.row()
384                 row.itemR(tex, "noise_size", text="Size")
385                 row.itemR(tex, "turbulence")
386                 
387 class TEXTURE_PT_image(TextureTypePanel):
388         __label__ = "Image"
389         tex_type = 'IMAGE'
390         
391         def draw(self, context):
392                 layout = self.layout
393                 
394                 tex = context.texture
395
396                 layout.template_texture_image(tex)
397
398 class TEXTURE_PT_image_sampling(TextureTypePanel):
399         __label__ = "Image Sampling"
400         __default_closed__ = True
401         tex_type = 'IMAGE'
402         
403         def draw(self, context):
404                 layout = self.layout
405                 
406                 tex = context.texture
407                 slot = context.texture_slot
408                 
409                 split = layout.split()
410                 
411                 """
412                 col = split.column()            
413                 col.itemR(tex, "flip_axis")
414                 col.itemR(tex, "normal_map")
415                 if slot:
416                         row = col.row()
417                         row.active = tex.normal_map
418                         row.itemR(slot, "normal_map_space", text="")
419                 """
420
421                 col = split.column()
422                 col.itemL(text="Alpha:")
423                 col.itemR(tex, "use_alpha", text="Use")
424                 col.itemR(tex, "calculate_alpha", text="Calculate")
425                 col.itemR(tex, "invert_alpha", text="Invert")
426
427                 col.itemL(text="Flip:")
428                 col.itemR(tex, "flip_axis", text="X/Y Axis")
429
430                 col = split.column() 
431                 col.itemL(text="Filter:")
432                 col.itemR(tex, "filter", text="")
433                 col.itemR(tex, "mipmap")
434                 
435                 row = col.row()
436                 row.active = tex.mipmap
437                 row.itemR(tex, "mipmap_gauss", text="Gauss")
438                 
439                 col.itemR(tex, "interpolation")
440                 if tex.mipmap and tex.filter != 'DEFAULT':
441                         if tex.filter == 'FELINE':
442                                 col.itemR(tex, "filter_probes", text="Probes")
443                         else:
444                                 col.itemR(tex, "filter_eccentricity", text="Eccentricity")
445
446 class TEXTURE_PT_image_mapping(TextureTypePanel):
447         __label__ = "Image Mapping"
448         __default_closed__ = True
449         tex_type = 'IMAGE'
450         
451         def draw(self, context):
452                 layout = self.layout
453                 
454                 tex = context.texture
455                 
456                 layout.itemR(tex, "extension")
457                 
458                 split = layout.split()
459                 
460                 if tex.extension == 'REPEAT': 
461                         col = split.column(align=True)
462                         col.itemL(text="Repeat:")
463                         col.itemR(tex, "repeat_x", text="X")
464                         col.itemR(tex, "repeat_y", text="Y")
465                         
466                         col = split.column(align=True)
467                         col.itemL(text="Mirror:")
468                         col.itemR(tex, "mirror_x", text="X")
469                         col.itemR(tex, "mirror_y", text="Y")
470                 elif tex.extension == 'CHECKER': 
471                         col = split.column(align=True)
472                         row = col.row()
473                         row.itemR(tex, "checker_even", text="Even")
474                         row.itemR(tex, "checker_odd", text="Odd")
475
476                         split.itemR(tex, "checker_distance", text="Distance")
477
478                 layout.itemS()
479
480                 split = layout.split()
481                 
482                 col = split.column(align=True)
483                 #col.itemR(tex, "crop_rectangle")
484                 col.itemL(text="Crop Minimum:")
485                 col.itemR(tex, "crop_min_x", text="X")
486                 col.itemR(tex, "crop_min_y", text="Y")
487                 
488                 col = split.column(align=True)
489                 col.itemL(text="Crop Maximum:")
490                 col.itemR(tex, "crop_max_x", text="X")
491                 col.itemR(tex, "crop_max_y", text="Y")
492         
493 class TEXTURE_PT_plugin(TextureTypePanel):
494         __label__ = "Plugin"
495         tex_type = 'PLUGIN'
496         
497         def draw(self, context):
498                 layout = self.layout
499                 
500                 tex = context.texture
501                 
502                 layout.itemL(text="Nothing yet")
503                 
504 class TEXTURE_PT_envmap(TextureTypePanel):
505         __label__ = "Environment Map"
506         tex_type = 'ENVIRONMENT_MAP'
507         
508         def draw(self, context):
509                 layout = self.layout
510                 
511                 tex = context.texture
512                 
513                 layout.itemL(text="Nothing yet")
514                 
515 class TEXTURE_PT_musgrave(TextureTypePanel):
516         __label__ = "Musgrave"
517         tex_type = 'MUSGRAVE'
518         
519         def draw(self, context):
520                 layout = self.layout
521                 
522                 tex = context.texture
523                 
524                 layout.itemR(tex, "musgrave_type")      
525                 
526                 split = layout.split()
527                 
528                 col = split.column()
529                 col.itemR(tex, "highest_dimension", text="Dimension")
530                 col.itemR(tex, "lacunarity")
531                 col.itemR(tex, "octaves")
532                 
533                 col = split.column() 
534                 if (tex.musgrave_type in ('HETERO_TERRAIN', 'RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL')):
535                         col.itemR(tex, "offset")
536                 if (tex.musgrave_type in ('RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL')):
537                         col.itemR(tex, "gain")
538                         col.itemR(tex, "noise_intensity", text="Intensity")
539                 
540                 layout.itemL(text="Noise:")
541                 
542                 layout.itemR(tex, "noise_basis", text="Basis")
543                 
544                 row = layout.row()
545                 row.itemR(tex, "noise_size", text="Size")
546                 row.itemR(tex, "nabla")
547
548 class TEXTURE_PT_voronoi(TextureTypePanel):
549         __label__ = "Voronoi"
550         tex_type = 'VORONOI'
551
552         def draw(self, context):
553                 layout = self.layout
554                 
555                 tex = context.texture
556                 
557                 split = layout.split()
558                 
559                 col = split.column()   
560                 col.itemL(text="Distance Metric:")
561                 col.itemR(tex, "distance_metric", text="")
562                 sub = col.column()
563                 sub.active = tex.distance_metric == 'MINKOVSKY'
564                 sub.itemR(tex, "minkovsky_exponent", text="Exponent")
565                 col.itemL(text="Coloring:")
566                 col.itemR(tex, "coloring", text="")
567                 col.itemR(tex, "noise_intensity", text="Intensity")
568                 
569                 col = split.column(align=True) 
570                 col.itemL(text="Feature Weights:")
571                 col.itemR(tex, "weight_1", text="1", slider=True)
572                 col.itemR(tex, "weight_2", text="2", slider=True)
573                 col.itemR(tex, "weight_3", text="3", slider=True)
574                 col.itemR(tex, "weight_4", text="4", slider=True)
575                 
576                 layout.itemL(text="Noise:")
577                 
578                 row = layout.row()
579                 row.itemR(tex, "noise_size", text="Size")
580                 row.itemR(tex, "nabla")
581                         
582 class TEXTURE_PT_distortednoise(TextureTypePanel):
583         __label__ = "Distorted Noise"
584         tex_type = 'DISTORTED_NOISE'
585         
586         def draw(self, context):
587                 layout = self.layout
588                 
589                 tex = context.texture
590
591                 layout.itemR(tex, "noise_distortion")
592                 layout.itemR(tex, "noise_basis", text="Basis")
593                 
594                 flow = layout.column_flow()
595                 flow.itemR(tex, "distortion_amount", text="Distortion")
596                 flow.itemR(tex, "noise_size", text="Size")
597                 flow.itemR(tex, "nabla")        
598
599 bpy.types.register(TEXTURE_PT_context_texture)
600 bpy.types.register(TEXTURE_PT_preview)
601 bpy.types.register(TEXTURE_PT_clouds)
602 bpy.types.register(TEXTURE_PT_wood)
603 bpy.types.register(TEXTURE_PT_marble)
604 bpy.types.register(TEXTURE_PT_magic)
605 bpy.types.register(TEXTURE_PT_blend)
606 bpy.types.register(TEXTURE_PT_stucci)
607 bpy.types.register(TEXTURE_PT_image)
608 bpy.types.register(TEXTURE_PT_image_sampling)
609 bpy.types.register(TEXTURE_PT_image_mapping)
610 bpy.types.register(TEXTURE_PT_plugin)
611 bpy.types.register(TEXTURE_PT_envmap)
612 bpy.types.register(TEXTURE_PT_musgrave)
613 bpy.types.register(TEXTURE_PT_voronoi)
614 bpy.types.register(TEXTURE_PT_distortednoise)
615 bpy.types.register(TEXTURE_PT_colors)
616 bpy.types.register(TEXTURE_PT_mapping)
617 bpy.types.register(TEXTURE_PT_influence)