Skip to content

material_prim

MaterialPrim

Bases: BasePrim

Provides high level functions to deal with a material prim and its attributes/ properties.

If there is a material prim present at the path, it will use it. Otherwise, a new material prim at the specified prim path will be created.

Parameters:

Name Type Description Default
prim_path str

prim path of the Prim to encapsulate or create.

required
name str

Name for the object. Names need to be unique per scene.

required
load_config None or dict

If specified, should contain keyword-mapped values that are relevant for loading this prim at runtime. Note that this is only needed if the prim does not already exist at @prim_path -- it will be ignored if it already exists. Subclasses should define the exact keys expected for their class. For this material prim, the below values can be specified:

mdl_name (None or str): If specified, should be the name of the mdl preset to load (including .mdl). None results in default, "OmniPBR.mdl" mtl_name (None or str): If specified, should be the name of the mtl preset to load. None results in default, "OmniPBR"

None
Source code in omnigibson/prims/material_prim.py
  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
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
class MaterialPrim(BasePrim):
    """
    Provides high level functions to deal with a material prim and its attributes/ properties.

    If there is a material prim present at the path, it will use it. Otherwise, a new material prim at
    the specified prim path will be created.

    Args:
        prim_path (str): prim path of the Prim to encapsulate or create.
        name (str): Name for the object. Names need to be unique per scene.
        load_config (None or dict): If specified, should contain keyword-mapped values that are relevant for
            loading this prim at runtime. Note that this is only needed if the prim does not already exist at
            @prim_path -- it will be ignored if it already exists. Subclasses should define the exact keys expected
            for their class. For this material prim, the below values can be specified:

            mdl_name (None or str): If specified, should be the name of the mdl preset to load (including .mdl).
                None results in default, "OmniPBR.mdl"
            mtl_name (None or str): If specified, should be the name of the mtl preset to load.
                None results in default, "OmniPBR"
    """
    # Persistent dictionary of materials, mapped from prim_path to MaterialPrim
    MATERIALS = dict()

    @classmethod
    def get_material(cls, name, prim_path, load_config=None):
        """
        Get a material prim from the persistent dictionary of materials, or create a new one if it doesn't exist.

        Args:
            name (str): Name for the object.
            prim_path (str): prim path of the MaterialPrim.
            load_config (None or dict): If specified, should contain keyword-mapped values that are relevant for
                loading this prim at runtime. Note that this is only needed if the prim does not already exist at
                @prim_path -- it will be ignored if it already exists.
        Returns:
            MaterialPrim: Material prim at the specified path
        """
        # If the material already exists, return it
        if prim_path in cls.MATERIALS:
            return cls.MATERIALS[prim_path]

        # Otherwise, create a new one and return it
        new_material = cls(prim_path=prim_path, name=name, load_config=load_config)
        cls.MATERIALS[prim_path] = new_material
        return new_material

    def __init__(
        self,
        prim_path,
        name,
        load_config=None,
    ):
        # Other values that will be filled in at runtime
        self._shader = None

        # Users of this material: should be a set of BaseObject and BaseSystem
        self._users = set()

        # Run super init
        super().__init__(
            prim_path=prim_path,
            name=name,
            load_config=load_config,
        )

    def _load(self):
        # We create a new material at the specified path
        mtl_created = []
        lazy.omni.kit.commands.execute(
            "CreateAndBindMdlMaterialFromLibrary",
            mdl_name="OmniPBR.mdl" if self._load_config.get("mdl_name", None) is None else self._load_config["mdl_name"],
            mtl_name="OmniPBR" if self._load_config.get("mtl_name", None) is None else self._load_config["mtl_name"],
            mtl_created_list=mtl_created,
        )
        material_path = mtl_created[0]

        # Move prim to desired location
        lazy.omni.kit.commands.execute("MovePrim", path_from=material_path, path_to=self._prim_path)

        # Return generated material
        return lazy.omni.isaac.core.utils.prims.get_prim_at_path(self._prim_path)

    @classmethod
    def clear(cls):
        cls.MATERIALS = dict()

    @property
    def users(self):
        """
        Users of this material: should be a list of BaseObject and BaseSystem
        """
        return self._users

    def add_user(self, user):
        """
        Adds a user to the material. This can be a BaseObject or BaseSystem.

        Args:
            user (BaseObject or BaseSystem): User to add to the material
        """
        self._users.add(user)

    def remove_user(self, user):
        """
        Removes a user from the material. This can be a BaseObject or BaseSystem.
        If there are no users left, the material will be removed.

        Args:
            user (BaseObject or BaseSystem): User to remove from the material
        """
        self._users.remove(user)
        if len(self._users) == 0:
            self.remove()

    def remove(self):
        # Remove from global sensors dictionary
        self.MATERIALS.pop(self._prim_path)

        # Run super
        super().remove()

    def _post_load(self):
        # run super first
        super()._post_load()

        # Add this material to the list of global materials
        self.MATERIALS[self._prim_path] = self

        # Generate shader reference
        self._shader = lazy.omni.usd.get_shader_from_material(self._prim)

    def bind(self, target_prim_path):
        """
        Bind this material to an arbitrary prim (usually a visual mesh prim)

        Args:
            target_prim_path (str): prim path of the Prim to bind to
        """
        bind_material(prim_path=target_prim_path, material_path=self.prim_path)

    async def _load_mdl_parameters(self, render=True):
        """
        Loads MDL parameters internally so they can be accessed by our class instance

        Args:
            render (bool): If True, takes a rendering step before loading the mdl parameters.
                Note that a rendering step is necessary to load these parameters, though if a step has already
                occurred externally, no additional rendering step is needed
        """
        if render:
            og.sim.render()
        await lazy.omni.usd.get_context().load_mdl_parameters_for_prim_async(self._shader)

    def shader_force_populate(self, render=True):
        """
        Force populate inputs and outputs of the shader

        Args:
            render (bool): If True, takes a rendering step before force populating the inputs and outputs.
                Note that a rendering step is necessary to load these I/Os, though if a step has already
                occurred externally, no additional rendering step is needed
        """
        assert self._shader is not None
        asyncio.run(self._load_mdl_parameters(render=render))

    def shader_update_asset_paths_with_root_path(self, root_path):
        """
        Similar to @shader_update_asset_paths, except in this case, root_path is explicitly provided by the caller.

        Args:
            root_path (str): root to be pre-appended to the original asset paths
        """

        for inp_name in self.shader_input_names_by_type("SdfAssetPath"):
            inp = self.get_input(inp_name)
            # If the input doesn't have any path, skip
            if inp is None:
                continue

            original_path = inp.path if inp.resolvedPath == "" else inp.resolvedPath
            # If the input has an empty path, skip
            if original_path == "":
                continue

            new_path = os.path.join(root_path, original_path)
            self.set_input(inp_name, new_path)

    def get_input(self, inp):
        """
        Grabs the input with corresponding name @inp associated with this material and shader

        Args:
            inp (str): Name of the shader input whose value will be grabbed

        Returns:
            any: value of the requested @inp
        """
        return self._shader.GetInput(inp).Get()

    def set_input(self, inp, val):
        """
        Sets the input with corresponding name @inp associated with this material and shader

        Args:
            inp (str): Name of the shader input whose value will be set
            val (any): Value to set for the input. This should be the valid type for that attribute.
        """
        # Make sure the input exists first, so we avoid segfaults with "invalid null prim"
        assert inp in self.shader_input_names, \
            f"Got invalid shader input to set! Current inputs are: {self.shader_input_names}. Got: {inp}"
        self._shader.GetInput(inp).Set(val)

    @property
    def is_glass(self):
        """
        Returns:
            bool: Whether this material is a glass material or not
        """
        return "glass_color" in self.shader_input_names

    @property
    def shader(self):
        """
        Returns:
            Usd.Shade: Shader associated with this material
        """
        return self._shader

    @property
    def shader_input_names(self):
        """
        Returns:
            set: All the shader input names associated with this material
        """
        return {inp.GetBaseName() for inp in self._shader.GetInputs()}

    def shader_input_names_by_type(self, input_type):
        """
        Args:
            input_type (str): input type

        Returns:
            set: All the shader input names associated with this material that match the given input type
        """
        return {inp.GetBaseName() for inp in self._shader.GetInputs() if inp.GetTypeName().cppTypeName == input_type}

    @property
    def diffuse_color_constant(self):
        """
        Returns:
            3-array: this material's applied (R,G,B) color
        """
        return np.array(self.get_input(inp="diffuse_color_constant"))

    @diffuse_color_constant.setter
    def diffuse_color_constant(self, color):
        """
        Args:
             color (3-array): this material's applied (R,G,B) color
        """
        self.set_input(inp="diffuse_color_constant", val=lazy.pxr.Gf.Vec3f(*np.array(color, dtype=float)))

    @property
    def diffuse_texture(self):
        """
        Returns:
            str: this material's applied diffuse_texture filepath
        """
        return self.get_input(inp="diffuse_texture").resolvedPath

    @diffuse_texture.setter
    def diffuse_texture(self, fpath):
        """
        Args:
            str: this material's applied diffuse_texture filepath
        """
        self.set_input(inp="diffuse_texture", val=lazy.pxr.Sdf.AssetPath(fpath))

    @property
    def albedo_desaturation(self):
        """
        Returns:
            float: this material's applied albedo_desaturation
        """
        return self.get_input(inp="albedo_desaturation")

    @albedo_desaturation.setter
    def albedo_desaturation(self, desaturation):
        """
        Args:
             desaturation (float): this material's applied albedo_desaturation
        """
        self.set_input(inp="albedo_desaturation", val=desaturation)

    @property
    def albedo_add(self):
        """
        Returns:
            float: this material's applied albedo_add
        """
        return self.get_input(inp="albedo_add")

    @albedo_add.setter
    def albedo_add(self, add):
        """
        Args:
             add (float): this material's applied albedo_add
        """
        self.set_input(inp="albedo_add", val=add)

    @property
    def albedo_brightness(self):
        """
        Returns:
            float: this material's applied albedo_brightness
        """
        return self.get_input(inp="albedo_brightness")

    @albedo_brightness.setter
    def albedo_brightness(self, brightness):
        """
        Args:
             brightness (float): this material's applied albedo_brightness
        """
        self.set_input(inp="albedo_brightness", val=brightness)

    @property
    def diffuse_tint(self):
        """
        Returns:
            3-array: this material's applied (R,G,B) diffuse_tint
        """
        return np.array(self.get_input(inp="diffuse_tint"))

    @diffuse_tint.setter
    def diffuse_tint(self, color):
        """
        Args:
             color (3-array): this material's applied (R,G,B) diffuse_tint
        """
        self.set_input(inp="diffuse_tint", val=lazy.pxr.Gf.Vec3f(*np.array(color, dtype=float)))

    @property
    def reflection_roughness_constant(self):
        """
        Returns:
            float: this material's applied reflection_roughness_constant
        """
        return self.get_input(inp="reflection_roughness_constant")

    @reflection_roughness_constant.setter
    def reflection_roughness_constant(self, roughness):
        """
        Args:
             roughness (float): this material's applied reflection_roughness_constant
        """
        self.set_input(inp="reflection_roughness_constant", val=roughness)

    @property
    def reflection_roughness_texture_influence(self):
        """
        Returns:
            float: this material's applied reflection_roughness_texture_influence
        """
        return self.get_input(inp="reflection_roughness_texture_influence")

    @reflection_roughness_texture_influence.setter
    def reflection_roughness_texture_influence(self, prop):
        """
        Args:
             prop (float): this material's applied reflection_roughness_texture_influence proportion
        """
        self.set_input(inp="reflection_roughness_texture_influence", val=prop)

    @property
    def reflectionroughness_texture(self):
        """
        Returns:
            None or str: this material's applied reflectionroughness_texture fpath if there is a texture applied, else
                None
        """
        inp = self.get_input(inp="reflectionroughness_texture")
        return None if inp is None else inp.resolvedPath

    @reflectionroughness_texture.setter
    def reflectionroughness_texture(self, fpath):
        """
        Args:
             fpath (str): this material's applied reflectionroughness_texture fpath
        """
        self.set_input(inp="reflectionroughness_texture", val=lazy.pxr.Sdf.AssetPath(fpath))

    @property
    def metallic_constant(self):
        """
        Returns:
            float: this material's applied metallic_constant
        """
        return self.get_input(inp="metallic_constant")

    @metallic_constant.setter
    def metallic_constant(self, constant):
        """
        Args:
             constant (float): this material's applied metallic_constant
        """
        self.set_input(inp="metallic_constant", val=constant)

    @property
    def metallic_texture_influence(self):
        """
        Returns:
            float: this material's applied metallic_texture_influence
        """
        return self.get_input(inp="metallic_texture_influence")

    @metallic_texture_influence.setter
    def metallic_texture_influence(self, prop):
        """
        Args:
             prop (float): this material's applied metallic_texture_influence
        """
        self.set_input(inp="metallic_texture_influence", val=prop)

    @property
    def metallic_texture(self):
        """
        Returns:
            None or str: this material's applied metallic_texture fpath if there is a texture applied, else
                None
        """
        inp = self.get_input(inp="metallic_texture")
        return None if inp is None else inp.resolvedPath

    @metallic_texture.setter
    def metallic_texture(self, fpath):
        """
        Args:
             fpath (str): this material's applied metallic_texture fpath
        """
        self.set_input(inp="metallic_texture", val=lazy.pxr.Sdf.AssetPath(fpath))

    @property
    def specular_level(self):
        """
        Returns:
            float: this material's applied specular_level
        """
        return self.get_input(inp="specular_level")

    @specular_level.setter
    def specular_level(self, level):
        """
        Args:
             level (float): this material's applied specular_level
        """
        self.set_input(inp="specular_level", val=level)

    @property
    def enable_ORM_texture(self):
        """
        Returns:
            bool: this material's applied enable_ORM_texture
        """
        return self.get_input(inp="enable_ORM_texture")

    @enable_ORM_texture.setter
    def enable_ORM_texture(self, enabled):
        """
        Args:
             enabled (bool): this material's applied enable_ORM_texture
        """
        self.set_input(inp="enable_ORM_texture", val=enabled)

    @property
    def ORM_texture(self):
        """
        Returns:
            None or str: this material's applied ORM_texture fpath if there is a texture applied, else
                None
        """
        inp = self.get_input(inp="ORM_texture")
        return None if inp is None else inp.resolvedPath

    @ORM_texture.setter
    def ORM_texture(self, fpath):
        """
        Args:
             fpath (str): this material's applied ORM_texture fpath
        """
        self.set_input(inp="ORM_texture", val=lazy.pxr.Sdf.AssetPath(fpath))

    @property
    def ao_to_diffuse(self):
        """
        Returns:
            float: this material's applied ao_to_diffuse
        """
        return self.get_input(inp="ao_to_diffuse")

    @ao_to_diffuse.setter
    def ao_to_diffuse(self, val):
        """
        Args:
             val (float): this material's applied ao_to_diffuse
        """
        self.set_input(inp="ao_to_diffuse", val=val)

    @property
    def ao_texture(self):
        """
        Returns:
            None or str: this material's applied ao_texture fpath if there is a texture applied, else
                None
        """
        inp = self.get_input(inp="ao_texture")
        return None if inp is None else inp.resolvedPath

    @ao_texture.setter
    def ao_texture(self, fpath):
        """
        Args:
             fpath (str): this material's applied ao_texture fpath
        """
        self.set_input(inp="ao_texture", val=lazy.pxr.Sdf.AssetPath(fpath))

    @property
    def enable_emission(self):
        """
        Returns:
            bool: this material's applied enable_emission
        """
        return self.get_input(inp="enable_emission")

    @enable_emission.setter
    def enable_emission(self, enabled):
        """
        Args:
             enabled (bool): this material's applied enable_emission
        """
        self.set_input(inp="enable_emission", val=enabled)

    @property
    def emissive_color(self):
        """
        Returns:
            3-array: this material's applied (R,G,B) emissive_color
        """
        return np.array(self.get_input(inp="emissive_color"))

    @emissive_color.setter
    def emissive_color(self, color):
        """
        Args:
             color (3-array): this material's applied emissive_color
        """
        self.set_input(inp="emissive_color", val=lazy.pxr.Gf.Vec3f(*np.array(color, dtype=float)))

    @property
    def emissive_color_texture(self):
        """
        Returns:
            None or str: this material's applied emissive_color_texture fpath if there is a texture applied, else
                None
        """
        inp = self.get_input(inp="emissive_color_texture")
        return None if inp is None else inp.resolvedPath

    @emissive_color_texture.setter
    def emissive_color_texture(self, fpath):
        """
        Args:
             fpath (str): this material's applied emissive_color_texture fpath
        """
        self.set_input(inp="emissive_color_texture", val=lazy.pxr.Sdf.AssetPath(fpath))

    @property
    def emissive_mask_texture(self):
        """
        Returns:
            None or str: this material's applied emissive_mask_texture fpath if there is a texture applied, else
                None
        """
        inp = self.get_input(inp="emissive_mask_texture")
        return None if inp is None else inp.resolvedPath

    @emissive_mask_texture.setter
    def emissive_mask_texture(self, fpath):
        """
        Args:
             fpath (str): this material's applied emissive_mask_texture fpath
        """
        self.set_input(inp="emissive_mask_texture", val=lazy.pxr.Sdf.AssetPath(fpath))

    @property
    def emissive_intensity(self):
        """
        Returns:
            float: this material's applied emissive_intensity
        """
        return self.get_input(inp="emissive_intensity")

    @emissive_intensity.setter
    def emissive_intensity(self, intensity):
        """
        Args:
             intensity (float): this material's applied emissive_intensity
        """
        self.set_input(inp="emissive_intensity", val=intensity)

    @property
    def enable_opacity(self):
        """
        Returns:
            bool: this material's applied enable_opacity
        """
        return self.get_input(inp="enable_opacity")

    @enable_opacity.setter
    def enable_opacity(self, enabled):
        """
        Args:
             enabled (bool): this material's applied enable_opacity
        """
        self.set_input(inp="enable_opacity", val=enabled)

    @property
    def enable_opacity_texture(self):
        """
        Returns:
            bool: this material's applied enable_opacity_texture
        """
        return self.get_input(inp="enable_opacity_texture")

    @enable_opacity_texture.setter
    def enable_opacity_texture(self, enabled):
        """
        Args:
             enabled (bool): this material's applied enable_opacity_texture
        """
        self.set_input(inp="enable_opacity_texture", val=enabled)

    @property
    def opacity_constant(self):
        """
        Returns:
            float: this material's applied opacity_constant
        """
        return self.get_input(inp="opacity_constant")

    @opacity_constant.setter
    def opacity_constant(self, constant):
        """
        Args:
             constant (float): this material's applied opacity_constant
        """
        self.set_input(inp="opacity_constant", val=constant)

    @property
    def opacity_texture(self):
        """
        Returns:
            None or str: this material's applied opacity_texture fpath if there is a texture applied, else
                None
        """
        inp = self.get_input(inp="opacity_texture")
        return None if inp is None else inp.resolvedPath

    @opacity_texture.setter
    def opacity_texture(self, fpath):
        """
        Args:
             fpath (str): this material's applied opacity_texture fpath
        """
        self.set_input(inp="opacity_texture", val=lazy.pxr.Sdf.AssetPath(fpath))

    @property
    def opacity_mode(self):
        """
        Returns:
            int: this material's applied opacity_mode
        """
        return self.get_input(inp="opacity_mode")

    @opacity_mode.setter
    def opacity_mode(self, mode):
        """
        Args:
             mode (int): this material's applied opacity_mode
        """
        self.set_input(inp="opacity_mode", val=mode)

    @property
    def opacity_threshold(self):
        """
        Returns:
            float: this material's applied opacity_threshold
        """
        return self.get_input(inp="opacity_threshold")

    @opacity_threshold.setter
    def opacity_threshold(self, threshold):
        """
        Args:
             threshold (float): this material's applied opacity_threshold
        """
        self.set_input(inp="opacity_threshold", val=threshold)

    @property
    def bump_factor(self):
        """
        Returns:
            float: this material's applied bump_factor
        """
        return self.get_input(inp="bump_factor")

    @bump_factor.setter
    def bump_factor(self, factor):
        """
        Args:
             factor (float): this material's applied bump_factor
        """
        self.set_input(inp="bump_factor", val=factor)

    @property
    def normalmap_texture(self):
        """
        Returns:
            None or str: this material's applied normalmap_texture fpath if there is a texture applied, else
                None
        """
        inp = self.get_input(inp="normalmap_texture")
        return None if inp is None else inp.resolvedPath

    @normalmap_texture.setter
    def normalmap_texture(self, fpath):
        """
        Args:
             fpath (str): this material's applied normalmap_texture fpath
        """
        self.set_input(inp="normalmap_texture", val=lazy.pxr.Sdf.AssetPath(fpath))

    @property
    def detail_bump_factor(self):
        """
        Returns:
            float: this material's applied detail_bump_factor
        """
        return self.get_input(inp="detail_bump_factor")

    @detail_bump_factor.setter
    def detail_bump_factor(self, factor):
        """
        Args:
             factor (float): this material's applied detail_bump_factor
        """
        self.set_input(inp="detail_bump_factor", val=factor)

    @property
    def detail_normalmap_texture(self):
        """
        Returns:
            None or str: this material's applied detail_normalmap_texture fpath if there is a texture applied, else
                None
        """
        inp = self.get_input(inp="detail_normalmap_texture")
        return None if inp is None else inp.resolvedPath

    @detail_normalmap_texture.setter
    def detail_normalmap_texture(self, fpath):
        """
        Args:
             fpath (str): this material's applied detail_normalmap_texture fpath
        """
        self.set_input(inp="detail_normalmap_texture", val=lazy.pxr.Sdf.AssetPath(fpath))

    @property
    def flip_tangent_u(self):
        """
        Returns:
            bool: this material's applied flip_tangent_u
        """
        return self.get_input(inp="flip_tangent_u")

    @flip_tangent_u.setter
    def flip_tangent_u(self, flipped):
        """
        Args:
             flipped (bool): this material's applied flip_tangent_u
        """
        self.set_input(inp="flip_tangent_u", val=flipped)

    @property
    def flip_tangent_v(self):
        """
        Returns:
            bool: this material's applied flip_tangent_v
        """
        return self.get_input(inp="flip_tangent_v")

    @flip_tangent_v.setter
    def flip_tangent_v(self, flipped):
        """
        Args:
             flipped (bool): this material's applied flip_tangent_v
        """
        self.set_input(inp="flip_tangent_v", val=flipped)

    @property
    def project_uvw(self):
        """
        Returns:
            bool: this material's applied project_uvw
        """
        return self.get_input(inp="project_uvw")

    @project_uvw.setter
    def project_uvw(self, projected):
        """
        Args:
             projected (bool): this material's applied project_uvw
        """
        self.set_input(inp="project_uvw", val=projected)

    @property
    def world_or_object(self):
        """
        Returns:
            bool: this material's applied world_or_object
        """
        return self.get_input(inp="world_or_object")

    @world_or_object.setter
    def world_or_object(self, val):
        """
        Args:
             val (bool): this material's applied world_or_object
        """
        self.set_input(inp="world_or_object", val=val)

    @property
    def uv_space_index(self):
        """
        Returns:
            int: this material's applied uv_space_index
        """
        return self.get_input(inp="uv_space_index")

    @uv_space_index.setter
    def uv_space_index(self, index):
        """
        Args:
             index (int): this material's applied uv_space_index
        """
        self.set_input(inp="uv_space_index", val=index)

    @property
    def texture_translate(self):
        """
        Returns:
            2-array: this material's applied texture_translate
        """
        return np.array(self.get_input(inp="texture_translate"))

    @texture_translate.setter
    def texture_translate(self, translate):
        """
        Args:
             translate (2-array): this material's applied (x,y) texture_translate
        """
        self.set_input(inp="texture_translate", val=lazy.pxr.Gf.Vec2f(*np.array(translate, dtype=float)))

    @property
    def texture_rotate(self):
        """
        Returns:
            float: this material's applied texture_rotate
        """
        return self.get_input(inp="texture_rotate")

    @texture_rotate.setter
    def texture_rotate(self, rotate):
        """
        Args:
             rotate (float): this material's applied texture_rotate
        """
        self.set_input(inp="texture_rotate", val=rotate)

    @property
    def texture_scale(self):
        """
        Returns:
            2-array: this material's applied texture_scale
        """
        return np.array(self.get_input(inp="texture_scale"))

    @texture_scale.setter
    def texture_scale(self, scale):
        """
        Args:
             scale (2-array): this material's applied (x,y) texture_scale
        """
        self.set_input(inp="texture_scale", val=lazy.pxr.Gf.Vec2f(*np.array(scale, dtype=float)))

    @property
    def detail_texture_translate(self):
        """
        Returns:
            2-array: this material's applied detail_texture_translate
        """
        return np.array(self.get_input(inp="detail_texture_translate"))

    @detail_texture_translate.setter
    def detail_texture_translate(self, translate):
        """
        Args:
             translate (2-array): this material's applied detail_texture_translate
        """
        self.set_input(inp="detail_texture_translate", val=lazy.pxr.Gf.Vec2f(*np.array(translate, dtype=float)))

    @property
    def detail_texture_rotate(self):
        """
        Returns:
            float: this material's applied detail_texture_rotate
        """
        return self.get_input(inp="detail_texture_rotate")

    @detail_texture_rotate.setter
    def detail_texture_rotate(self, rotate):
        """
        Args:
             rotate (float): this material's applied detail_texture_rotate
        """
        self.set_input(inp="detail_texture_rotate", val=rotate)

    @property
    def detail_texture_scale(self):
        """
        Returns:
            2-array: this material's applied detail_texture_scale
        """
        return np.array(self.get_input(inp="detail_texture_scale"))

    @detail_texture_scale.setter
    def detail_texture_scale(self, scale):
        """
        Args:
             scale (2-array): this material's applied detail_texture_scale
        """
        self.set_input(inp="detail_texture_scale", val=lazy.pxr.Gf.Vec2f(*np.array(scale, dtype=float)))

    @property
    def exclude_from_white_mode(self):
        """
        Returns:
            bool: this material's applied excludeFromWhiteMode
        """
        return self.get_input(inp="excludeFromWhiteMode")

    @exclude_from_white_mode.setter
    def exclude_from_white_mode(self, exclude):
        """
        Args:
             exclude (bool): this material's applied excludeFromWhiteMode
        """
        self.set_input(inp="excludeFromWhiteMode", val=exclude)

    @property
    def diffuse_reflection_weight(self):
        """
        Returns:
            float: this material's applied diffuse_reflection_weight
        """
        return self.get_input(inp="diffuse_reflection_weight")

    @diffuse_reflection_weight.setter
    def diffuse_reflection_weight(self, weight):
        """
        Args:
             weight (float): this material's applied diffuse_reflection_weight
        """
        self.set_input(inp="diffuse_reflection_weight", val=weight)

    @property
    def enable_specular_transmission(self):
        """
        Returns:
            bool: this material's applied enable_specular_transmission
        """
        return self.get_input(inp="enable_specular_transmission")

    @enable_specular_transmission.setter
    def enable_specular_transmission(self, enabled):
        """
        Args:
             enabled (bool): this material's applied enable_specular_transmission
        """
        self.set_input(inp="enable_specular_transmission", val=enabled)

    @property
    def specular_transmission_weight(self):
        """
        Returns:
            float: this material's applied specular_transmission_weight
        """
        return self.get_input(inp="specular_transmission_weight")

    @specular_transmission_weight.setter
    def specular_transmission_weight(self, weight):
        """
        Args:
             weight (float): this material's applied specular_transmission_weight
        """
        self.set_input(inp="specular_transmission_weight", val=weight)

    @property
    def diffuse_reflection_color(self):
        """
        Returns:
            3-array: this material's diffuse_reflection_color in (R,G,B)
        """
        return np.array(self.get_input(inp="diffuse_reflection_color"))

    @diffuse_reflection_color.setter
    def diffuse_reflection_color(self, color):
        """
        Args:
             color (3-array): this material's diffuse_reflection_color in (R,G,B)
        """
        self.set_input(inp="diffuse_reflection_color", val=lazy.pxr.Gf.Vec3f(*np.array(color, dtype=float)))

    @property
    def specular_reflection_color(self):
        """
        Returns:
            3-array: this material's specular_reflection_color in (R,G,B)
        """
        return np.array(self.get_input(inp="specular_reflection_color"))

    @specular_reflection_color.setter
    def specular_reflection_color(self, color):
        """
        Args:
             color (3-array): this material's specular_reflection_color in (R,G,B)
        """
        self.set_input(inp="specular_reflection_color", val=lazy.pxr.Gf.Vec3f(*np.array(color, dtype=float)))

    @property
    def specular_transmission_color(self):
        """
        Returns:
            3-array: this material's specular_transmission_color in (R,G,B)
        """
        return np.array(self.get_input(inp="specular_transmission_color"))

    @specular_transmission_color.setter
    def specular_transmission_color(self, color):
        """
        Args:
             color (3-array): this material's specular_transmission_color in (R,G,B)
        """
        self.set_input(inp="specular_transmission_color", val=lazy.pxr.Gf.Vec3f(*np.array(color, dtype=float)))

    @property
    def specular_transmission_scattering_color(self):
        """
        Returns:
            3-array: this material's specular_transmission_scattering_color in (R,G,B)
        """
        return np.array(self.get_input(inp="specular_transmission_scattering_color"))

    @specular_transmission_scattering_color.setter
    def specular_transmission_scattering_color(self, color):
        """
        Args:
             color (3-array): this material's specular_transmission_scattering_color in (R,G,B)
        """
        self.set_input(inp="specular_transmission_scattering_color", val=lazy.pxr.Gf.Vec3f(*np.array(color, dtype=float)))

    @property
    def specular_reflection_ior_preset(self):
        """
        Returns:
            int: this material's specular_reflection_ior_preset (int corresponding to enum)
        """
        return self.get_input(inp="specular_reflection_ior_preset")

    @specular_reflection_ior_preset.setter
    def specular_reflection_ior_preset(self, preset):
        """
        Args:
             preset (int): this material's specular_reflection_ior_preset (int corresponding to enum)
        """
        self.set_input(inp="specular_reflection_ior_preset", val=preset)

    @property
    def enable_diffuse_transmission(self):
        """
        Returns:
            float: this material's applied enable_diffuse_transmission
        """
        return self.get_input(inp="enable_diffuse_transmission")

    @enable_diffuse_transmission.setter
    def enable_diffuse_transmission(self, val):
        """
        Args:
             val (bool): this material's applied enable_diffuse_transmission
        """
        self.set_input(inp="enable_diffuse_transmission", val=val)

    @property
    def glass_color(self):
        """
        Returns:
            3-array: this material's applied (R,G,B) glass color (only applicable to OmniGlass materials)
        """
        assert self.is_glass, f"Tried to query glass_color shader input, " \
                              f"but material at {self.prim_path} is not an OmniGlass material!"
        return np.array(self.get_input(inp="glass_color"))

    @glass_color.setter
    def glass_color(self, color):
        """
        Args:
             color (3-array): this material's applied (R,G,B) glass color (only applicable to OmniGlass materials)
        """
        assert self.is_glass, f"Tried to set glass_color shader input, " \
                              f"but material at {self.prim_path} is not an OmniGlass material!"
        self.set_input(inp="glass_color", val=lazy.pxr.Gf.Vec3f(*np.array(color, dtype=float)))

