I used UsdLux to create a mesh light, but it didn’t work. I want to create a hemispherical light source with light rays pointing toward the center of the sphere, to simulate uniformly scattered skylight. However, a DomeLight does not meet my needs.
First, I tried applying LightAPI to a plane. Although the light attributes appeared in the property panel, no matter how I adjusted the parameters, the mesh did not emit light.
My code is as follows
from pxr import Usd, UsdLux, Sdf, Gf
import omni.usd
import omni.kit.commands
stage = omni.usd.get_context().get_stage()
omni.kit.commands.execute('CreateMeshPrimWithDefaultXform',
prim_type='Plane',
prim_path=None,
select_new_prim=True,
prepend_default_prim=True,
above_ground=True)
mesh_prim = stage.GetPrimAtPath('/World/Plane')
# LightAPI
print(UsdLux.MeshLightAPI.CanApply(mesh_prim))
meshLightAPI = UsdLux.LightAPI(mesh_prim)
meshLightAPI.Apply(mesh_prim)
links = meshLightAPI.GetLightLinkCollectionAPI()
meshLightAPI.CreateColorAttr().Set(Gf.Vec3f(1.0, 1.0, 1.0))
meshLightAPI.CreateIntensityAttr().Set(1000000)
UsdLux.ShadowAPI.Apply(mesh_prim)
Additional note: The figure below shows the stage I created, where I placed a large cube to check whether the light was emitting. In this stage, I used UsdLux.RectLight.Define(stage, ‘/World/Plane’) to create a light, and it worked properly as a light source.
I ran the same code on both computers, and both used isaac - sim 4.2 and kit-app-template, and the result was a crash. Configured as follows
---------------------------------------------------------------------------------------------|
| Driver Version: 572.83 | Graphics API: D3D12
|=============================================================================================|
| GPU | Name | Active | LDA | GPU Memory | Vendor-ID | LUID |
| | | | | | Device-ID | UUID |
| | | | | | Bus-ID | |
|---------------------------------------------------------------------------------------------|
| 0 | NVIDIA GeForce RTX 3070 Ti Lap.. | Yes: 0 | | 8018 MB | 10de | 74260100.. |