Welcome to mirror list, hosted at ThFree Co, Russian Federation.

properties_texture.py « bl_ui « startup « scripts « release - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a4f6f753669f04dc84d674d1eb3ac99646470237 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
# ##### BEGIN GPL LICENSE BLOCK #####
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; either version 2
#  of the License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software Foundation,
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####

# <pep8 compliant>

import bpy
from bpy.types import (
    Menu,
    Panel,
    UIList,
)
from bpy.types import (
    Brush,
    FreestyleLineStyle,
    ParticleSettings,
    Texture,
)

from rna_prop_ui import PropertyPanel
from .properties_paint_common import brush_texture_settings


class TEXTURE_MT_specials(Menu):
    bl_label = "Texture Specials"
    COMPAT_ENGINES = {'BLENDER_RENDER'}

    def draw(self, context):
        layout = self.layout

        layout.operator("texture.slot_copy", icon='COPYDOWN')
        layout.operator("texture.slot_paste", icon='PASTEDOWN')


class TEXTURE_UL_texslots(UIList):

    def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
        slot = item
        tex = slot.texture if slot else None

        if self.layout_type in {'DEFAULT', 'COMPACT'}:
            if tex:
                layout.prop(tex, "name", text="", emboss=False, icon_value=icon)
            else:
                layout.label(text="", icon_value=icon)
        elif self.layout_type == 'GRID':
            layout.alignment = 'CENTER'
            layout.label(text="", icon_value=icon)


def context_tex_datablock(context):
    idblock = context.brush
    if idblock:
        return idblock

    idblock = context.line_style
    if idblock:
        return idblock

    if context.particle_system:
        idblock = context.particle_system.settings

    return idblock


class TextureButtonsPanel:
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "texture"


class TEXTURE_PT_preview(TextureButtonsPanel, Panel):
    bl_label = "Preview"
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}

    @classmethod
    def poll(cls, context):
        tex = context.texture
        return tex and (tex.type != 'NONE' or tex.use_nodes) and (context.engine in cls.COMPAT_ENGINES)

    def draw(self, context):
        layout = self.layout

        tex = context.texture
        slot = getattr(context, "texture_slot", None)
        idblock = context_tex_datablock(context)

        if idblock:
            layout.template_preview(tex, parent=idblock, slot=slot)
        else:
            layout.template_preview(tex, slot=slot)

        # Show Alpha Button for Brush Textures, see #29502
        idblock = context_tex_datablock(context)
        if isinstance(idblock, Brush):
            layout.prop(tex, "use_preview_alpha")


class TEXTURE_PT_context(TextureButtonsPanel, Panel):
    bl_label = ""
    bl_context = "texture"
    bl_options = {'HIDE_HEADER'}
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}

    def draw(self, context):
        layout = self.layout

        tex = context.texture
        space = context.space_data
        pin_id = space.pin_id
        use_pin_id = space.use_pin_id
        user = context.texture_user

        col = layout.column()

        if not (use_pin_id and isinstance(pin_id, bpy.types.Texture)):
            pin_id = None

        if not pin_id:
            col.template_texture_user()

        if user or pin_id:
            col.separator()

            if pin_id:
                col.template_ID(space, "pin_id")
            else:
                propname = context.texture_user_property.identifier
                col.template_ID(user, propname, new="texture.new")

            if tex:
                col.separator()

                split = col.split(percentage=0.2)
                split.label(text="Type")
                split.prop(tex, "type", text="")


class TEXTURE_PT_node(TextureButtonsPanel, Panel):
    bl_label = "Node"
    bl_context = "texture"
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}

    @classmethod
    def poll(cls, context):
        node = context.texture_node
        return node and (context.engine in cls.COMPAT_ENGINES)

    def draw(self, context):
        layout = self.layout

        node = context.texture_node
        ntree = node.id_data
        layout.template_node_view(ntree, node, None)