ORM_texture property writable

Returns:

Type Description

None or str: this material's applied ORM_texture fpath if there is a texture applied, else None

albedo_add property writable

Returns:

Name Type Description
float

this material's applied albedo_add

albedo_brightness property writable

Returns:

Name Type Description
float

this material's applied albedo_brightness

albedo_desaturation property writable

Returns:

Name Type Description
float

this material's applied albedo_desaturation

ao_texture property writable

Returns:

Type Description

None or str: this material's applied ao_texture fpath if there is a texture applied, else None

ao_to_diffuse property writable

Returns:

Name Type Description
float

this material's applied ao_to_diffuse

bump_factor property writable

Returns:

Name Type Description
float

this material's applied bump_factor

detail_bump_factor property writable

Returns:

Name Type Description
float

this material's applied detail_bump_factor

detail_normalmap_texture property writable

Returns:

Type Description

None or str: this material's applied detail_normalmap_texture fpath if there is a texture applied, else None

detail_texture_rotate property writable

Returns:

Name Type Description
float

this material's applied detail_texture_rotate

detail_texture_scale property writable

Returns:

Type Description

2-array: this material's applied detail_texture_scale

detail_texture_translate property writable

Returns:

Type Description

2-array: this material's applied detail_texture_translate

diffuse_color_constant property writable

