How to turn a Mesh "light" on in Omniverse USD?

Operating System:
Windows
Kit Version:
107 (Kit App Template)
Kit Template:
Kit Base Editor
GPU Hardware:
3050 series
GPU Driver:
Latest
**

I have downloaded a Kitchen Set USD scene somewhere in internet. In there, there is a light object of type Mesh:** /Kitchen_set/Props_grp/Ceiling_grp/CeilingLight_1/Geom/pCylinder164
I want to turn this light on.

Because I’m very new to Omniverse and USD so I ask chatgpt and it give me this function
def enable_mesh_light_meshlightapi(prim_path, intensity=200.0, color=(1.0,1.0,1.0)):
stage = omni.usd.get_context().get_stage()
if not stage:
print(“No stage open.”); return False

prim = stage.GetPrimAtPath(prim_path)
if not prim or not prim.IsValid():
print(“Prim not found:”, prim_path);
return False

try:
    if UsdLux.MeshLightAPI.CanApply(prim):
        print("Applying MeshLightAPI to", prim_path)
        UsdLux.MeshLightAPI.Apply(prim)
        print('11111')
        lightApi = UsdLux.LightAPI(prim)
        print('22222')
        lightApi.CreateIntensityAttr().Set(float(intensity))
        print('33333')
        lightApi.CreateColorAttr().Set(Gf.Vec3f(*color))
        print('44444')
        # optional normalization by area:
        # lightApi.CreateNormalizeAttr().Set(True)

        prim.SetActive(True)

        print("MeshLightAPI applied & light attributes set.")
        return True
    else:
        print("MeshLightAPI cannot be applied to prim (CanApply==False).")
        return False
except Exception as e:
    print("Error applying MeshLightAPI:", e)
    return False

This is what it print in console
Applying MeshLightAPI to /Kitchen_set/Props_grp/Ceiling_grp/CeilingLight_1/Geom/pCylinder164
11111
22222

And it hang there forever. 33333 and 44444 and so on were never reached.
And my Kit become Not responding so I must kill it via Task Manager (or CMD)
What am I missing? Thanks

It sounds like you are talking about the LIGHTWHEEL Kitchen. You just need to turn on “mesh lights” in the Rendering Settings. But you also need to make sure that the material assigned to the mesh light is also a self illuminating material. If not you can drag one in from our Material library

Hi Richard,
Many thanks for your response!
Firstly, I turned the “mesh lights” on in the Rendering Settings, but the light was still not “on”. I suspect that I need to

make sure that the material assigned to the mesh light is also a self illuminating material. If not you can drag one in from our Material library

But,

  • I’m not sure how to find the “Material” view/tab on my Kit Base Editor
  • I’m not sure what “drag one” mean. Do you mean that I should click and hold the left mouse to the Material, then drag it to the Mesh Prim (the Light object), then drop it (release the left mouse)? Like Drag and Drop a File?

Secondly. how can I do it via Python code? I mean turn the Mesh (light) on by coding. Actually I’m reallocated to an Omniverse project, which is very new to me since I’m a Java based.

Thank you for your support!!

Hi @Richard3D can you help to check?

You don’t want to use Kit Base Editor. It’s not the right template. It’s just a simple code editor. You need a complete workflow editor. You need USD Composer.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.