class TEXTURE_PT_node_mapping(TextureButtonsPanel, Panel):
    bl_label = "Mapping"
    bl_context = "texture"
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}

    @classmethod
    def poll(cls, context):
        node = context.texture_node
        # TODO(sergey): perform a faster/nicer check?
        return node and hasattr(node, 'texture_mapping') and (context.engine in cls.COMPAT_ENGINES)

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = False  # No animation.

        flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)

        node = context.texture_node

        mapping = node.texture_mapping

        col = flow.column()
        col.prop(mapping, "vector_type")

        col.separator()

        col = col.column(align=True)
        col.prop(mapping, "mapping_x", text="Projection X")
        col.prop(mapping, "mapping_y", text="Y")
        col.prop(mapping, "mapping_z", text="Z")

        col.separator()

        col = flow.column()
        col.column().prop(mapping, "translation")

        col = flow.column()
        col.column().prop(mapping, "rotation")

        col = flow.column()
        col.column().prop(mapping, "scale")


class TextureTypePanel(TextureButtonsPanel):

    @classmethod
    def poll(cls, context):
        tex = context.texture
        engine = context.engine
        return tex and ((tex.type == cls.tex_type and not tex.use_nodes) and (engine in cls.COMPAT_ENGINES))


class TEXTURE_PT_clouds(TextureTypePanel, Panel):
    bl_label = "Clouds"
    tex_type = 'CLOUDS'
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)

        tex = context.texture

        col = flow.column()
        col.prop(tex, "noise_basis", text="Noise Basis")

        col.separator()

        col.prop(tex, "noise_type", text="Type")

        col.separator()

        col = flow.column()
        col.prop(tex, "cloud_type")

        col.separator()

        col = flow.column()
        col.prop(tex, "noise_scale", text="Size")
        col.prop(tex, "noise_depth", text="Depth")
        col.prop(tex, "nabla", text="Nabla")


class TEXTURE_PT_wood(TextureTypePanel, Panel):
    bl_label = "Wood"
    tex_type = 'WOOD'
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        flow = layout.grid_flow(row_major=True, columns=0, even_columns=False, even_rows=False, align=False)

        tex = context.texture

        col = flow.column()
        col.prop(tex, "noise_basis", text="Noise Basis")

        col.separator()

        col.prop(tex, "wood_type")

        col.separator()

        col = flow.column()
        col.prop(tex, "noise_basis_2", text="Second Basis")

        col = col.column()
        col.active = tex.wood_type in {'RINGNOISE', 'BANDNOISE'}
        col.prop(tex, "noise_type", text="Type")

        col.separator()

        sub = flow.column()
        sub.active = tex.wood_type in {'RINGNOISE', 'BANDNOISE'}
        sub.prop(tex, "noise_scale", text="Size")
        sub.prop(tex, "turbulence")
        sub.prop(tex, "nabla")


class TEXTURE_PT_marble(TextureTypePanel, Panel):
    bl_label = "Marble"
    tex_type = 'MARBLE'
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)

        tex = context.texture

        col = flow.column()
        col.prop(tex, "noise_basis", text="Noise Basis")

        col.separator()

        col.prop(tex, "marble_type")

        col.separator()

        col = flow.column()
        col.prop(tex, "noise_basis_2", text="Second Basis")
        col.prop(tex, "noise_type", text="Type")

        col.separator()

        col = flow.column()
        col.prop(tex, "noise_scale", text="Size")
        col.prop(tex, "noise_depth", text="Depth")
        col.prop(tex, "turbulence")
        col.prop(tex, "nabla")


class TEXTURE_PT_magic(TextureTypePanel, Panel):
    bl_label = "Magic"
    tex_type = 'MAGIC'
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)

        tex = context.texture

        col = flow.column()
        col.prop(tex, "noise_depth", text="Depth")

        col = flow.column()
        col.prop(tex, "turbulence")


class TEXTURE_PT_blend(TextureTypePanel, Panel):
    bl_label = "Blend"
    tex_type = 'BLEND'
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)

        tex = context.texture

        col = flow.column()
        col.prop(tex, "progression")

        col.separator()

        col = flow.column()
        col.active = (tex.progression in {'LINEAR', 'QUADRATIC', 'EASING', 'RADIAL'})
        col.prop(tex, "use_flip_axis", text="Orientation")