Returns:

Type Description

3-array: this material's applied (R,G,B) color

diffuse_reflection_color property writable

Returns:

Type Description

3-array: this material's diffuse_reflection_color in (R,G,B)

diffuse_reflection_weight property writable

Returns:

Name Type Description
float

this material's applied diffuse_reflection_weight

diffuse_texture property writable

Returns:

Name Type Description
str

this material's applied diffuse_texture filepath

diffuse_tint property writable

Returns:

Type Description

3-array: this material's applied (R,G,B) diffuse_tint

emissive_color property writable

Returns:

Type Description

3-array: this material's applied (R,G,B) emissive_color

emissive_color_texture property writable

Returns:

Type Description

None or str: this material's applied emissive_color_texture fpath if there is a texture applied, else None

emissive_intensity property writable

Returns:

Name Type Description
float

this material's applied emissive_intensity

emissive_mask_texture property writable

Returns:

Type Description

None or str: this material's applied emissive_mask_texture fpath if there is a texture applied, else None

enable_ORM_texture property writable

Returns:

Name Type Description
bool

this material's applied enable_ORM_texture

enable_diffuse_transmission property writable

Returns:

Name Type Description
float

this material's applied enable_diffuse_transmission

enable_emission property writable

Returns:

Name Type Description
bool

this material's applied enable_emission

enable_opacity property writable

Returns:

Name Type Description
bool

this material's applied enable_opacity

enable_opacity_texture property writable

Returns:

Name Type Description
bool

this material's applied enable_opacity_texture

enable_specular_transmission property writable

Returns:

Name Type Description
bool

this material's applied enable_specular_transmission

exclude_from_white_mode property writable

Returns:

Name Type Description
bool

this material's applied excludeFromWhiteMode

flip_tangent_u property writable

Returns:

Name Type Description
bool

this material's applied flip_tangent_u

flip_tangent_v property writable

Returns:

Name Type Description
bool

this material's applied flip_tangent_v

glass_color property writable

Returns:

Type Description

3-array: this material's applied (R,G,B) glass color (only applicable to OmniGlass materials)

is_glass property

Returns:

Name Type Description
bool

Whether this material is a glass material or not

metallic_constant property writable

Returns:

Name Type Description
float

this material's applied metallic_constant

metallic_texture property writable

Returns:

Type Description

None or str: this material's applied metallic_texture fpath if there is a texture applied, else None

metallic_texture_influence property writable

Returns:

Name Type Description
float

this material's applied metallic_texture_influence

normalmap_texture property writable

Returns:

Type Description

None or str: this material's applied normalmap_texture fpath if there is a texture applied, else None