class TEXTURE_PT_stucci(TextureTypePanel, Panel):
    bl_label = "Stucci"
    tex_type = 'STUCCI'
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)

        tex = context.texture

        col = flow.column()
        col.prop(tex, "noise_basis", text="Noise Basis")

        col.separator()

        col.row().prop(tex, "stucci_type")

        col.separator()

        col = flow.column()
        col.prop(tex, "noise_type", text="Type")

        col.separator()

        col = flow.column()
        col.prop(tex, "noise_scale", text="Size")
        col.prop(tex, "turbulence")


class TEXTURE_PT_image(TextureTypePanel, Panel):
    bl_label = "Image"
    tex_type = 'IMAGE'
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}

    def draw(self, context):
        # TODO: maybe expose the template_ID from the template image here.
        layout = self.layout
        del layout


class TEXTURE_PT_image_settings(TextureTypePanel, Panel):
    bl_label = "Settings"
    bl_parent_id = 'TEXTURE_PT_image'
    tex_type = 'IMAGE'
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}

    def draw(self, context):
        layout = self.layout

        tex = context.texture
        layout.template_image(tex, "image", tex.image_user)


def texture_filter_common(tex, layout):
    layout.prop(tex, "filter_type", text="Filter Type")

    if tex.use_mipmap and tex.filter_type in {'AREA', 'EWA', 'FELINE'}:
        col = layout.column()
        if tex.filter_type == 'FELINE':
            col.prop(tex, "filter_lightprobes", text="Light Probes")
        else:
            col.prop(tex, "filter_eccentricity", text="Eccentricity")

    layout.prop(tex, "filter_size", text="Size")
    layout.prop(tex, "use_filter_size_min", text="Minimum Size")


class TEXTURE_PT_image_sampling(TextureTypePanel, Panel):
    bl_label = "Sampling"
    bl_options = {'DEFAULT_CLOSED'}
    bl_parent_id = 'TEXTURE_PT_image'
    tex_type = 'IMAGE'
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)

        tex = context.texture

        col = flow.column()
        col.prop(tex, "use_interpolation")

        col.separator()

        col = flow.column()
        col.prop(tex, "use_mipmap")
        sub = col.column()
        sub.active = tex.use_mipmap
        sub.prop(tex, "use_mipmap_gauss", text="Gaussian Filter")

        col.separator()

        texture_filter_common(tex, flow)


class TEXTURE_PT_image_alpha(TextureTypePanel, Panel):
    bl_label = "Alpha"
    bl_options = {'DEFAULT_CLOSED'}
    bl_parent_id = 'TEXTURE_PT_image'
    tex_type = 'IMAGE'
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}

    def draw_header(self, context):
        tex = context.texture
        self.layout.prop(tex, "use_alpha", text="")

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True

        tex = context.texture

        col = layout.column()
        col.active = bool(tex.image and tex.image.use_alpha)
        col.prop(tex, "use_calculate_alpha", text="Calculate")
        col.prop(tex, "invert_alpha", text="Invert")


class TEXTURE_PT_image_mapping(TextureTypePanel, Panel):
    bl_label = "Mapping"
    bl_options = {'DEFAULT_CLOSED'}
    bl_parent_id = 'TEXTURE_PT_image'
    tex_type = 'IMAGE'
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True

        tex = context.texture

        col = layout.column()
        col.prop(tex, "use_flip_axis", text="Flip Axes")

        col.separator()

        subcol = layout.column()
        subcol.prop(tex, "extension")  # use layout, to keep the same location in case of button cycling.

        flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)

        if tex.extension == 'REPEAT':

            col = flow.column()
            sub = col.column(align=True)
            sub.prop(tex, "repeat_x", text="Repeat X")
            sub.prop(tex, "repeat_y", text="Y")

            col = flow.column()
            sub = col.column()
            sub.active = (tex.repeat_x > 1)
            sub.prop(tex, "use_mirror_x", text="Mirror X")

            sub = col.column()
            sub.active = (tex.repeat_y > 1)
            sub.prop(tex, "use_mirror_y", text="Y")

        elif tex.extension == 'CHECKER':
            subcol.separator()

            col = flow.column()
            col.prop(tex, "checker_distance", text="Distance")

            col = flow.column()
            col.prop(tex, "use_checker_even", text="Tiles Even")
            col.prop(tex, "use_checker_odd", text="Odd")
        else:
            del flow