opacity_constant property writable

Returns:

Name Type Description
float

this material's applied opacity_constant

opacity_mode property writable

Returns:

Name Type Description
int

this material's applied opacity_mode

opacity_texture property writable

Returns:

Type Description

None or str: this material's applied opacity_texture fpath if there is a texture applied, else None

opacity_threshold property writable

Returns:

Name Type Description
float

this material's applied opacity_threshold

project_uvw property writable

Returns:

Name Type Description
bool

this material's applied project_uvw

reflection_roughness_constant property writable

Returns:

Name Type Description
float

this material's applied reflection_roughness_constant

reflection_roughness_texture_influence property writable

Returns:

Name Type Description
float

this material's applied reflection_roughness_texture_influence

reflectionroughness_texture property writable

Returns:

Type Description

None or str: this material's applied reflectionroughness_texture fpath if there is a texture applied, else None

shader property

Returns:

Type Description

Usd.Shade: Shader associated with this material

shader_input_names property

Returns:

Name Type Description
set

All the shader input names associated with this material

specular_level property writable

Returns:

Name Type Description
float

this material's applied specular_level

specular_reflection_color property writable

Returns:

Type Description

3-array: this material's specular_reflection_color in (R,G,B)

specular_reflection_ior_preset property writable

Returns:

Name Type Description
int

this material's specular_reflection_ior_preset (int corresponding to enum)

specular_transmission_color property writable

Returns:

Type Description

3-array: this material's specular_transmission_color in (R,G,B)

specular_transmission_scattering_color property writable

Returns:

Type Description

3-array: this material's specular_transmission_scattering_color in (R,G,B)

specular_transmission_weight property writable

Returns:

Name Type Description
float

this material's applied specular_transmission_weight

texture_rotate property writable

Returns:

Name Type Description
float

this material's applied texture_rotate

texture_scale property writable

Returns:

Type Description

2-array: this material's applied texture_scale

texture_translate property writable

Returns:

Type Description

2-array: this material's applied texture_translate

users property

Users of this material: should be a list of BaseObject and BaseSystem

uv_space_index property writable

Returns:

Name Type Description
int

this material's applied uv_space_index

world_or_object property writable

Returns:

Name Type Description
bool

this material's applied world_or_object

add_user(user)

Adds a user to the material. This can be a BaseObject or BaseSystem.

Parameters:

Name Type Description Default
user BaseObject or BaseSystem

User to add to the material

required
Source code in omnigibson/prims/material_prim.py
def add_user(self, user):
    """
    Adds a user to the material. This can be a BaseObject or BaseSystem.

    Args:
        user (BaseObject or BaseSystem): User to add to the material
    """
    self._users.add(user)