class TEXTURE_PT_image_mapping_crop(TextureTypePanel, Panel):
    bl_label = "Crop"
    bl_options = {'DEFAULT_CLOSED'}
    bl_parent_id = 'TEXTURE_PT_image_mapping'
    tex_type = 'IMAGE'
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)

        tex = context.texture

        col = flow.column(align=True)
        # col.prop(tex, "crop_rectangle")
        col.prop(tex, "crop_min_x", text="Minimum X")
        col.prop(tex, "crop_min_y", text="Y")

        col = flow.column(align=True)
        col.prop(tex, "crop_max_x", text="Maximum X")
        col.prop(tex, "crop_max_y", text="Y")


class TEXTURE_PT_musgrave(TextureTypePanel, Panel):
    bl_label = "Musgrave"
    tex_type = 'MUSGRAVE'
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)

        tex = context.texture

        col = flow.column()
        col.prop(tex, "noise_basis", text="Noise Basis")

        col.separator()

        col.prop(tex, "musgrave_type")

        col.separator()

        col.prop(tex, "noise_scale", text="Size")
        col.prop(tex, "nabla")

        col.separator()

        col = flow.column()
        col.prop(tex, "dimension_max", text="Dimension")
        col.prop(tex, "lacunarity")
        col.prop(tex, "octaves")

        col.separator()

        musgrave_type = tex.musgrave_type

        col = flow.column()

        if musgrave_type in {'HETERO_TERRAIN', 'RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL'}:
            col.prop(tex, "offset")
        col.prop(tex, "noise_intensity", text="Intensity")

        if musgrave_type in {'RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL'}:
            col.prop(tex, "gain")


class TEXTURE_PT_voronoi(TextureTypePanel, Panel):
    bl_label = "Voronoi"
    tex_type = 'VORONOI'
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)

        tex = context.texture

        col = flow.column()
        col.prop(tex, "distance_metric")

        sub = col.column()
        sub.active = tex.distance_metric == 'MINKOVSKY'
        sub.prop(tex, "minkovsky_exponent", text="Exponent")

        sub.separator()

        col = flow.column()
        col.prop(tex, "color_mode")
        col.prop(tex, "noise_intensity", text="Intensity")

        col.separator()

        col = flow.column()
        col.prop(tex, "noise_scale", text="Size")
        col.prop(tex, "nabla")


class TEXTURE_PT_voronoi_feature_weights(TextureTypePanel, Panel):
    bl_label = "Feature Weights"
    bl_parent_id = "TEXTURE_PT_voronoi"
    tex_type = 'VORONOI'
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=True)

        tex = context.texture

        col = flow.column(align=True)
        col.prop(tex, "weight_1", text="First", slider=True)
        col.prop(tex, "weight_2", text="Second", slider=True)

        sub = flow.column(align=True)
        sub.prop(tex, "weight_3", text="Third", slider=True)
        sub.prop(tex, "weight_4", text="Fourth", slider=True)


class TEXTURE_PT_distortednoise(TextureTypePanel, Panel):
    bl_label = "Distorted Noise"
    tex_type = 'DISTORTED_NOISE'
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)

        tex = context.texture

        col = flow.column()
        col.prop(tex, "noise_basis", text="Noise Basis")

        col.separator()

        col.prop(tex, "noise_distortion", text="Distortion")

        col.separator()

        col = flow.column()
        col.prop(tex, "distortion", text="Amount")
        col.prop(tex, "noise_scale", text="Size")
        col.prop(tex, "nabla")


class TextureSlotPanel(TextureButtonsPanel):
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}

    @classmethod
    def poll(cls, context):
        if not hasattr(context, "texture_slot"):
            return False

        return (context.engine in cls.COMPAT_ENGINES)