bind(target_prim_path)

Bind this material to an arbitrary prim (usually a visual mesh prim)

Parameters:

Name Type Description Default
target_prim_path str

prim path of the Prim to bind to

required
Source code in omnigibson/prims/material_prim.py
def bind(self, target_prim_path):
    """
    Bind this material to an arbitrary prim (usually a visual mesh prim)

    Args:
        target_prim_path (str): prim path of the Prim to bind to
    """
    bind_material(prim_path=target_prim_path, material_path=self.prim_path)

get_input(inp)

Grabs the input with corresponding name @inp associated with this material and shader

Parameters:

Name Type Description Default
inp str

Name of the shader input whose value will be grabbed

required

Returns:

Name Type Description
any

value of the requested @inp

Source code in omnigibson/prims/material_prim.py
def get_input(self, inp):
    """
    Grabs the input with corresponding name @inp associated with this material and shader

    Args:
        inp (str): Name of the shader input whose value will be grabbed

    Returns:
        any: value of the requested @inp
    """
    return self._shader.GetInput(inp).Get()

get_material(name, prim_path, load_config=None) classmethod

Get a material prim from the persistent dictionary of materials, or create a new one if it doesn't exist.

Parameters:

Name Type Description Default
name str

Name for the object.

required
prim_path str

prim path of the MaterialPrim.