class TEXTURE_PT_mapping(TextureSlotPanel, Panel):
    bl_label = "Mapping"
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}

    @classmethod
    def poll(cls, context):
        idblock = context_tex_datablock(context)
        if isinstance(idblock, Brush) and not context.sculpt_object:
            return False

        if not getattr(context, "texture_slot", None):
            return False

        engine = context.engine
        return (engine in cls.COMPAT_ENGINES)

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=True)

        idblock = context_tex_datablock(context)

        tex = context.texture_slot

        if isinstance(idblock, Brush):
            if context.sculpt_object or context.image_paint_object:
                brush_texture_settings(layout, idblock, context.sculpt_object)
        else:
            col = flow.column()

            col.prop(tex, "texture_coords", text="Coordinates")

            # Note: the ORCO case used to call ob.data, "texco_mesh" prop.
            if tex.texture_coords == 'UV':
                ob = context.object

                if ob and ob.type == 'MESH':
                    # Note: TODO prop_search doesn't align on the right.
                    row = col.row(align=True)
                    row.prop_search(tex, "uv_layer", ob.data, "uv_layers", text="Map")
                    row.label(text="", icon='BLANK1')
                else:
                    col.prop(tex, "uv_layer", text="Map")

            elif tex.texture_coords == 'OBJECT':
                col.prop(tex, "object", text="Object")

            elif tex.texture_coords == 'ALONG_STROKE':
                col.prop(tex, "use_tips", text="Use Tips")

            col.separator()

            if isinstance(idblock, FreestyleLineStyle):
                col = flow.column()
                col.prop(tex, "mapping", text="Projection")

                col.separator()

                col = flow.column()
                col.prop(tex, "mapping_x", text="Mapping X")
                col.prop(tex, "mapping_y", text="Y")
                col.prop(tex, "mapping_z", text="Z")

                col.separator()

            col = flow.column(align=True)
            col.column().prop(tex, "offset")

            col = flow.column(align=True)
            col.column().prop(tex, "scale")


class TEXTURE_PT_influence(TextureSlotPanel, Panel):
    bl_label = "Influence"
    bl_options = {'DEFAULT_CLOSED'}
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}

    @classmethod
    def poll(cls, context):
        idblock = context_tex_datablock(context)
        if isinstance(idblock, Brush):
            return False

        if not getattr(context, "texture_slot", None):
            return False

        engine = context.engine
        return (engine in cls.COMPAT_ENGINES)

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        flow = layout.grid_flow(row_major=False, columns=0, even_columns=False, even_rows=False, align=False)

        idblock = context_tex_datablock(context)
        tex = context.texture_slot

        def factor_but(layout, toggle, factor, name):
            row = layout.row(align=True)
            row.active = getattr(tex, toggle)

            row.prop(tex, factor, text=name, slider=True)
            sub = row.row(align=True)
            sub.prop(tex, toggle, text="")
            return sub  # XXX, temp. use_map_normal needs to override.

        if isinstance(idblock, ParticleSettings):
            col = flow.column()
            factor_but(col, "use_map_time", "time_factor", "General Time")
            factor_but(col, "use_map_life", "life_factor", "Lifetime")
            factor_but(col, "use_map_density", "density_factor", "Density")
            factor_but(col, "use_map_size", "size_factor", "Size")

            col.separator()

            col = flow.column()
            factor_but(col, "use_map_velocity", "velocity_factor", "Physics Velocity")
            factor_but(col, "use_map_damp", "damp_factor", "Damp")
            factor_but(col, "use_map_gravity", "gravity_factor", "Gravity")
            factor_but(col, "use_map_field", "field_factor", "Force Fields")

            col.separator()

            col = flow.column()
            factor_but(col, "use_map_length", "length_factor", "Hair Length")
            factor_but(col, "use_map_clump", "clump_factor", "Clump")
            factor_but(col, "use_map_twist", "twist_factor", "Twist")

            col = flow.column()
            factor_but(col, "use_map_kink_amp", "kink_amp_factor", "Kink Amplitude")
            factor_but(col, "use_map_kink_freq", "kink_freq_factor", "Kink Frequency")
            factor_but(col, "use_map_rough", "rough_factor", "Rough")

        elif isinstance(idblock, FreestyleLineStyle):
            col = flow.column()
            factor_but(col, "use_map_color_diffuse", "diffuse_color_factor", "Color")
            factor_but(col, "use_map_alpha", "alpha_factor", "Alpha")

        if not isinstance(idblock, ParticleSettings):
            col = flow.column()

            col.prop(tex, "blend_type", text="Blend")
            col.prop(tex, "use_rgb_to_intensity")

            # color is used on gray-scale textures even when use_rgb_to_intensity is disabled.
            col.prop(tex, "color", text="")

            col = flow.column()
            col.prop(tex, "invert", text="Negative")
            col.prop(tex, "use_stencil")


class TextureColorsPoll:
    @classmethod
    def poll(cls, context):
        tex = context.texture
        return tex and (tex.type != 'NONE' or tex.use_nodes) and (context.engine in cls.COMPAT_ENGINES)


class TEXTURE_PT_colors(TextureButtonsPanel, TextureColorsPoll, Panel):
    bl_label = "Colors"
    bl_options = {'DEFAULT_CLOSED'}
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        flow = layout.grid_flow(row_major=False, columns=0, even_columns=False, even_rows=False, align=False)

        tex = context.texture

        col = flow.column()
        col.prop(tex, "use_clamp", text="Clamp")

        col = flow.column(align=True)
        col.prop(tex, "factor_red", text="Multiply R")
        col.prop(tex, "factor_green", text="G")
        col.prop(tex, "factor_blue", text="B")

        col.separator()

        col = flow.column()
        col.prop(tex, "intensity")
        col.prop(tex, "contrast")
        col.prop(tex, "saturation")


class TEXTURE_PT_colors_ramp(TextureButtonsPanel, TextureColorsPoll, Panel):
    bl_label = "Color Ramp"
    bl_options = {'DEFAULT_CLOSED'}
    bl_parent_id = 'TEXTURE_PT_colors'
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}

    def draw_header(self, context):
        tex = context.texture
        self.layout.prop(tex, "use_color_ramp", text="")

    def draw(self, context):
        layout = self.layout

        tex = context.texture

        # Note: TODO after creation of a new texture, the template_color_ramp will be blank.
        #       Possibly needs to be fixed in the template itself.
        is_active = bool(tex and tex.use_color_ramp)
        if is_active:
            layout.template_color_ramp(tex, "color_ramp", expand=True)
        else:
            layout.alignment = 'RIGHT'
            layout.label("Please enable the Color Ramp first")


class TEXTURE_PT_custom_props(TextureButtonsPanel, PropertyPanel, Panel):
    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
    _context_path = "texture"
    _property_type = Texture

    @classmethod
    def poll(cls, context):
        return context.texture and (context.engine in cls.COMPAT_ENGINES)


classes = (
    TEXTURE_MT_specials,
    TEXTURE_UL_texslots,
    TEXTURE_PT_preview,
    TEXTURE_PT_context,
    TEXTURE_PT_node,
    TEXTURE_PT_node_mapping,
    TEXTURE_PT_clouds,
    TEXTURE_PT_wood,
    TEXTURE_PT_marble,
    TEXTURE_PT_magic,
    TEXTURE_PT_blend,
    TEXTURE_PT_stucci,
    TEXTURE_PT_image,
    TEXTURE_PT_image_settings,
    TEXTURE_PT_image_alpha,
    TEXTURE_PT_image_mapping,
    TEXTURE_PT_image_mapping_crop,
    TEXTURE_PT_image_sampling,
    TEXTURE_PT_musgrave,
    TEXTURE_PT_voronoi,
    TEXTURE_PT_voronoi_feature_weights,
    TEXTURE_PT_distortednoise,
    TEXTURE_PT_influence,
    TEXTURE_PT_mapping,
    TEXTURE_PT_colors,
    TEXTURE_PT_colors_ramp,
    TEXTURE_PT_custom_props,
)

if __name__ == "__main__":  # only for live edit.
    from bpy.utils import register_class
    for cls in classes:
        register_class(cls)