required
load_config None or dict

If specified, should contain keyword-mapped values that are relevant for loading this prim at runtime. Note that this is only needed if the prim does not already exist at @prim_path -- it will be ignored if it already exists.

None

Returns: MaterialPrim: Material prim at the specified path

Source code in omnigibson/prims/material_prim.py
@classmethod
def get_material(cls, name, prim_path, load_config=None):
    """
    Get a material prim from the persistent dictionary of materials, or create a new one if it doesn't exist.

    Args:
        name (str): Name for the object.
        prim_path (str): prim path of the MaterialPrim.
        load_config (None or dict): If specified, should contain keyword-mapped values that are relevant for
            loading this prim at runtime. Note that this is only needed if the prim does not already exist at
            @prim_path -- it will be ignored if it already exists.
    Returns:
        MaterialPrim: Material prim at the specified path
    """
    # If the material already exists, return it
    if prim_path in cls.MATERIALS:
        return cls.MATERIALS[prim_path]

    # Otherwise, create a new one and return it
    new_material = cls(prim_path=prim_path, name=name, load_config=load_config)
    cls.MATERIALS[prim_path] = new_material
    return new_material

remove_user(user)

Removes a user from the material. This can be a BaseObject or BaseSystem. If there are no users left, the material will be removed.

Parameters:

Name Type Description Default
user BaseObject or BaseSystem

User to remove from the material

required
Source code in omnigibson/prims/material_prim.py
def remove_user(self, user):
    """
    Removes a user from the material. This can be a BaseObject or BaseSystem.
    If there are no users left, the material will be removed.

    Args:
        user (BaseObject or BaseSystem): User to remove from the material
    """
    self._users.remove(user)
    if len(self._users) == 0:
        self.remove()

set_input(inp, val)

Sets the input with corresponding name @inp associated with this material and shader

Parameters:

Name Type Description Default
inp str

Name of the shader input whose value will be set

required
val any

Value to set for the input. This should be the valid type for that attribute.

required
Source code in omnigibson/prims/material_prim.py
def set_input(self, inp, val):
    """
    Sets the input with corresponding name @inp associated with this material and shader

    Args:
        inp (str): Name of the shader input whose value will be set
        val (any): Value to set for the input. This should be the valid type for that attribute.
    """
    # Make sure the input exists first, so we avoid segfaults with "invalid null prim"
    assert inp in self.shader_input_names, \
        f"Got invalid shader input to set! Current inputs are: {self.shader_input_names}. Got: {inp}"
    self._shader.GetInput(inp).Set(val)

shader_force_populate(render=True)

Force populate inputs and outputs of the shader

Parameters:

Name Type Description Default
render bool

If True, takes a rendering step before force populating the inputs and outputs. Note that a rendering step is necessary to load these I/Os, though if a step has already occurred externally, no additional rendering step is needed

True
Source code in omnigibson/prims/material_prim.py
def shader_force_populate(self, render=True):
    """
    Force populate inputs and outputs of the shader

    Args:
        render (bool): If True, takes a rendering step before force populating the inputs and outputs.
            Note that a rendering step is necessary to load these I/Os, though if a step has already
            occurred externally, no additional rendering step is needed
    """
    assert self._shader is not None
    asyncio.run(self._load_mdl_parameters(render=render))

shader_input_names_by_type(input_type)

Parameters:

Name Type Description Default
input_type str

input type

required

Returns:

Name Type Description
set

All the shader input names associated with this material that match the given input type

Source code in omnigibson/prims/material_prim.py
def shader_input_names_by_type(self, input_type):
    """
    Args:
        input_type (str): input type

    Returns:
        set: All the shader input names associated with this material that match the given input type
    """
    return {inp.GetBaseName() for inp in self._shader.GetInputs() if inp.GetTypeName().cppTypeName == input_type}

shader_update_asset_paths_with_root_path(root_path)

Similar to @shader_update_asset_paths, except in this case, root_path is explicitly provided by the caller.

Parameters:

Name Type Description Default
root_path str

root to be pre-appended to the original asset paths

required
Source code in omnigibson/prims/material_prim.py
def shader_update_asset_paths_with_root_path(self, root_path):
    """
    Similar to @shader_update_asset_paths, except in this case, root_path is explicitly provided by the caller.

    Args:
        root_path (str): root to be pre-appended to the original asset paths
    """

    for inp_name in self.shader_input_names_by_type("SdfAssetPath"):
        inp = self.get_input(inp_name)
        # If the input doesn't have any path, skip
        if inp is None:
            continue

        original_path = inp.path if inp.resolvedPath == "" else inp.resolvedPath
        # If the input has an empty path, skip
        if original_path == "":
            continue

        new_path = os.path.join(root_path, original_path)
        self.set_input(inp_name, new_path)